dashSize
Creates a variable inside the shader that is directly linked to a property of the same name on the JavaScript material object, serving as an intuitive bridge for dynamic control from JS.
Core Advantages
It fully automates the tedious process of defining, declaring, and updating uniforms. Developers can control shaders with intuitive JS code like `material.dashSize = 5.0`, significantly improving code readability, maintainability, and development efficiency.
Common Uses
As parameters for custom materials, such as defining the segment length, gap size, or line width of a dashed line.
As a real-time control knob for effects, like dynamically adjusting the strength or color of a glitch effect.
To parameterize rendering styles, such as setting the number of color levels for toon shading.
As a boolean switch to dynamically toggle different rendering logic paths within the shader (e.g., enabling/disabling a texture).
How to adjust
This node is not adjusted directly. Instead, you modify the associated property on the material object in JavaScript, e.g., `myMaterial.dashSize = 10.0;`. The visual effect depends entirely on how this value is used within the TSL node graph, such as changing the length of the visible segments in the code example above.
Code Examples
1
2// Create a dashed line pattern using dashSize and gapSize from JS
3const pattern = mod( uv().x, dashSize.add( gapSize ) );
4
5// If the calculated value is greater than dashSize, it's in a gap, so discard the fragment
6pattern.greaterThan( dashSize ).discard();
7