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.
This commit is contained in:
parent
f41e464b4a
commit
8bf718bbbe
1 changed files with 12 additions and 0 deletions
|
|
@ -91,7 +91,19 @@ void main() {
|
||||||
|
|
||||||
bool movementProcessed = false;
|
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
|
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
|
#if VIEW_MODE_SIDE
|
||||||
// spawn on sand surface: random X, scan down from top to find first non-air cell
|
// spawn on sand surface: random X, scan down from top to find first non-air cell
|
||||||
float spawnX = rand(vUv * 10000.);
|
float spawnX = rand(vUv * 10000.);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue