IIRC, the 'viewer' variable holds the position of the camera in world space. You can multiply a vertex-position with 'worldMat' to convert it to world space, then perform a subtraction and normalize to get the viewer-direction in world-space. You can then multiply the normal with 'worldNormalMat' to get the world space normal, and perform the dot product to get the angular difference.
In view space, the position of the camera should be (0,0,0) -- view space is relative to the camera. So alternatively, if you want to work in view-space instead of world-space, just normalise the view-space vertex-position to get the direction from the camera to the vert.
|