materialPointSize
Provides access to the `size` property on a `PointsMaterial`, which defines the base size for each point in a point cloud.
Core Advantages
Completely abstracts the underlying `gl_PointSize` variable and Uniform management, seamlessly integrating with the `material.size` property and allowing developers to control point size in the TSL vertex shader in a standard and convenient way.
Common Uses
Setting a uniform size for static point clouds (e.g., starfields, 3D scan data).
As a base value for calculating custom size attenuation (perspective) effects.
As a base size for animations, combined with a time node for particle pulsing or explosion effects.
In data visualization, as a global scaling factor combined with vertex attributes to represent data.
As the default size for interactive feedback, temporarily increased on hover.
How to adjust
Adjust by modifying the `size` property (a number) of the `PointsMaterial` in JavaScript. This value defines the base size of the points. In TSL, this node can be used as a base value and combined with other nodes (e.g., `timer`, `positionLocal`) for non-uniform dynamic effects.
Code Examples
1// In the vertex shader, make each point twinkle independently based on its position
2const uniquePhase = positionLocal.x.add( positionLocal.z );
3const twinkleFactor = sin( timerLocal().mul( 3 ).add( uniquePhase ) ).mul( 0.5 ).add( 1 );
4
5// Multiply the material's base size by the twinkle factor for the final size
6const finalSize = materialPointSize.mul( twinkleFactor );
7
8// Assign the result to the point cloud's pointWidth output
9pointCloud.pointWidth = finalSize;