Announcement

Collapse
No announcement yet.

Matching GLSL Normals to VrayNormals

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

    Code:
    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.
    Gavin Greenwalt
    im.thatoneguy[at]gmail.com || Gavin[at]SFStudios.com
    Straightface Studios

  • #2
    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:

    http://docs.chaosgroup.com/display/V...port+in+V-Ray#
    NOTE: When using the transformation matrices, always place the vector to be transformed on the right-hand side.
    Code:
    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?
    Last edited by im.thatoneguy; 25-08-2015, 07:18 PM.
    Gavin Greenwalt
    im.thatoneguy[at]gmail.com || Gavin[at]SFStudios.com
    Straightface Studios

    Comment

    Working...
    X