normalView
Provides the surface normal relative to the camera (view space normal), and automatically switches between smooth and flat shading based on material settings.
Core Advantages
Its core advantage is automatically selecting the correct normal type based on the material's `flatShading` property, greatly simplifying code, while providing a convenient, unified input for view-dependent effects like Fresnel and Matcap.
Common Uses
Implementing the Fresnel effect (rim lighting) by calculating the angle to the view direction to highlight object silhouettes.
Serving as UV coordinates for Matcap (Material Capture) shading to efficiently achieve complex non-photorealistic rendering.
Performing calculations for traditional lighting models (like Blinn-Phong) in view space.
How to adjust
Toggle the material's `material.flatShading` property to switch between smooth and low-poly (Flat) styles. Its output can also be mathematically manipulated in the node graph (e.g., adding a sine wave distortion) to create stylized visual distortions.
Code Examples
1// Calculate Fresnel/rim light effect based on the dot product of normalView and the view direction
2const fresnelFactor = pow( saturate( dot( normalView, vec3( 0, 0, 1 ) ) ).oneMinus(), 3.0 );
3output.color.rgb = mix( baseColor, rimColor, fresnelFactor );