I’m working on my first shader with the script of:
shader_type spatial;
// import the textures
// base colour texture
uniform sampler2D base_colour : source_color;
// shadow colour texture
//uniform sampler2D shadow_colour;
// if no shadow colour texure use base_colour and multiply
//uniform vec3 shadow_colour = texture(base_colour, UV).rgb * vec3(0.0);
uniform vec4 shading_multiplier = vec4(.264, .205, .626, .408);
// R, G, B, and Alpha channels:
uniform sampler2D R_tga : source_color;
uniform sampler2D G_tga : source_color;
uniform sampler2D B_tga : source_color;
uniform sampler2D A_tga : source_color;
void vertex() {
// Called for every vertex the material is visible on.
}
void fragment() {
// Called for every pixel the material is visible on.
// get base colour and multiply by shadow to create shading colour
vec4 shadow_colour = texture(base_colour,UV) * shading_multiplier;
ALBEDO = texture(base_colour,UV).rgb;
}
//void light() {
// Called for every pixel for every light affecting the material.
// Uncomment to replace the default light processing function with this one.
//}
While the result is close (unshaded Godot on left, blender render on right):
Its not quite right. All my dark purples now look dark brown, looking at the RGB values their only a little bit off but I need the to be exactly the same otherwise all the original colour contrasts won’t come through. I’ve had a look online and seen the documentation about colour washing but from what I understand my script shouldn’t have that problem now. Any suggestions on what I can do?
could be all sorts of things. event unshaded, adding an environment node and changing the tonemapping will make a difference:
also, did you use a similar shader in blender? because the shading multiplier may be different, but even if you used the same multiplier in a blender shader, no two rendering engines will do colour mapping identically.
Also dont forget to check the the actual colour picker you chose the colour from, they have different colour interpolations similar to the tonemap the camera uses, and that changes how the actual RGB values are interpreted
The blender model is only altering the colours where there is shading, the unshaded parts should be the same but arnt.
If the render engines are going to render the colours differently how am I supposed to design my models colours so they are consistent? that’s incredibly annoying.
I’m using a website to pick the colours and it picks by pixel so they should be correct.
double click the image in Godot’s filesystem, then change the import settings (the “Import” tab usually located next to “Scene”). There should be a check box for “High Quality” if it’s been used in 3D.
can I ask u a quick question about colour mixing in Godot?
I had a look a the blender documentation and I think the mixing ratio just sort of controls the alpha of the mix colour and over laps it. Do you know how I would be able to do that that in Godot?
Godot uses a pretty raw GLSL shading variant, maybe you want the mix function, I am not sure exactly what you want to do, but this line should mix based on alpha
uniform sampler2D base_colour : source_color, filter_nearest; //this is my base/lit colourtexture.
uniform vec4 shading_multiplier = vec4(.264, .205, .626, .408) // the RGB are the colour of the mix I used in blender and the Alpha is the mix ratio.
What I think I need to do is somehow overlap the colours so the render shows the shading colour over the base colour, but in such a way that the shading colour is transparent by 0.408. if that makes sense. Ive tried controlling the mix amount but i dont think thats it, multiply numbers smaller than 1 always gives u a smaller number afterall.
mix is probably good for that, it’s really more of a lerp function, so given this line a alpha of 1.0 will only show the texture, and a alpha of 0.0 will only show the shading multiplier colors.