From 8bf718bbbed3199fc5ac38ad637a3959f1e5bca8 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Wed, 11 Mar 2026 20:51:11 -0400 Subject: [PATCH] Gate ant initialization by ANTS_START_COUNT budget Ants whose index exceeds ANTS_START_COUNT output zero state and return immediately on init, keeping them dormant without consuming GPU work. This lets the ant texture capacity exceed the active ant count without spawning unwanted ants. --- src/shaders/antsCompute.frag | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/shaders/antsCompute.frag b/src/shaders/antsCompute.frag index 1567fd6..e52b3c0 100644 --- a/src/shaders/antsCompute.frag +++ b/src/shaders/antsCompute.frag @@ -91,7 +91,19 @@ void main() { bool movementProcessed = false; + // calculate this ant's index from its UV position in the texture + ivec2 texSize = textureSize(tLastState, 0); + int antIndex = int(vUv.y * float(texSize.y)) * texSize.x + int(vUv.x * float(texSize.x)); + if (pos == vec2(0)) { // init new ant + // only activate ants within the start count + if (antIndex >= ANTS_START_COUNT) { + // dormant ant — output zeros and skip everything + FragColor = vec4(0); + FragColorExt = vec4(0); + return; + } + #if VIEW_MODE_SIDE // spawn on sand surface: random X, scan down from top to find first non-air cell float spawnX = rand(vUv * 10000.);