Sunday 8 September 2013

faceforward

Definition from RSL documentation:

vector faceforward(vector N, I [,Nref = Ng])
{
          return sign(-I.Nref) * N;
}

This function is taking I, the incident ray from camera to the shading point, inverse it so that the ray direction is from the shading point back to camera. Then perform a dot product with Ng (surface geometric normal). Any shading point that is facing away from the camera view (the green lines on the image) will have the dot product to return a negative value. The sign function simply return -1 if the dot product calculation returns a negative value. If it is a positive value, the sign function will return positive 1.  Multiply again with the input N, (surface shading normal), the faceforward function eventually return a normal vector that is in negative value if it is facing away from camera.




















No comments:

Post a Comment