fix: stagger particle lifecycle respawn
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled

This commit is contained in:
OpenAI Codex
2026-09-05 10:36:07 +08:00
parent c7acefcb21
commit 7929052c58
5 changed files with 46 additions and 12 deletions

View File

@@ -100,12 +100,16 @@ void main() {
// Formal particles use GPU-resident lifecycle state. Each slot keeps
// its age in B; A=0 marks this frame as a respawn so Trail does not
// connect the retired position to the new randomized one.
bool respawn = u_mask.w > 0.5;
float age = respawn ? 0.0 : previous.b + u_pass.y;
bool initialSeed = u_mask.w > 0.5;
float lifecycleHash = particleHash(v_uv + vec2(17.31, 83.17));
float maxAge = u_marker.z * mix(0.75, 1.25, lifecycleHash);
float initialAgeHash = particleHash(v_uv + vec2(71.19, 29.47));
bool respawn = initialSeed;
float age = initialSeed ? initialAgeHash * maxAge : previous.b + u_pass.y;
vec2 position = previous.rg;
vec2 velocity;
bool valid = !respawn && fieldVelocityAt(position, velocity);
if (!valid || age >= u_marker.z) {
if (!valid || age >= maxAge) {
respawn = true;
}
@@ -139,7 +143,9 @@ void main() {
// frame; alpha still prevents an invalid visible segment.
position = respawnSeed(v_uv, previous.rg, 3.0);
}
age = 0.0;
if (!initialSeed) {
age = 0.0;
}
}
fragColor = vec4(position, age, respawn ? 0.0 : 1.0);
return;