GLSL shader example
Radar Sweep with Fading Blips
Compute time since the sweep from modular angular difference. Fixed-target afterglow can therefore be evaluated without a history buffer.
Live example
Edit the code and the preview updates as you type.
What to observe
Radar Sweep with Fading Blips.
Mechanism
Compute time since the sweep from modular angular difference. Fixed-target afterglow can therefore be evaluated without a history buffer.
The controlling code
float ang=atan(p.y,p.x),r=length(p),sweep=u_time*(.3+u_parameter);float age=mod(sweep-ang+6.28318,6.28318);float grid=exp(-abs(fract(r*5.)-.5)*90.);c+=vec3(.05,.6,.25)*(exp(-age*2.)*.55+grid*.15)*step(r,.85);for(int i=0;i<6;i++){float fi=float(i);vec2 pt=(.25+.08*fi)*vec2(cos(fi*2.3),sin(fi*2.3));float a=atan(pt.y,pt.x);c+=vec3(.3,1.,.5)*exp(-length(p-pt)*160.)*exp(-mod(sweep-a+6.28318,6.28318)*1.4);}
Experiment
Change the two afterglow exponents *1.4 to *3.. The sweep wedge and target blips fade more quickly behind the beam, while target positions remain fixed.
Debugging and cost
Six target positions are computed in a loop; each fade comes from angular age rather than a feedback buffer. Change i<6 to i<3 to retain only three targets and see that the sweep grid itself is independent of target count.