ivec3
Converts any 3D vector input (like a vec3) into a 3-component integer vector (ivec3) by truncating the decimal part of each component.
Core Advantages
Provides type safety for GPU operations requiring 3D integer coordinates, such as `texelFetch` on 3D textures. It abstracts the low-level `ivec3()` constructor, making it intuitive and cross-backend compatible to create 3D-space-based discrete logic (like volume noise or 3D checkerboards).
Common Uses
Providing integer coordinates (voxel addresses) for `texelFetch` on 3D textures (volume textures)
Calculating spatial grid indices for 3D procedural content (e.g., 3D checkerboards)
Providing sample coordinates for 2D Texture Arrays (xy for pixel, z for layer index)
Converting float positions to integer indices in spatial hashing or grid acceleration structures
How to adjust
Its visual effect is controlled by its input. For a 3D procedural pattern, increasing the multiplier on the input coordinates before the `ivec3` node makes the final 3D pattern (e.g., a checkerboard) denser. Adding a `timer` to the input causes the entire 3D integer grid to shift over time, making the pattern appear to 'flow' or 'travel' through the model.
Code Examples
1// Scale local position and convert to a 3D integer index for a 3D checkerboard
2const voxelIndex = ivec3( positionLocal.mul( 5 ) );
3
4// Determine color based on the parity of the 3D index
5const indexSum = voxelIndex.x.add( voxelIndex.y ).add( voxelIndex.z );
6const isEven = indexSum.mod( 2 ).equal( 0 );