GLSL shader example
Hexagonal Bokeh Blur
Accumulate and normalize samples inside a hexagonal aperture; bright dots on black expand into the aperture shape.
Live example
Edit the code and the preview updates as you type.
What to observe
Hexagonal Bokeh Blur.
Mechanism
Accumulate and normalize samples inside a hexagonal aperture; bright dots on black expand into the aperture shape.
The controlling code
vec3 sum=vec3(0.);float w=0.;for(int y=-4;y<=4;y++)for(int x=-4;x<=4;x++){vec2 o=vec2(float(x),float(y))/4.;if(max(abs(o.y),abs(o.x)*.866+abs(o.y)*.5)<1.){sum+=texture2D(u_texture,uv+o*(.01+.07*u_parameter)).rgb;w++;}}c=sum/w;
Experiment
Set the aperture radius .01+.07*u_parameter to .06. Bright fixture dots expand into fixed-size hexagonal patches, so moving the slider no longer changes their size.
Debugging and cost
The nested -4 to 4 loops test 81 candidate offsets but sample only those inside the aperture. Replace the final sum/w*4. with sum/w to remove the display gain and see how averaging spreads each dot's energy over its larger footprint.