ivec4
Converts any 4D vector input (like a vec4) into a 4-component integer vector (ivec4) by truncating the decimal part of each component.
Core Advantages
It is a cornerstone for implementing advanced features like skeletal animation by safely handling packed integer vertex attributes (e.g., bone indices `skinIndex`). It abstracts the low-level `ivec4()` constructor, making it simple and less error-prone to handle compound integer data in TSL.
Common Uses
In skeletal animation, reading the bone indices (`skinIndex`) for each vertex
Unpacking a `vec4` uniform into four separate integer configurations or flags
Calculating discrete integer lattice indices for 4D procedural noise
Providing addressing coordinates for multi-dimensional texture arrays in custom pipelines
How to adjust
Its visual effect is discrete and channel-separated. Adjusting one component of its input `vec4` only affects the logic that depends on that integer. For instance, one component might control the level of color quantization (changing color block density), while another acts as a switch (0 or 1) to perform a hard toggle between two completely different visual effects.
Code Examples
1// Unpack four integer settings from a single vec4 uniform
2const intSettings = ivec4( settingsUniform );
3
4// Use the first integer component as a switch
5const isEffectOn = intSettings.x.equal( 1 );
6
7// Use the second integer component as a quantization level
8const quantizedValue = floor( someValue.mul( intSettings.y ) ).div( intSettings.y );