I have a multi-layer tilemap used to make more soft edges in my terrain based on incline,rotation, etc. It depends on the top layers having some transparency so you can see the tiles underneath. I've also applied a normal map to each layers tiles (also with transparency in the upper layers). The problem is, while the normals appear correctly according to my shader, but as soon as I shine light on it, the upper layers are treated as if they have a different normal than the shader says it has? It's almost as if the normals stack across layers? All my normals are fully opaque where needed, so might be a godot bug
#normals in tilemap layers not reflecting light as expected
1 messages · Page 1 of 1 (latest)
I found a workaround:
I saved the normal vector from the fragment shader as a varying and used this custom light shader:
void fragment() {
vec3 normal = texture(NORMAL_TEXTURE, UV).rgb;
normal_vec = (normal- vec3(.5)) * 2.;
}
void light() {
//vec3 normal = texture(NORMAL_TEXTURE, UV).rgb;
float cNdotL = max(0.0, dot(normal_vec, light_dir));
LIGHT.rgba = vec4(LIGHT_COLOR.rgb * COLOR.rgb * LIGHT_ENERGY * cNdotL, LIGHT_COLOR.a);
}