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.
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
| Slot | Direction | Type | |
|---|---|---|---|
input | input | TEXTURE | |
map | input | TEXTURE | |
out | output | TEXTURE |
Parameters
displace
| Name | Type | Default | Range | Doc |
|---|---|---|---|---|
amount | float | 0.1 | -1 … 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/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);
}