.hss: shader graphs
An .hss file is a shader written as a graph of nodes.
It covers looks that a standard material can't, such as an unlit glow, a rim effect, or moving vertices.
The format may change between releases.
Why a graph
Objects in UNAVI come from other people. A bad shader can hang the GPU, so the app never runs shader code it was handed.
A graph is a list of nodes, where each node can only use nodes listed before it.
That rules out loops, and the app compiles the graph into a shader itself.
wired:shading caps a graph at 128 nodes, 16 public inputs, and 4 texture samples.
Structure
A graph has up to two networks.
- Surface sets the color of each pixel.
It is either
Lit, shaded like a normal material, orUnlit, drawn as-is. - Displacement is optional, and moves vertices.
A graph also has up to 16 public inputs. Each prim using the graph can override them, so one graph can look different on every prim.
Example
unavi-physgun outlines the object it has grabbed with this graph.
(
public_inputs: [
Color((1.0, 0.62, 0.16, 1.0)), // 0: tint, overridden per player
Float(1.0), // 1: unused by the hull; see below
Float(2.5), // 2: intensity
],
surface: (
nodes: [
// lines 18-23 omitted
Fresnel(power: Input(1)),
Saturate(x: Node(0)),
Mul(a: Node(1), b: Input(2)),
Mul(a: Input(0), b: Node(2)),
// lines 28-31 omitted
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,
// lines 40-42 omitted
cast_shadows: false,
),
)
beam.hss in the same crate also uses a displacement network, to bend its tractor beam.
Use in .hsda
A prim's shader attribute names the .hss file, and can override public inputs by index.
shader: (
path: "./glow.hss",
overrides: {},
),