pointUV
When rendering `Points`, provides the 2D local coordinates (UV) of the current fragment on an individual point's quad, corresponding to the GLSL built-in `gl_PointCoord`.
Core Advantages
It allows for efficiently applying independent textures or procedural patterns (like circles or stars) to each point, transforming simple points into complex visual elements. This is achieved by leveraging native GPU support, which is highly performant and avoids creating extra geometry.
Common Uses
Clipping default square points into circles or soft-edged dots by calculating the distance to the point's center and discarding fragments.
Serving as texture coordinates to sample a sprite map for each particle in a system (e.g., sparks, smoke).
As input for math or noise functions to procedurally generate patterns within a point without using textures (e.g., radial gradients).
How to adjust
This node itself is not adjustable. Its effect is altered by performing math operations on its output `vec2` coordinate. For example, `pointUV.sub(0.5)` centers the coordinate system, simplifying radial calculations; `pointUV.mul(2.0)` will tile or scale a texture/pattern; and `pointUV.yx` swaps the UV coordinates, rotating non-symmetrical patterns.
Code Examples
1// Calculate the distance from the current fragment to the point's center (0.5, 0.5)
2const dist = pointUV.distance( vec2( 0.5 ) );
3
4// Use smoothstep to create a soft circular edge (alpha)
5const strength = smoothstep( 0.5, 0.4, dist );
6
7// Apply the alpha to the color, rendering the square point as a soft circle
8material.colorNode = vec4( baseColor, strength );