positionLocal
Represents the final local space position after vertex shader calculations, automatically passed as an interpolated coordinate (Varying) to the fragment shader.
Core Advantages
Its core advantage is being a Varying, automatically interpolating the final local position calculated in the vertex shader for each fragment. This provides the foundation for creating procedural textures and effects that are 'stuck' to the model itself.
Common Uses
Creating model-space procedural textures in the fragment shader, like a 3D checkerboard.
Implementing model-space clipping effects by discarding fragments based on their local coordinate distance.
Visually debugging vertex displacement results by outputting its value as a color.
How to adjust
Its value is changed in the vertex shader by modifying the logic of `NodeMaterial.positionNode` (e.g., adding noise displacement). In the fragment shader, its interpolated output can be used to create various effects, like stripe patterns or 3D checkerboards.
Code Examples
1// Create a 3D checkerboard pattern based on the interpolated local position
2const pattern = mod(
3 floor( positionLocal.x ).add( floor( positionLocal.y ) ).add( floor( positionLocal.z ) ),
4 2.0
5);
6output.color.rgb = vec3( pattern );