goofi v3.0.0

Shape

one shape on transparent black

Size is the width across as a fraction of the frame, and soft is how far the edge fades.

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

Slots

SlotDirectionType
outoutputTEXTURE

Parameters

shape

NameTypeDefaultRangeDoc
kindstringcirclecircle | square | ring
sizefloat0.50 … 1
softfloat0.010 … 0.5
rfloat10 … 1
gfloat10 … 1
bfloat10 … 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/Shape.wgsl.

node-bundles/graphics/Shape.wgsl
/* goofi
{ "doc": "one shape on transparent black\nSize is the width across as a fraction of the frame, and soft is how far the edge fades.",
  "tags": ["image", "generator"],
  "params": [
    {"group": "shape", "name": "kind", "kind": "str", "default": "circle", "options": ["circle", "square", "ring"]},
    {"group": "shape", "name": "size", "kind": "float", "default": 0.5, "min": 0.0, "max": 1.0},
    {"group": "shape", "name": "soft", "kind": "float", "default": 0.01, "min": 0.0, "max": 0.5},
    {"group": "shape", "name": "r", "kind": "float", "default": 1.0, "min": 0.0, "max": 1.0},
    {"group": "shape", "name": "g", "kind": "float", "default": 1.0, "min": 0.0, "max": 1.0},
    {"group": "shape", "name": "b", "kind": "float", "default": 1.0, "min": 0.0, "max": 1.0} ] }
*/
fn shade(uv: vec2f) -> vec4f {
    let q = uv - vec2f(0.5);
    let radius = p.size * 0.5;
    var d = length(q) - radius;
    switch p.kind {
        case 1u: {
            let box = abs(q) - vec2f(radius);
            d = length(max(box, vec2f(0.0))) + min(max(box.x, box.y), 0.0);
        }
        case 2u: {
            d = abs(length(q) - radius) - radius * 0.15;
        }
        default: {}
    }
    let soft = max(p.soft, 1e-5);
    let cover = 1.0 - smoothstep(-soft, soft, d);
    return vec4f(vec3f(p.r, p.g, p.b) * cover, cover);
}

← All nodes