I am trying to blend two world space normals inside a shader. One comes from a tangent space normal map converted into world space using a classic TBN matrix and the other one is a mesh normal map in world space.
I found some interesting resources here :
But those blending technics seem to be only available for tangent space normals, especially the Reoriented Normal Mapping (RNM). I tried to apply the RNM technic with unpack already done.
n1 += vec3(0, 0, 1);
n2 *= vec3(-1, -1, 1);
return n1 * dot(n1, n2) / n1.z - n2;
But this doesn't give expected results and I don't get why. Is there a way to apply the RNM blending on world space normals ?
Thanks a lot.
Edit: Here are some output and the result I am having with RNM. The A normal is not disturbed by the B normal, it gives some strange massively reoriented results.
float3 nv = dot(normal, viewDir);
color.rgb = nv;
I would expect that you would need to feed the mesh's normal/tangent/bitangent into the equation somehow. You might consider simply transforming the world space normal into tangent space, applying RNM, then transforming the result to world space—that's only one extra 3x3 mul.
– John Calsbeek Apr 19 '16 at 14:17