Multiplying vertex positions by 0 collapses geometry to a single point, which the GPU silently discards — an efficient way to hide inactive instances
A GPU silently discards any triangle that degenerates to a point or line (all vertices at the same position). This property enables a shader trick: to conditionally hide an instance, multiply all its vertex offsets by a boolean state value (0 or 1). When state=1, the geometry renders normally; when state=0, all vertices collapse to the same point and the triangle is discarded with no fragment shader invocations. This avoids branching or separate draw calls for visible vs. hidden instances. The state value must be cast to f32 for WGSL type safety.
Examples
let state = f32(cellState[instance]); // 0 or 1
// state=0 → pos*0=0 → all vertices collapse to same point → GPU discards
let gridPos = (pos * state + 1) / grid - 1 + cellOffset;
Assessment
What visual result does a triangle with all vertices at (0.5, 0.5, 0, 1) produce, and why? Explain why multiplying by state=0 is more efficient than drawing inactive cells off-screen.