Troubleshooting gamma issues
Disclaimer: This post is written using version 10.0.1400.0 of Simplygon. If you encounter this post at a later stage, some of the API calls might have changed. However, the core concepts should still remain valid.
If you have processed assets in Simplygon and the output had another color shade, then this post is for you. In this post we'll go through how to detect and solve gamma issues.
Problem to solve
The problem with incorrect gamma settings can be detected by that the output from a process involving material casting has wrong shade of color. Here it is very apperent with original asset to left and output after a aggregation with material baking to right. It is also possible for problem to be other way around; processed asset is much more bright then original asset.
The solution is to use the correct settings on each step during material casting and ensuring it matches the input texture's setting as well as what the game engine expects.
Changing the sRBG flag can be done per color caster using the user interface. Image below is from Blender but other plug-ins are identical.
This can also be done via scripting by
SetOutputSRGB on the
color_caster = sg.CreateColorCaster() color_caster_settings = color_caster.GetColorCasterSettings() color_caster_settings.SetOutputSRGB(True)
Changing a casters sRGB flag is the simplest test you can do if you suspect that you have gamma issues.
In most cases the model importer will set the correct sRBG flag on the texture node upon import. There are however some cases where this can fail. One such example is in the gltf format. The format does not contain any data if the texture is in gamma corrected or not. Upon importing an gltf file we assume that the texture is gamma corrected, unless it is an normal map.
To change a texture nodes gamma flag we need to find the
ShadingTextureNode for faulty texture and change it's
SetUseSRGB flag. An example on how to do this can be found in this blog post.
sRGB and normal maps
If we ponder what a gamma corrected normal map would mean we can very easy find out that normal maps should never be gamma corrected. Gamma correction allocates different amount of bits depending on brightness. What that would mean for a normal map is depending on where the normal is pointing it would have different resolution.
After using correct sRBG flag we can process the asset without any color problems.