uniformOf
The live GPU value of a prop, for a hand-written builder: uniformOf(p('radius'), params).
uniformOf(ref: PropRef, params: {uniforms: Record<string, Expr>}): Expr
Import uniformOf from shaders/std.
Colors come back as vec4f in linear RGB with alpha, positions as vec2f, numbers as f32. Read a part with .member('rgb') or .member('x'). Throws when the name is not one of the definition's props.
Parameters
| Name | Type | Notes |
|---|---|---|
ref | PropRef | |
params | {uniforms: Record<string, Expr>} |
Example
paint: (params) => {
const color = uniformOf(p('color'), params)
const gain = mul(uniformOf(p('intensity'), params), 0.5)
return vec4(mul(color.member('rgb'), gain), color.member('a'))
}
Tip. A position prop's y is stored flipped: use
sub(1, center.member('y'))to compare it withuv.
See also
p— Reference one of the definition's props by name, wherever a word asks for a value.resolveScalar— AScalaror prop ref as a GPU value, for a hand-written builder.resolveArg— Any input value a word accepts (a prop ref, aScalar, a context token, a number) as a GPU value inside a filter's builder.paintFrame— The coordinate and frame size a hand-writtenpaint:builder should draw in.
Used by
Aurora, Blob, FlowingGradient, GlassTiles, Marble, MeshGradient, Prism, StudioBackground, Waveform