faceForward
Orients a vector n to face in the direction opposite to an incident vector i, using nRef as a reference to determine if i is arriving from the front or back side.
If dot(nRef, i) is negative, it means i is considered to be on the "front side" (the side nRef points away from, assuming i points towards the surface), and n is returned as is. Otherwise, i is considered to be on the "back side" (or grazing the surface), and -n (the negation of n) is returned.
This is typically used to ensure a normal vector used in lighting calculations correctly faces the incident light or view vector.
Return
Returns n if dot(nRef, i) < 0.0, otherwise returns -n.
Parameters
The vector to orient, typically a normal vector.
The incident vector (e.g., view vector or light vector pointing towards the surface).
The reference normal, typically the geometric normal of the surface, used to determine the orientation of i relative to the surface.