instanceCulling
instanceCulling(culler : ComputeInstanceCulling) : InstanceCullingNodeTSL function for creating an instance culling node that applies GPU-culled instance transforms to vertex positions and normals.
This is the main entry point for enabling GPU culling in your material. The node automatically handles the indirection from draw index to original instance ID.
Example: Basic GPU frustum culling
Parameters
The GPU instance culler.
Returns
InstanceCullingNode — Node that applies culled instance transforms.Example
import { ComputeInstanceCulling } from '@three-blocks/core';
import * as THREE from 'three/webgpu';
// Create instanced mesh with 100,000 instances
const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshStandardNodeMaterial();
const mesh = new THREE.InstancedMesh(geometry, material, 100000);
// Scatter instances randomly
const matrix = new THREE.Matrix4();
for (let i = 0; i < 100000; i++) {
matrix.makeTranslation(
(Math.random() - 0.5) * 1000,
(Math.random() - 0.5) * 100,
(Math.random() - 0.5) * 1000
);
mesh.setMatrixAt(i, matrix);
}
// Create GPU culler
const culler = new ComputeInstanceCulling(mesh, renderer);
// Culling patch is applied automatically to material.setupPosition()
// so you can keep using positionNode normally.
scene.add(mesh);