Ramp
a gradient between two colours
The angle turns the gradient: 0 runs left to right, 90 top to bottom.
out
- Type name
graphics:Ramp- Plane
graphics- Tags
imagegenerator- Language
wgsl- Tier
shader- Bundle
graphics- Source
node-bundles/graphics/Ramp.wgsl- Availability
- available
Slots
| Slot | Direction | Type | |
|---|---|---|---|
out | output | TEXTURE |
Parameters
ramp
| Name | Type | Default | Range | Doc |
|---|---|---|---|---|
angle | float | 0 | 0 … 360 | |
r0 | float | 0 | 0 … 1 | |
g0 | float | 0 | 0 … 1 | |
b0 | float | 0 | 0 … 1 | |
r1 | float | 1 | 0 … 1 | |
g1 | float | 1 | 0 … 1 | |
b1 | float | 1 | 0 … 1 |
common
| Name | Type | Default | Range | Doc |
|---|---|---|---|---|
width | int | 0 | 0 … 8192 | Texture size in pixels; 0 follows the first wired texture input. A node that makes its own frames follows the patch's default instead. |
height | int | 0 | 0 … 8192 | Texture size in pixels; 0 follows the first wired texture input. A node that makes its own frames follows the patch's default instead. |
Source
The current source of this node, as it stands in the goofi repository at node-bundles/graphics/Ramp.wgsl.
/* goofi
{ "doc": "a gradient between two colours\nThe angle turns the gradient: 0 runs left to right, 90 top to bottom.",
"tags": ["image", "generator"],
"params": [
{"group": "ramp", "name": "angle", "kind": "float", "default": 0.0, "min": 0.0, "max": 360.0},
{"group": "ramp", "name": "r0", "kind": "float", "default": 0.0, "min": 0.0, "max": 1.0},
{"group": "ramp", "name": "g0", "kind": "float", "default": 0.0, "min": 0.0, "max": 1.0},
{"group": "ramp", "name": "b0", "kind": "float", "default": 0.0, "min": 0.0, "max": 1.0},
{"group": "ramp", "name": "r1", "kind": "float", "default": 1.0, "min": 0.0, "max": 1.0},
{"group": "ramp", "name": "g1", "kind": "float", "default": 1.0, "min": 0.0, "max": 1.0},
{"group": "ramp", "name": "b1", "kind": "float", "default": 1.0, "min": 0.0, "max": 1.0} ] }
*/
fn shade(uv: vec2f) -> vec4f {
let a = radians(p.angle);
let t = clamp(dot(uv - vec2f(0.5), vec2f(cos(a), sin(a))) + 0.5, 0.0, 1.0);
return vec4f(mix(vec3f(p.r0, p.g0, p.b0), vec3f(p.r1, p.g1, p.b1), t), 1.0);
}