ivec2
Converts various inputs (like a vec2) into a 2-component integer vector (ivec2) by truncating the decimal part of each component.
Core Advantages
Ensures type safety for GPU functions that strictly require integer coordinates, like `texelFetch`. It abstracts the low-level `ivec2()` constructor, simplifying the creation of discrete, grid-based logic (like mosaics or checkerboards) in a readable, cross-backend compatible way.
Common Uses
Providing exact integer coordinates for `texelFetch` to read a specific pixel from a texture
Calculating grid indices for procedural patterns like checkerboards or tiles
Creating pixelation or mosaic effects by discretizing continuous UV coordinates
Accessing data from grid-based data textures
How to adjust
Its visual effect is controlled by its input. For a procedural pattern, increasing the multiplier on the input UVs before the `ivec2` node will make the resulting pattern (e.g., a checkerboard) denser and smaller. Adding a `timer` to the input will cause the integer grid to shift over time, creating a scrolling animation.
Code Examples
1// Scale continuous UVs and convert to an integer index for a checkerboard
2const gridIndex = ivec2( uv().mul( 10 ) );
3
4// Determine color based on the parity of the integer index
5const isEven = gridIndex.x.add( gridIndex.y ).mod( 2 ).equal( 0 );
6const finalColor = conditional( isEven, color('white'), color('black') );