Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No method for setting an Texture2DRD with an rd_format_srgb resulting in incorrect display in either 3d or 2d #103836

Open
DDarby-Lewis opened this issue Mar 8, 2025 · 1 comment

Comments

@DDarby-Lewis
Copy link

Tested versions

godot 4.3

System information

Godot v4.3.stable (77dcf97) - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 with Max-Q Design (NVIDIA; 31.0.15.3161) - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz (12 Threads)

Issue description

As the title says I don't think that the feature exists (this might not be the correct place to raise this - let me know if not), but I am raising it as a bug since it results in Texture2DRD resources displaying either too pale in 3D or too dark in 2D neither of which is ideal.

Overview of the issue:

Create a Texture2DRD resource, assign it a nice color texture, view it in 3D, it looks OK, view it in 2D, it looks too dark. Think, Ok, so it should be converted to SRGB, do so, look good in 2D, view in 3D, look too light.

Workarounds:

  • There are of course things we could do here, if the texture is OK for 2D (i.e. it is in SRGB) you can set your 3D shader to convert to linear.
  • You can duplicate all textures and convert the dups.

None of these are ideal as each requires additional work for each created resource.
If this were a few versions ago I'd assume it was a limitation and ignore it, or use one of the above workarounds. However I read that this was solved with bindless textures in vulcan (not sure what that means), and I have seen that it works once I have exported my Texture2DRD as a png, see below.

I have looked at how this is handled in the engine and from what I can tell there is a rd_format_srgb member on the RD::TextureStorage::texture object which when set will generate a shared texture with a view that converts the texture to SRGB for 2D.
I think this is how it functions at least, please correct me if I am off.

This is what it looks like in game, here in 3D I have my Texture2DRD (data in linear space) on the left on the cube, and a PNG the right (the png was created by converting the Texture2DRD to SRBG and then exporting as an image, since PNG is assumed to be SRGB).

Image

And here is the 2D view of these two image side by side, again RD on the left and PNG on the right.

Image

Steps to reproduce

Create a Texture2DRD resource, assign it a nice color texture, view it in 3D, it looks OK, view it in 2D, it looks too dark. Think, Ok, so it should be converted to SRGB, do so, look good in 2D, view in 3D, look too light.

Minimal reproduction project (MRP)

NA

@clayjohn
Copy link
Member

clayjohn commented Mar 9, 2025

Are you using the source_color hint in your shader? If you use it, the shader should automatically switch between linear and sRGB for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants