3

Should my texture assets be linear or sRGB? In either case, what's the proper way to import them?

(There's a similar question on r/godot but I don't see any thorough answers.)

Godot seems to assume all PNG textures are linear, regardless of any gamma or sRGB info embedded in the PNG. I tested this by hex-editing a PNG to have various types of gAMA and sRGB chunks. This is at odds with most image editors, which tend to default to nonlinear color spaces. So if you create a PNG in e.g. Gimp and stick it on a Sprite3D, it will look washed-out by default.

Godot (in 3.2, at least) has an Srgb import option which, when set to Enable, makes such textures appear normal. But I'm concerned that:

  • This option seems to have been removed from trunk.
  • If the sRGB > linear conversion happens before the uint8 > float32 conversion, this will discard a lot of color precision.
  • What's the point of Srgb's default Detect setting if it doesn't detect actual sRGB PNGs?

There's also hint_albedo, but I would hope users wouldn't have to write shaders just to make textures work as expected.

What's the recommended texture workflow?

ppm
  • 178
  • 8

1 Answers1

0

The workflow goes as follows:

  • In 2D, HDR isn't used by default. Textures will be imported as non-sRGB if they're not detected to be used in 3D.
  • In 3D, HDR is used by default. Textures will automatically be imported as sRGB if they're detected to be used in 3D somehow. In 3D, they can also be detected as normal maps so they use RGTC compression (which is more efficient and better-looking than generic texture compression algoritms).

This option seems to have been removed from trunk.

This is intended, since the Vulkan renderer uses bindless textures. sRGB conversion is now done directly when rendering the texture rather than when importing it. This allows using the same texture in both 2D and 3D contexts and having it look correct in both. Likewise, in Godot 4.0, you'll be able to use the same texture with and without filtering without having to make a copy of it.

Calinou
  • 889
  • 8
  • 14
  • Thanks for your help! But I don't understand. "Textures will automatically be imported as sRGB if they're detected to be used in 3D" - I can't square that with my test. With Srgb=Detect, my Sprite3D looked pale, implying the PNG values were interpreted as if they were linear. I also tried using the same texture in both 2D and 3D; Srgb=Detect looks normal in 2D but pale in 3D, while Srgb=Enabled looks dark in 2D but normal in 3D. – ppm Apr 07 '20 at 02:28