Hi all,
It's been a while since I've been working on my HLSL shaders, and found out I'm not 100% sure if I'm applying gamma correctness correctly. So here's what I do:
- create backbuffer in this format: DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
- source textures (DDS) are always in SRGB format
- this way the textures should be gamma correct, because DX11 helps me out here
Now my question is about material and light colors. I'm not sure if I need to convert those to linear space. The colors are handpicked on screen, so I guess gamma correct. Below are 2 screenshots, the darker is including converting those colors (``return float4(linearColor.rgb * linearColor.rgb, linearColor.a);``), in the lighter shot I didn't do this conversion.
These are the properties of the brick material and the light source (there are no other lightsources in the scene, also no global ambient):
Material:
CR_VECTOR4(0.51f, 0.26f, 0.22f, 1.0f), // ambient
CR_VECTOR4(0.51f, 0.26f, 0.22f, 1.0f), // diffuse RGB + alpha
CR_VECTOR4(0.51f, 0.26f, 0.22f, 4.0f)); // specular RGB + power
Directional light:
mDirLights[0].Ambient = CR_VECTOR4(0.1f, 0.1f, 0.1f, 1.0f);
mDirLights[0].Diffuse = CR_VECTOR4(0.75f, 0.75f, 0.75f, 1.0f);
mDirLights[0].Specular = CR_VECTOR4(1.0f, 1.0f, 1.0f, 16.0f);
mDirLights[0].Direction = CR_VECTOR3(0.0f, 1.0f, 0.0f);
So in short, should I or should I not do this conversion in the lighting calculation in the shader? (and/or what else are you seeing :))
Note that I don't do anything with the texture color, after it's fetched in the shader (no conversions), which I believe is correct.