Please help with normal map shder. Here is my code:
shader_type spatial;
uniform sampler2D _normal : hint_normal;
varying mat3 TBN; // from view to tangent space
varying mat3 INV_TBN; // from tangent to view space
void vertex() {
TBN = mat3(
(MODELVIEW_MATRIX * vec4(TANGENT, 1.0)).xyz, // from model to view space
(MODELVIEW_MATRIX * vec4(BINORMAL, 1.0)).xyz,
(MODELVIEW_MATRIX * vec4(NORMAL, 1.0)).xyz
);
INV_TBN = transpose(TBN);
}
void light() {
vec3 N = normalize(texture(_normal, UV).xyz * 2.0 - 1.0); // already in tangent space
vec3 L = TBN * LIGHT; // from view to tangent space
float NdotL = max(dot(N, L), 0.0);
DIFFUSE_LIGHT += NdotL * ATTENUATION * ALBEDO;
}
And here is what I get with it. For example here is standart Godot shader.
What is wrong with my shader?