object-fit / background-size, extended with rotation, offset, and world-size controls.
Sizing params are included in every shader’s Params type (via ShaderSizingParams) and are processed into uniforms (via ShaderSizingUniforms) before being passed to the GPU.
ShaderSizingParams
Controls how the shader content scales to fill the canvas. Works analogously to CSS
object-fit.'none'— No scaling. The shader is rendered at its intrinsic/world size. Tiles if the canvas is larger. Used for repeating patterns.'contain'— Scales the content to fit within the canvas while preserving its aspect ratio. Letterboxed if the canvas has a different aspect ratio.'cover'— Scales the content to fill the entire canvas while preserving its aspect ratio. Content may be cropped.
Zoom level applied on top of the
fit scaling. 1 is no additional zoom. Values above 1 zoom in; values below 1 zoom out.Rotation of the shader content in degrees (
0 to 360).Horizontal anchor point for positioning.
0 = left edge, 0.5 = center, 1 = right edge.Vertical anchor point for positioning.
0 = top edge, 0.5 = center, 1 = bottom edge.Horizontal offset of the shader content relative to its origin. Range
-1 to 1, where 1 shifts content by the full canvas width.Vertical offset of the shader content relative to its origin. Range
-1 to 1, where 1 shifts content by the full canvas height.The virtual width of the shader graphic before it is scaled to fit the canvas. When set to
0 the shader infers the world size from the canvas aspect ratio. Use this together with worldHeight to lock the graphic to a specific intrinsic aspect ratio regardless of the canvas size.The virtual height of the shader graphic before it is scaled to fit the canvas. See
worldWidth.ShaderFit
fit param. Mirrors CSS object-fit semantics.
ShaderFitOptions
fit to the GPU as a float uniform (u_fit). You won’t need this when using the React components — it’s used by each component when constructing ShaderSizingUniforms.
Default sizing presets
Two default sizing configurations are exported, covering the two main categories of shader.defaultObjectSizing
Used by most animated shaders — those that render a single graphic that should fit within the canvas.defaultObjectSizing: MeshGradient, SmokeRing, NeuroNoise, DotOrbit, SimplexNoise, Metaballs, Voronoi, Warp, GodRays, Spiral, Swirl, Dithering, GrainGradient, PulsingBorder, ColorPanels, StaticMeshGradient, StaticRadialGradient, and others.
defaultPatternSizing
Used by tiling pattern shaders — those that repeat across the canvas surface without a defined boundary.defaultObjectSizing is fit: 'none'. Shaders using defaultPatternSizing: DotGrid, Waves, PerlinNoise, PaperTexture, and other tileable pattern shaders.