goofi v3.0.0

Ramp

a gradient between two colours

The angle turns the gradient: 0 runs left to right, 90 top to bottom.

Ramp wgsl
out
Type name
graphics:Ramp
Plane
graphics
Tags
imagegenerator
Language
wgsl
Tier
shader
Bundle
graphics
Source
node-bundles/graphics/Ramp.wgsl
Availability
available

Slots

SlotDirectionType
outoutputTEXTURE

Parameters

ramp

NameTypeDefaultRangeDoc
anglefloat00 … 360
r0float00 … 1
g0float00 … 1
b0float00 … 1
r1float10 … 1
g1float10 … 1
b1float10 … 1

common

NameTypeDefaultRangeDoc
widthint00 … 8192Texture size in pixels; 0 follows the first wired texture input. A node that makes its own frames follows the patch's default instead.
heightint00 … 8192Texture 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.

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);
}

← All nodes