spherizeUV
Applies a spherical distortion to UV coordinates, procedurally creating visual warping effects like a fisheye lens, water drop, or gravitational field on a 2D plane.
Core Advantages
Enables real-time generation of procedural distortion effects directly in the shader with dynamically adjustable parameters, avoiding the need for pre-made textures and encapsulating complex math for easy integration.
Common Uses
Simulating a magnifying glass or fisheye lens
Simulating water drop or ripple effects
Creating sci-fi/magic effects (e.g., black holes, portals)
How to adjust
Mainly controlled by adjusting the `strength` and `center` inputs. A positive `strength` value creates an outward 'fisheye' bulge, with larger values causing stronger distortion; a negative value creates an inward 'pinch' effect. Changing the `center` (a vec2) moves the distortion's origin, enabling interactive lens effects when linked to dynamic data like mouse coordinates.
Code Examples
1// strength: distortion intensity, positive for bulge, negative for pinch
2const strength = uniform( 1.5 );
3
4// Apply spherizeUV to default uv(), center defaults to vec2(0.5)
5const distortedUV = spherizeUV( uv(), strength );