I am working on a normal mapping. I need to have the ability to scale normal vectors to adjust the normal strength of the surface. Currently the way I am doing it basically shows plausible results. But I am still not sure that it's 100% correct and to my surprise I found no info on the web regarding this subject. So here is how I do that (my lightning is in camera space):
vertex shader:
vec3 N = normalize(normalMatrix * a_normal);
vec3 T = normalize(normalMatrix * a_tangent.xyz) * nStrength;
vec3 B = normalize(normalMatrix * (cross(a_normal, a_tangent.xyz) * a_tangent.w) ) * nStrength;
v_TBN = mat3(T,B,N);
normalMatrix - inverse-transpose of model-view matrix.
The shading itself happens in the fragment shader. The only relevant part which is happening there is transforming normal from the texture with v_TBN varying:
Fragment shader:
vec3 GetNormal(){
vec3 n = texture(normalMap,uv).xyz;
n = normalize(n * 2.0 - 1.0);
return normalize (v_TBN * n);
}
So, as you can see, I scale tangent and bi-tangent vectors with nStrength scalar.That's the most optimal setup I figured out that gives most correct looking effect.Is this the right way to strengthen the normals?