:)
TL:DR
When writing a custom spatial shader the ALBEDO
color isn't the output color, even if render_mode unshaded
is set.
Long story
I created a new project in Godot v3.4.4.stable.official [419e713a2] and simply added two CSGBox.
For the left one I assigned a SpatialMaterial and set it to unshaded and assigned an albedo texture (see below). The result is as expected.
However, for the right one I assigned a ShaderMaterial and wrote the following, very simple, shader:
shader_type spatial;
render_mode unshaded;
uniform sampler2D albedo;
void fragment() {
ALBEDO = texture(albedo, UV).rgb;
}
After assigning the same texture to the albedo
shader parameter, the result is a lot too bright. I already tried several render_modes, variables such as SPECULAR and other things like texture import settings, but couldn't figure out how to get the same result as the left box.
The texture
The result
Left side: As expected using SpatialMaterial, Right side: Too bright using ShaderMaterial
Sample project
Well, it's nothing big, but if you want to take a look: https://files.catbox.moe/nj407g.zip
Thank you in advance ❤
This is something that is often dismissed in tutorials and explanations: Adding
hint_albedo
tells Godot to do an sRGB to linear conversion. The documentation about uniforms mentions:So change this line:
To this:
And it should give you the expected result.