GLSL shader example

Heat Haze Distortion

Multiply horizontal distortion by a localized heat mask so the image away from the horizon stays stable.

Live example

Edit the code and the preview updates as you type.

What to observe

Heat Haze Distortion.

Mechanism

Multiply horizontal distortion by a localized heat mask so the image away from the horizon stays stable.

The controlling code

float band=exp(-pow((uv.y-.45)*7.,2.));vec2 q=uv+vec2(noise(vec2(uv.y*90.,u_time*2.))-.5,0.)*band*u_parameter*.05;c=texture2D(u_texture,q).rgb;

Experiment

Change the band center in uv.y-.45 to uv.y-.7. The horizontally distorted zone moves upward while the image away from that zone stays close to its original coordinates.

Debugging and cost

The haze uses one noise evaluation and one background sample. Change the band width factor 7. to 14. in exp(-pow((uv.y-.45)*7.,2.)) to narrow the affected zone without increasing either cost.

Built-in functions used

Learn it step by step