Hey there!
I'm quite new to Godot, to materials and to shaders too
(Sorry for my poor english too!)
I'm trying to understand fragment shaders and how I could use them to customize colors on my models.
While trying to do this, I noticed that if I use a ShaderMaterial, I am never able to get exactly the same color / tone that I get when using StandardMaterial3D.
My standard material has no particular options that differ from the default (only roughness = 0.55)

My shader material uses the same texture as the standard material below and has a very simple script (that does nothing for the moment, but getting the color from the original texture):

shader_type spatial;
render_mode cull_disabled;

uniform sampler2D base_texture;
void fragment() {
	ROUGHNESS = 0.55;
	vec4 current_color = texture(base_texture, UV);
	ALBEDO = current_color.rgb;
}

Anyway, I get an important difference when displaying one model using the StandardMaterial3D and another one using the ShaderMaterial, as you can see:

Why are they so different?
I feel like I miss something... Anyone to point me towards the right direction?

  • xyz replied to this.
  • AkakiAkakievitch Convert your standard material to a shader material and look into generated shader code to see what gets included.

    xyz
    Thank you very much! I was missing a source_color hint after the texture.
    uniform sampler2D base_texture : source_color;

    I found in the documentation that:

    It's important to understand that textures that are supplied as color require hints for proper sRGB -> linear conversion (i.e. source_color), as Godot's 3D engine renders in linear color space. If this is not done, the texture will appear washed out.

    Thank you very much! It's a good trick that I'll remember!