vertexColor
vertexColor
Accesses the per-vertex color (`color`) attribute stored on a geometry, allowing these colors to be used directly in material calculations.
Core Advantages
Provides a convenient way to access different sets of vertex color data (by switching the index) with a simple function call, eliminating the need to manually declare GLSL `attribute`s and simplifying the workflow.
Common Uses
Displaying pre-baked lighting or procedural colors
Masking for blending between different textures or effects
Applying vertex-based Ambient Occlusion (AO)
How to adjust
Adjust by passing an integer `index` to the function. `vertexColor(0)` accesses the first vertex color attribute (usually 'color'), `vertexColor(1)` accesses the second, and so on, provided the corresponding data exists on the geometry.
Code Examples
1// Access the primary vertex color (index 0)
2const primaryColor = vertexColor( 0 );
3
4// Access a second vertex color attribute (index 1)
5const secondaryColor = vertexColor( 1 );