Sprites.Media.Shader.Parameter
The control for one shader parameter: its name, its type and the value editor the type calls for. A parameter is { name, type, value }, and value is a tagged union of one of optionalFloat, optionalVec2, optionalVec3 or optionalVec4. The card shows a name field, a type dropdown, a value editor matched to the type and a Remove button. An edit rebuilds the parameter and lays it back into the parameter list, since a list element is read on its own and written through its list. The list of parameter cards and its Add button live in Sprites.Media.Shader.Params.
- Sprites.Media.Shader.Parameter.Control
- Sprites.Media.Shader.Parameter.Name
- Sprites.Media.Shader.Parameter.Type
- Sprites.Media.Shader.Parameter.Value
- Sprites.Media.Shader.Parameter.Float
- Sprites.Media.Shader.Parameter.Vec2
- Sprites.Media.Shader.Parameter.Vec3
- Sprites.Media.Shader.Parameter.Vec4
- Sprites.Media.Shader.Parameter.Colour
Sprites.Media.Shader.Parameter.Control Void
Sprites.Media.Shader.Parameter.Control(param, index, params)
One parameter card: a top row of the name field, the type dropdown and a Remove button, over the value editor. param is the parameter, index its position and params the two-way list. Remove drops the parameter from the list. Edits rebuild the parameter and lay it back into params at index.
| Input | Type | Description |
|---|---|---|
param | value | The parameter this card edits, read from the list. |
index | number | The parameter's position in the list. |
params | Sprites.Reactive.Value | The two-way parameter list an edit writes back through. |
Returns nothing.
const value = Sprites.Media.Shader.FloatValue(0.5);
const param = Sprites.Media.Shader.NewParameter('uAmount', 'float', value);
const params = Sprites.Reactive.Value([param]);
const first = Sprites.Array.At(params, 0);
Sprites.Media.Shader.Parameter.Control(first, 0, params);
Sprites.Media.Shader.Parameter.Name Void
Sprites.Media.Shader.Parameter.Name(param, index, params)
The name field: a text input two-way bound to the parameter's name, the uniform name the GLSL declares. Writing lays the renamed parameter back into the list at index.
| Input | Type | Description |
|---|---|---|
param | value | The parameter whose name this field edits. |
index | number | The parameter's position in the list. |
params | Sprites.Reactive.Value | The two-way parameter list the rename writes back through. |
Returns nothing.
Sprites.Media.Shader.Parameter.Name(param, 0, params);
Sprites.Media.Shader.Parameter.Type Void
Sprites.Media.Shader.Parameter.Type(param, index, params)
The type dropdown: float, vec2, vec3, vec4 or colour. Changing the type also lays a fresh value of the new shape in place through DefaultValue, so the value editor always matches the type.
| Input | Type | Description |
|---|---|---|
param | value | The parameter whose type this dropdown edits. |
index | number | The parameter's position in the list. |
params | Sprites.Reactive.Value | The two-way parameter list the retype writes back through. |
Returns nothing.
Sprites.Media.Shader.Parameter.Type(param, 0, params);
Sprites.Media.Shader.Parameter.Value Void
Sprites.Media.Shader.Parameter.Value(param, index, params)
The value editor matched to the parameter's type. Exactly one type matches, so exactly one of the five branches renders; each is its own If over the type, so the editor follows a type change with no imperative teardown.
| Input | Type | Description |
|---|---|---|
param | value | The parameter whose value this editor edits. |
index | number | The parameter's position in the list. |
params | Sprites.Reactive.Value | The two-way parameter list an edit writes back through. |
Returns nothing.
Sprites.Media.Shader.Parameter.Bindingparam, 0, params);
Sprites.Media.Shader.Parameter.Float Void
Sprites.Media.Shader.Parameter.Float(param, index, params)
The value editor for a float parameter: one number field two-way bound to the float. Writing wraps the number as a float value and lays it back into the list.
| Input | Type | Description |
|---|---|---|
param | value | The float parameter this field edits. |
index | number | The parameter's position in the list. |
params | Sprites.Reactive.Value | The two-way parameter list an edit writes back through. |
Returns nothing.
Sprites.Media.Shader.Parameter.Float(param, 0, params);
Sprites.Media.Shader.Parameter.Vec2 Void
Sprites.Media.Shader.Parameter.Vec2(param, index, params)
The value editor for a vec2 parameter: two number fields for x and y. Each field rebuilds the whole vector from its new value and the other, held current by read, so a change to one leaves the other be.
| Input | Type | Description |
|---|---|---|
param | value | The vec2 parameter this editor edits. |
index | number | The parameter's position in the list. |
params | Sprites.Reactive.Value | The two-way parameter list an edit writes back through. |
Returns nothing.
Sprites.Media.Shader.Parameter.Vec2(param, 0, params);
Sprites.Media.Shader.Parameter.Vec3 Void
Sprites.Media.Shader.Parameter.Vec3(param, index, params)
The value editor for a vec3 parameter: three number fields for x, y and z, each rebuilding the whole vector from its new value and the two others held current by read.
| Input | Type | Description |
|---|---|---|
param | value | The vec3 parameter this editor edits. |
index | number | The parameter's position in the list. |
params | Sprites.Reactive.Value | The two-way parameter list an edit writes back through. |
Returns nothing.
Sprites.Media.Shader.Parameter.Vec3(param, 0, params);
Sprites.Media.Shader.Parameter.Vec4 Void
Sprites.Media.Shader.Parameter.Vec4(param, index, params)
The value editor for a vec4 parameter: four number fields for x, y, z and w, each rebuilding the whole vector from its new value and the three others held current by read.
| Input | Type | Description |
|---|---|---|
param | value | The vec4 parameter this editor edits. |
index | number | The parameter's position in the list. |
params | Sprites.Reactive.Value | The two-way parameter list an edit writes back through. |
Returns nothing.
Sprites.Media.Shader.Parameter.Vec4(param, 0, params);
Sprites.Media.Shader.Parameter.Colour Void
Sprites.Media.Shader.Parameter.Colour(param, index, params)
The value editor for a colour parameter: a colour picker over the vec4 stored as red, green, blue and alpha, each 0 to 1. The picker binds a packed 0xRRGGBBAA colour, so the value is packed from the four channels for the picker and unpacked back to four 0 to 1 floats on a pick.
| Input | Type | Description |
|---|---|---|
param | value | The colour parameter this picker edits. |
index | number | The parameter's position in the list. |
params | Sprites.Reactive.Value | The two-way parameter list an edit writes back through. |
Returns nothing.
Sprites.Media.Shader.Parameter.Colour(param, 0, params);