Troubleshooting gamma issues

Written by Jesper Tingvall, Product Expert, Simplygon

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.

Introduction

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.

Original grammophone to left and much darker grammophone to right.

Solution

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.

Texture.png → TextureNode → ColorCaster → Optimized_texture.png → GameEngine

Color caster

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.

OutoutSRBG flag in Blender UI

This can also be done via scripting by SetOutputSRGB on the ColorCasterSettings object.

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.

Texture node

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.

Result

After using correct sRBG flag we can process the asset without any color problems.

Original grammophone to left and much identical optimized grammophone to right.

⇐ Back to all posts

Request 30-days free evaluation license

*
*
*
*
Industry
*

Request 30-days free evaluation license

*
*
*
*
Industry
*