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.);