src/math/Color.cpp
/** Quantizes the linear color and returns the result as a FColor with optional sRGB conversion and quality as goal. */
Quantizes the linear color and returns the result as a FColor with optional sRGB conversion and quality as goal.
Quantizes the linear color and returns the result as a FColor with optional sRGB conversion and quality as goal .
FColor FLinearColor::ToFColor(const bool bSRGB) const
	{
		float FloatR = FMath::Clamp(r, 0.0f, 1.0f);
		float FloatG = FMath::Clamp(g, 0.0f, 1.0f);
		float FloatB = FMath::Clamp(b, 0.0f, 1.0f);
		float FloatA = FMath::Clamp(a, 0.0f, 1.0f);
		if (bSRGB)
		{
			FloatR = FloatR <= 0.0031308f ? FloatR * 12.92f : FMath::Pow(FloatR, 1.0f / 2.4f) * 1.055f - 0.055f;
			FloatG = FloatG <= 0.0031308f ? FloatG * 12.92f : FMath::Pow(FloatG, 1.0f / 2.4f) * 1.055f - 0.055f;
			FloatB = FloatB <= 0.0031308f ? FloatB * 12.92f : FMath::Pow(FloatB, 1.0f / 2.4f) * 1.055f - 0.055f;
		}
		FColor ret;
		ret.a = FMath::FloorToInt(FloatA * 255.999f);
		ret.r = FMath::FloorToInt(FloatR * 255.999f);
		ret.g = FMath::FloorToInt(FloatG * 255.999f);
		ret.b = FMath::FloorToInt(FloatB * 255.999f);
		return ret;
	}
FColor FLinearColor :: ToFColor ( const bool bSRGB ) const { float FloatR = FMath :: Clamp ( r , 0.0f , 1.0f ) ; float FloatG = FMath :: Clamp ( g , 0.0f , 1.0f ) ; float FloatB = FMath :: Clamp ( b , 0.0f , 1.0f ) ; float FloatA = FMath :: Clamp ( a , 0.0f , 1.0f ) ; if ( bSRGB ) { FloatR = FloatR <= 0.0031308f ? FloatR * 12.92f : FMath :: Pow ( FloatR , 1.0f / 2.4f ) * 1.055f - 0.055f ; FloatG = FloatG <= 0.0031308f ? FloatG * 12.92f : FMath :: Pow ( FloatG , 1.0f / 2.4f ) * 1.055f - 0.055f ; FloatB = FloatB <= 0.0031308f ? FloatB * 12.92f : FMath :: Pow ( FloatB , 1.0f / 2.4f ) * 1.055f - 0.055f ; } FColor ret ; ret . a = FMath :: FloorToInt ( FloatA * 255.999f ) ; ret . r = FMath :: FloorToInt ( FloatR * 255.999f ) ; ret . g = FMath :: FloorToInt ( FloatG * 255.999f ) ; ret . b = FMath :: FloorToInt ( FloatB * 255.999f ) ; return ret ; }
Quantizes the linear color and returns the result as a FColor with optional sRGB conversion and quality as goal.
Quantizes the linear color and returns the result as a FColor with optional sRGB conversion and quality as goal .