batch
In a BatchedMesh, wraps a node (e.g., a color node) to enable it to access unique attribute values for each object in the batch, allowing for the efficient rendering of many varied objects in a single draw call.
Core Advantages
Its core value is abstracting complex batch data access into a simple function call. By wrapping a property node with batch(), developers can give each object independent, dynamic attributes while maintaining the extreme performance of a single draw call, perfectly combining performance and flexibility.
Common Uses
Providing unique positions, rotations, and scales for large-scale vegetation or scenery (trees, rocks).
Providing independent transformation matrices and colors for crowds of dynamic units (NPCs, enemies).
In voxel worlds, accessing the unique type or state of each block.
Providing an independent physical state for each fragment in complex mesh-based particle effects.
How to adjust
batch() is adjusted by using it as a 'switch'. Applying batch() to a material property (like colorNode) makes it read per-object data from the BatchedMesh, resulting in varied colors. Without it, all objects will use a single, non-batched value (like a fixed color), ignoring any per-object data.
Code Examples
1// Assuming perObjectColorNode gets color based on object ID
2material.colorNode = batch( perObjectColorNode ); // Enable batching for the color property