normalWorld
Provides the surface normal in the global World Space, correctly transformed by the object's rotation and scale. It is fundamental for standard lighting and environment reflections.
Core Advantages
Its core advantage is providing a normal in a common coordinate system shared by all scene elements (like lights and environment probes), making lighting and reflection calculations direct and accurate. Its value is independent of the camera view, which is crucial for effects like environment mapping.
Common Uses
As the core input for standard lighting models (like PBR) to calculate diffuse and specular light.
Calculating the reflection vector for environment maps to create surface reflection effects.
Creating procedural effects dependent on world direction, such as simulating snow on top of objects.
How to adjust
This is a read-only output, but its result can be used for debugging (e.g., `normalWorld.mul(0.5).add(0.5)` to visualize it as color), or be replaced in the shading logic (e.g., with the view direction) to create flat, cartoon-like silhouette effects.
Code Examples
1// Simulate a snow effect based on the angle to the world's up direction
2const upFactor = dot( normalWorld, vec3( 0, 1, 0 ) );
3const snowAmount = smoothstep( 0.6, 0.85, upFactor );
4output.color.rgb = mix( rockColor, snowColor, snowAmount );