goofi v3.0.0

Displace

push the input around by a map

The map's red and green channels are the two directions, with 0.5 as no push.

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

Slots

SlotDirectionType
inputinputTEXTURE
mapinputTEXTURE
outoutputTEXTURE

Parameters

displace

NameTypeDefaultRangeDoc
amountfloat0.1-1 … 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/Displace.wgsl.

node-bundles/graphics/Displace.wgsl
/* goofi
{ "doc": "push the input around by a map\nThe map's red and green channels are the two directions, with 0.5 as no push.",
  "tags": ["image", "transform"],
  "inputs": [{"name": "input", "kind": "TEXTURE"}, {"name": "map", "kind": "TEXTURE"}],
  "params": [
    {"group": "displace", "name": "amount", "kind": "float", "default": 0.1, "min": -1.0, "max": 1.0} ] }
*/
fn shade(uv: vec2f) -> vec4f {
    let m = textureSample(map, samp, uv).rg - vec2f(0.5);
    return textureSample(input, samp, uv + m * p.amount);
}

← All nodes