GLSL shader example
Halftone Dot Shader
Luminance controls dot area, so radius uses a square-root mapping. Darker regions produce larger dots in equal-sized cells.
Live example
Edit the code and the preview updates as you type.
What to observe
Halftone Dot Shader.
Mechanism
Luminance controls dot area, so radius uses a square-root mapping. Darker regions produce larger dots in equal-sized cells.
The controlling code
float size=5.+u_parameter*20.;vec2 id=floor(gl_FragCoord.xy/size),q=fract(gl_FragCoord.xy/size)-.5;float l=dot(texture2D(u_texture,(id+.5)*size/u_resolution).rgb,vec3(.299,.587,.114));float radius=sqrt(1.-l)*.5;float ink=1.-smoothstep(radius-.03,radius+.03,length(q));c=mix(vec3(.96,.91,.8),vec3(.07,.04,.12),ink);
Experiment
Set size=5.+u_parameter*20. to size=20.. The dot cells stop resizing, making it easier to see how darker fixture samples produce larger circles within equal-size cells.
Debugging and cost
One texture read at (id+.5)*size/u_resolution sets each cell's brightness. Replace sqrt(1.-l)*.5 with (1.-l)*.5 to shrink midtone dots and see why radius needs a square root when dot area represents darkness.