godotengine / godotengine/godot
Spatial shader srgb -> linear hints not working for NoiseTexture2D
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in Godot 4.4 stable
- Tested in different versions, seems to be even going back to Godot 3
- Did not find a version with a different behaviour
### System information
Godot v4.4.stable - Windows 10 (build 19045) - Single-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4080 (NVIDIA; 32.0.15.6636) - AMD Ryzen 7 3700X 8-Core Processor (16 threads)
### Issue description
`NoiseTexture2D` is not correctly rendered in linear colorspace when being used in a **spatial shader**.
This is broken for the default `StandardMaterial3D` etc, but also does not work when using a custom shader.
The texture is not converted from srgb -> linear, no matter what uniform hints are used.
The problem of this bug comes up when a `NoiseTexture2D` is converted to an image to improve performance by avoiding noise calculation at runtime. Also multiple `NoiseTexture2D` can be converted to a single image file to pack them into channels and avoid unneccessary texture lookups in a shader.
The following image illustrates the issue.

## Exclaimer
I am aware that maybe it is not the correct use of `source_color` when using NoiseTexture2D in a shader. But the above is definitely not the expected behaviour as every other Texture2D format is correctly displayed either in linear or srgb colors space when using the uniform hints or not.
I also chatted with @clayjohn about this issue and he confirmed that it is not expected behaviour.
## Challenge / Problem
Fixing this bug straight away would potentially break a lot of vfx materials on live projects. I have seen hundreds of shaders that use NoiseTexture2D + `source_color` and building effects with it. Changing this behaviour would change the appearance of those effects.
Maybe that's ok and an exclaimer in the versions release notes mentioning the neccessary removal of the hint would be good.
### Steps to reproduce
- Create a Material on a MeshInstance3D + Quad
- Add a NoiseTexture2D to the albedo slot.
- Convert to shader
- Change the albedo textures uniform hints, observe no change.
### Minimal reproduction project (MRP)
[NoiseTexture2Dhints.zip](https://github.com/user-attachments/files/19273581/NoiseTexture2Dhints.zip)
Contributor guide
Research direction
Start with the NoiseTexture2D reproduction project and follow the spatial shader steps using StandardMaterial3D and the custom shader. Compare the albedo uniform hints with other Texture2D formats, then confirm that the selected srgb or linear behavior is applied without overlooking the compatibility concern for existing VFX materials.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, godot
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100