Matching GLSL Normals to VrayNormals

I’m attempting to just establish a baseline vrayGLSL Normal map shader which maintains the geometric normals. However I’m having trouble using the vr_CameraToWorld to transform cameraspace normals into worldspace normals.

vec3 wNormal()
{
   vec3 cNormal = vr_Normal;
   vec4 worldvec = vr_CameraToWorld * vec4(cNormal.x,cNormal.y,cNormal.z,0.0);
   return vec3(worldvec.x,worldvec.y,worldvec.z);
}

I’m sure it’s something incredibly obvious but I’m not sure what the correct matrix operation is to transform screen tow orld.

Ok… it was in fact mighty stupid. Correct function puts the transformation matrix on the right hand side. Although in my defense I was following the instructions in the documentation which state:

NOTE: When using the transformation matrices, always place the vector to be transformed on the right-hand side.


vec3 wNormal()
{
   return (vec4(vr_Normal, 0.0) * vr_CameraToWorld).xyz;
}

Just a note on a weird quirk. Y is inverted in Max’s shading space?