goofi v3.0.0

Lookup

recolour through a palette

One channel of the input reads across the palette, left to right.

Lookup wgsl
input
palette
out
Type name
graphics:Lookup
Plane
graphics
Tags
imagetransform
Language
wgsl
Tier
shader
Bundle
graphics
Source
node-bundles/graphics/Lookup.wgsl
Availability
available

Slots

SlotDirectionType
inputinputTEXTURE
paletteinputTEXTURE
outoutputTEXTURE

Parameters

lookup

NameTypeDefaultRangeDoc
channelstringluminanceluminance | red | green | blue | alpha

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/Lookup.wgsl.

node-bundles/graphics/Lookup.wgsl
/* goofi
{ "doc": "recolour through a palette\nOne channel of the input reads across the palette, left to right.",
  "tags": ["image", "transform"],
  "inputs": [{"name": "input", "kind": "TEXTURE"}, {"name": "palette", "kind": "TEXTURE"}],
  "params": [
    {"group": "lookup", "name": "channel", "kind": "str", "default": "luminance",
     "options": ["luminance", "red", "green", "blue", "alpha"]} ] }
*/
fn shade(uv: vec2f) -> vec4f {
    let c = textureSample(input, samp, uv);
    var t = dot(c.rgb, vec3f(0.299, 0.587, 0.114));
    switch p.channel {
        case 1u: { t = c.r; }
        case 2u: { t = c.g; }
        case 3u: { t = c.b; }
        case 4u: { t = c.a; }
        default: {}
    }
    return textureSample(palette, samp, vec2f(clamp(t, 0.0, 1.0), 0.5));
}

← All nodes