[Bf-codereview] Gamma Node for Cycles (issue 5488046)

brechtvanlommel at gmail.com brechtvanlommel at gmail.com
Sun Dec 18 13:17:50 CET 2011


Gamma 2.2 and 1.0/2.2 should cancel each other out. However, Blender
sRGB <=> linear conversion is not a simple gamma conversion, the formula
for that is quite different:

float srgb_to_linearrgb(float c)
{
     if (c < 0.04045f)
         return (c < 0.0f)? 0.0f: c * (1.0f/12.92f);
     else
         return powf((c + 0.055f)*(1.0f/1.055f), 2.4f);
}

float linearrgb_to_srgb(float c)
{
     if (c < 0.0031308f)
         return (c < 0.0f)? 0.0f: c * 12.92f;
     else
         return  1.055f * powf(c, 1.0f/2.4f) - 0.055f;
}

http://codereview.appspot.com/5488046/


More information about the Bf-codereview mailing list