GLSL shader example
Feedback Trails with Ping-Pong Buffers
Each frame reads the previous trail, fades it, adds a new point, then swaps read/write targets. Pause freezes state; Reset clears history.
Live example
Edit the code and the preview updates as you type.
What to observe
Feedback Trails with Ping-Pong Buffers.
Mechanism
Each frame reads the previous trail, fades it, adds a new point, then swaps read/write targets. Pause freezes state; Reset clears history.
The controlling code
c=texture2D(u_trail,uv).rgb;
The u_trail tab contains both history decay and the new light point; Fragment only displays its accumulated RGB. Replace the source color vec3(.2,.65,1.) with vec3(1.,.2,.1) in u_trail to build a warm-colored trail from fresh state.
Experiment
Set the Effect parameter to 0 and then 1, changing retention .92+.06*u_parameter from 0.92 to 0.98. The moving light point leaves a longer-lived trail at the higher value.
Debugging and cost
u_trail samples the previous target once, adds the current spot, then swaps targets; each frame is one decay step. Change the spot falloff 180. to 90. to widen the injected point and its trail without adding any history reads.