highpModelNormalViewMatrix
Provides the correct matrix (the inverse transpose of the model-view matrix) for transforming normal vectors, ensuring accurate lighting calculations even when an object undergoes non-uniform scaling, and supports high-precision rendering contexts.
Core Advantages
Automates the calculation and provision of the correct normal transformation matrix (inverse transpose), freeing developers from the tedious work of manual calculation, updates, and uniform passing. It fundamentally prevents lighting errors caused by non-uniform scaling and seamlessly supports high-precision rendering.
Common Uses
In standard lighting models (e.g., PBR), for transforming model normals to view space for lighting calculations.
In normal mapping, as a basis for constructing the TBN matrix to transform tangent-space normals to view space.
For rim lighting or Fresnel effects, to calculate the angle between the surface normal and the view direction.
In environment reflection/refraction, to unify the coordinate system of the normal and view vectors for calculating reflection/refraction directions.
How to adjust
This node has no adjustable parameters. Its value is demonstrated by the contrast between using it and not: without it (or by incorrectly using another matrix), a non-uniformly scaled object (like a squashed sphere) will have severely distorted lighting and deformed highlights. Using this node ensures that lighting and highlights appear natural and correct, regardless of how the object is transformed.
Code Examples
1
2// Transform the model-space normal to view-space
3const transformedNormal = ( highpModelNormalViewMatrix * normal() ).xyz;
4