faceForward
Orients a vector (e.g., a geometric normal) to face towards the observer, based on a reference direction. It's like ensuring a mirror always faces you, flipping it if it's facing away.
Core Advantages
Encapsulates a complex conditional vector flip logic (dot product, comparison, multiplication) into a single, highly efficient, and semantically clear node, significantly improving performance and graph readability.
Common Uses
Providing uniform and correct refraction/reflection calculations for double-sided materials.
Reinforcing rim lighting effects so they appear correctly and continuously on both front and back faces.
In Non-Photorealistic Rendering (NPR), forcing normal directions to achieve specific stylized lighting.
How to adjust
Adjusting the inputs (especially the incident vector I) changes the definition of 'forward'. For a double-sided plane, using faceForward on its normal ensures smooth and continuous lighting calculations. As the plane rotates from front-facing to back-facing, the lighting effect fades and brightens smoothly, instead of abruptly jumping due to a sudden normal flip, because the node ensures the normal used for lighting always points towards the observer.
Code Examples
1// If dot(I, Nref) < 0, returns -N, otherwise returns N.
2const correctedNormal = faceForward( N, I, Nref );