GLSL shader example

CRT Scanlines and Rolling Bright Band

Scanline density uses pixel coordinates while the rolling band uses normalized coordinates, keeping spatial frequency separate from speed.

Live example

Edit the code and the preview updates as you type.

What to observe

CRT Scanlines and Rolling Bright Band.

Mechanism

Scanline density uses pixel coordinates while the rolling band uses normalized coordinates, keeping spatial frequency separate from speed.

The controlling code

vec3 image=texture2D(u_texture,uv).rgb;float scan=.75+.25*sin(gl_FragCoord.y*(1.+u_parameter*2.));float roll=exp(-pow((uv.y-fract(u_time*.12))*12.,2.));c=image*scan+roll*.15;

Experiment

Change fract(u_time*.12) to fract(u_time*.24). The broad bright band rolls twice as fast, while the fine scanline spacing is unchanged because it uses gl_FragCoord.y.

Debugging and cost

Only one texture lookup supplies the underlying image; the two brightness patterns are computed afterward. Set the .25 amplitude in scan=.75+.25*sin(...) to 0. to remove fine-line modulation while leaving the moving bright band visible.

Understand the technique

Built-in functions used

Learn it step by step