inline void color_t::ColorSpace_from_linearRGB(colorSpaces_t colorSpace, float gamma)
{
//NOTE: Alpha value is not converted from linear to color space and vice versa. Should it be converted?
if(colorSpace == SRGB)
{
R = sRGB_from_linearRGB(R);
G = sRGB_from_linearRGB(G);
B = sRGB_from_linearRGB(B);
}
else if(colorSpace == XYZ_D65)
{
float oldR = R, oldG = G, oldB = B;
R = XYZ_D65_from_linearRGB[0][0] * oldR + XYZ_D65_from_linearRGB[0][1] * oldG + XYZ_D65_from_linearRGB[0][2] * oldB;
G = XYZ_D65_from_linearRGB[1][0] * oldR + XYZ_D65_from_linearRGB[1][1] * oldG + XYZ_D65_from_linearRGB[1][2] * oldB;
B = XYZ_D65_from_linearRGB[2][0] * oldR + XYZ_D65_from_linearRGB[2][1] * oldG + XYZ_D65_from_linearRGB[2][2] * oldB;
}
else if(colorSpace == RAW_MANUAL_GAMMA && gamma != 1.f)
{
if(gamma <= 0.f) gamma = 1.0e-2f; //Arbitrary lower boundary limit for the output gamma, to avoid division by 0
float invGamma = 1.f / gamma;
gammaAdjust(invGamma);
}
}
Return to Materials and Texturing
Users browsing this forum: No registered users and 3 guests