In custom shaders, why is the final computed color converted to `sRGB`?

I read the custom shader guide, where the final sentence is:

When scene.highDynamicRange is false, the final computed color (after custom shaders and lighting) is converted to sRGB.

Why is that?

I stumpled upon it because we use custom shaders for some geometry, namely a big sphere with transfomed photos textured on it, and some 3D point clouds.

I compared how the photos looked in my filesystem, and how they looked on my geometry, and the ones on the geometry (both sphere and point cloud) where noticeably brighter, to the point where some dark (almost black) areas became quite colourful. I fixed this by converting the already linear colors to linear, so that when Cesium converts them to sRGB, they are correct again:

return czm_srgbToLinear(colorFromTexture.rgb)

Is there a better way to “turn off” that built-in conversion from linear to sRGB? I don’t want to set scene.highDynamicRange to true, because that changes a lot in the scene (e.g., label rendering), and it seems an unrelated feature, because we are not using HDR photos.

3 Likes