UNAVI Docs unavi.xyz
Build · Formats

.hss: shader graphs

An .hss file defines a custom shader as a graph of typed nodes. Shader graphs handle visual effects that a standard PBR (physically based rendering) material cannot express, such as unlit glows, Fresnel rims, or vertex displacement.

The format is not version-locked and may change between releases.

Why a graph

Because spaces load objects authored by untrusted peers, UNAVI never executes arbitrary shader code received over the network, which could hang or crash the GPU.

Instead, an .hss file is a flat list of nodes where each node may only reference inputs or nodes listed earlier in the array. That structure forms a directed acyclic graph with no loops, allowing the host to validate and compile the graph into native shader code safely. wired:shading limits each graph to 128 nodes, 16 public inputs, and 4 texture samples.

Structure

A shader graph can include up to two node networks:

A graph can also expose up to 16 public inputs. Individual prims using the shader can override those inputs, letting one graph drive multiple visual variations.

Example

unavi-physgun highlights grabbed objects using an inverted-hull outline shader graph:

// Inverted-hull highlight for grabbed props (`cull: Front` draws only the
// extruded silhouette behind the prop).
(
    public_inputs: [
        Color((1.0, 0.62, 0.16, 1.0)), // 0: tint (overridden per player)
        Float(1.0),                    // 1: fresnel power
        Float(2.5),                    // 2: intensity
    ],
    surface: (
        nodes: [
            Fresnel(power: Input(1)),
            Saturate(x: Node(0)),
            Mul(a: Node(1), b: Input(2)),
            Mul(a: Input(0), b: Node(2)),

            // Zero alpha for premultiplied additive blending.
            Extract(v: Node(3), channel: 0),
            Extract(v: Node(3), channel: 1),
            Extract(v: Node(3), channel: 2),
            Combine4(x: Node(4), y: Node(5), z: Node(6), w: Const(Float(0.0))),
        ],
        output: Unlit((color: Node(7))),
        blend: Add,
        cull: Front,
        cast_shadows: false,
    ),
)

For an example that also uses a displacement network, see beam.hss in the same crate, which bends the physgun's tractor beam.

Use in .hsda

Attach a shader graph to a prim with the shader attribute, optionally overriding public inputs by index:

shader: (
    path: "./glow.hss",
    overrides: {},
),