#[non_exhaustive]pub enum Node {
Show 54 variants
Const {
ty: Type,
values: Vec<f64>,
},
ConstArray {
element_ty: Type,
values: Vec<f64>,
},
ArrayVar {
element_ty: Type,
values: Vec<f64>,
},
Uniform(Rc<UniformNode>),
BufferElement {
buffer: Rc<BufferNode>,
index: NodeRef,
},
Attribute {
name: &'static str,
ty: Type,
},
InstancedAttribute {
buffer: Rc<InstanceBuffer>,
offset: usize,
ty: Type,
},
Builtin(Builtin),
Compute {
flow: Rc<ComputeFlow>,
output: NodeRef,
},
Var(Rc<VarDef>),
VarIntent(Rc<VarDef>),
Let(Rc<VarDef>),
Varying(Rc<VaryingDef>),
Property {
name: &'static str,
ty: Type,
},
Param {
name: &'static str,
ty: Type,
},
Assign {
target: NodeRef,
value: NodeRef,
},
Op {
op: &'static str,
a: NodeRef,
b: NodeRef,
ty: Type,
},
Math {
name: &'static str,
args: Vec<NodeRef>,
ty: Type,
},
Swizzle {
node: NodeRef,
components: &'static str,
ty: Type,
},
Cast {
node: NodeRef,
ty: Type,
},
Neg {
node: NodeRef,
ty: Type,
},
Join {
args: Vec<NodeRef>,
ty: Type,
},
Element {
node: NodeRef,
index: NodeRef,
ty: Type,
},
Texture {
texture: Rc<TextureSource>,
uv: NodeRef,
mode: SampleMode,
ty: Type,
},
TextureSize {
texture: Rc<TextureSource>,
level: NodeRef,
},
VaryingProperty {
name: &'static str,
ty: Type,
flat: bool,
},
Call {
def: Rc<FnDef>,
args: Vec<NodeRef>,
},
Code(Rc<CodeDef>),
CodeCall {
def: Rc<CodeDef>,
args: Vec<NodeRef>,
},
Block {
statements: Vec<NodeRef>,
result: NodeRef,
},
Loop {
start: Option<NodeRef>,
count: NodeRef,
index: NodeRef,
condition: &'static str,
update: Option<NodeRef>,
body: Vec<NodeRef>,
},
Break,
Continue,
TextureStore {
texture: Rc<TextureSource>,
coord: NodeRef,
value: NodeRef,
},
If {
cond: NodeRef,
body: Vec<NodeRef>,
else_body: Vec<NodeRef>,
},
IfVar {
pre: Vec<NodeRef>,
result: NodeRef,
cond: NodeRef,
body: Vec<NodeRef>,
},
Discard,
Return {
value: NodeRef,
},
Not {
node: NodeRef,
},
BitNot {
node: NodeRef,
ty: Type,
},
Select {
cond: NodeRef,
a: NodeRef,
b: NodeRef,
ty: Type,
},
StructMember {
buffer: Rc<BufferNode>,
member: usize,
},
Atomic {
method: &'static str,
pointer: NodeRef,
value: Option<NodeRef>,
},
Workgroup(Rc<WorkgroupArrayDef>),
Barrier {
scope: &'static str,
},
Subgroup {
method: &'static str,
a: Option<NodeRef>,
b: Option<NodeRef>,
},
Custom(Rc<dyn CustomNode>),
Context {
node: NodeRef,
value: Rc<ContextValue>,
},
Isolate {
node: NodeRef,
},
Expression {
snippet: Rc<str>,
ty: Type,
},
Debug {
node: NodeRef,
callback: Option<DebugCallback>,
},
StructNew {
layout: Rc<StructLayout>,
values: Vec<NodeRef>,
},
OutputStruct {
members: Vec<NodeRef>,
},
StructGet {
value: NodeRef,
layout: Rc<StructLayout>,
member: usize,
},
}Expand description
The node set. Closed on purpose: an exhaustive match in the builder is
what tells the next rung it has added something the generator cannot emit.
Node::Custom is the one opening, and it can only compose the others.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Const
A literal. values holds one entry per component.
ConstArray
array< f32, N >( … ) — QuadMesh’s vertexNode.
Fields
ArrayVar
The same literal array held in a var<private> nodeVarN : array< T, N >
rather than written out at each use — three.js’ TempNode promotion of
an array() that the flow reads more than once, which BloomNode’s
composite does five times (dump/m11).
Fields
Uniform(Rc<UniformNode>)
UniformNode.
BufferElement
BufferNode element access: NodeBuffer_N.value[ index ].
Attribute
A geometry attribute.
InstancedAttribute
instancedBufferAttribute( buffer, type, stride, offset ): a vertex
attribute whose buffer steps once per instance. offset is in floats
from the start of the instance; the stride is the buffer’s item_size,
which is all three.js’ own call sites use.
Fields
buffer: Rc<InstanceBuffer>The per-instance buffer.
Builtin(Builtin)
A WGSL builtin input.
Compute
ComputeNode used as a value — Fn( () => { …; return x } )().compute( count ) set as a material’s positionNode. Outside the compute stage
it generates output (properties.outputComputeNode); the kernel
itself runs from updateBefore() (NodeUpdateType.FRAME), which the
builder records in
NodeProgram::update_before for the
renderer to dispatch. See docs/nodes.md §44 and §57.
Fields
flow: Rc<ComputeFlow>The compute kernel’s statements and dispatch size.
Var(Rc<VarDef>)
VarNode — a cached var<private>.
VarIntent(Rc<VarDef>)
VarNode with intent set, as it ends up when something assigns to
it — see to_var_intent. A WGSL
function-scope var, declared with its value where it is first
built (var nodeVar0 : vec3<f32> = …;) instead of hoisted into the
// vars block.
Let(Rc<VarDef>)
VarNode with readOnly set — node.toConst(). A WGSL let, so it is
declared where it is assigned and, unlike a var<private>, cannot be
written again.
Varying(Rc<VaryingDef>)
VaryingNode.
Property
A var<private> with a fixed name that the setup code assigns
explicitly — PropertyNode (DiffuseColor, Output, …).
Param
A parameter of an emitted fn — a name that is already in scope.
Assign
A statement: target = value.
Fields
Op
OperatorNode.
Fields
Math
MathNode — a WGSL builtin call.
Fields
Swizzle
SplitNode.
Fields
Cast
ConvertNode / a single-argument constructor: vec4<f32>( x ).
Neg
OperatorNode with one operand: ( - x ).
Join
JoinNode — vec4<f32>( a, b, c, d ).
Element
ArrayElementNode: m[ 3u ], array< f32, 3 >( … )[ vertexIndex ].
Fields
Texture
TextureNode — a texture sample.
Fields
texture: Rc<TextureSource>The texture being sampled.
mode: SampleModeHow the texture is read.
TextureSize
TextureSizeNode — textureDimensions( t, level ), a vec2<u32>.
VaryingProperty
varyingProperty( type, name ) — a named varying assigned to by
statement rather than built from a value. Unlike Node::Varying it
is declared as soon as either stage mentions it, so a varying the
fragment stage never reads still appears in VaryingsStruct, exactly
as vBatchIndirectId does in Three’s dump.
Fields
Call
A call into a Node::Code / inlined Fn().
Code(Rc<CodeDef>)
CodeNode itself — a wgslFn() as a node rather than as a call, which
is the shape another wgslFn’s includes list needs it in. Building
one emits its declaration into // codes and nothing else; it has no
value, so nothing but an includes list may hold one.
CodeCall
FunctionCallNode over a wgslFn() — a call into hand-written WGSL
the node system copies through verbatim. See crate::nodes::code.
Fields
Block
A sequence of statements followed by the value they produce — the shape
an inlined Fn() body with toVar() statements has. Three has no node
for it: its ShaderNode call simply flows its body’s statements into the
current stage and returns the last expression, which is what this does.
Fields
Loop
Loop( count, ( { i } ) => { … } ) — for ( var i : i32 = 0; i < n; i ++ ).
Fields
start: Option<NodeRef>Loop( { start, end }, … )‘s start. None is three.js’
Loop( count, … ) shorthand, whose start is the literal 0; a
node start is written out as it stands, so
webgpu_postprocessing_anamorphic’s negated half-sample count
reaches the loop header as i32( ( - nodeVar1 ) ).
count: NodeRefLoop( { start, end }, … )’s end, or Loop( count, … )’s
count — the loop’s exclusive upper bound.
index: NodeRefThe loop index, as it appears inside body (Node::Param). Its
type is Loop( { type } ): i32, or f32 for hashBlur’s
type: 'float', which also changes the step to i += 1..
Break
Break() — a bare break; out of the innermost Loop.
Continue
Continue() — a bare continue; to the next iteration of the
innermost Loop.
TextureStore
textureStore( storageTexture, coord, value ) — a statement.
StorageTextureNode.generateStore() writes the coordinate as
vec2<u32>( … ) (vec3<u32> for a 3D texture) around whatever the
caller passed, so a uvec2 coordinate is wrapped once more, exactly as
three’s dump shows.
Fields
texture: Rc<TextureSource>The storage texture being written.
If
If( cond, () => { … } ) as a bare statement (setupDiscard),
optionally with the .Else( … ) / .ElseIf( … ) arm StackNode adds.
ElseIf is not a shape of its own: StackNode.ElseIf() puts a whole
nested If inside the else block, so If( a ).ElseIf( b ) is
else_body: vec![ if_then( b, … ) ] and generates as a nested
if/else, which is exactly what three emits.
Fields
IfVar
If( cond, () => { … } ) — a one-armed conditional over a result var
that was initialised before it. pre holds the statements three.js
emits ahead of the result var (its toConst lines), result is the var
itself and body the statements inside the block, the last of which
assigns result. The node’s value is the result var.
Fields
Discard
Discard() — a bare discard;.
Return
return value; inside an emitted fn — what an If( cond, () => { return x; } ) in a Fn() body compiles to (neutralToneMapping’s
early out).
Not
x.not() — ( ! x ). A bool, or a bvecN for an N-vector
operand (OperatorNode.getNodeType()’s '!' arm).
BitNot
x.bitNot() — ( ~ x ), typed getIntegerType( typeA ).
Select
cond.select( a, b ) — lowered to an if/else writing a result var,
exactly as Three does.
Fields
StructMember
storageStruct.get( 'member' ) — MemberNode on a
BufferSource::Struct storage buffer: NodeBuffer_N.member.
Fields
buffer: Rc<BufferNode>The struct buffer.
Atomic
AtomicFunctionNode — atomicStore( &pointer, value ) and the rest of
the family. pointer is a struct member or buffer element declared
atomic< T >. As a bare statement it is one atomicX( … ); line; read
as a value as well, its result is held in a let first.
Fields
Workgroup(Rc<WorkgroupArrayDef>)
WorkgroupInfoNode — the array itself. Read through
Node::Element, which is how .element( i ) reaches it.
Barrier
BarrierNode — workgroupBarrier() / storageBarrier() /
textureBarrier(), scope being the prefix.
Subgroup
SubgroupFunctionNode — subgroupAdd( e ), subgroupShuffle( e, id ),
quadSwapX( e ) and the rest of the family
(src/nodes/gpgpu/SubgroupFunctionNode.js). Reaching one enables
subgroups in the stage that builds it.
Fields
Custom(Rc<dyn CustomNode>)
A node type defined outside the crate; see CustomNode. Built by
building what its setup returns.
Context
ContextNode — node.context( { … } ). Builds node with value’s
keys merged into builder.context, and restores the previous context
afterwards.
Fields
value: Rc<ContextValue>The context entries merged in.
Isolate
IsolateNode — isolate( node ). Builds node in a NodeCache of
its own, whose parent is the cache in force where the isolate is
built: what node’s subgraph sets up, counts or declares for the first
time stays inside it.
Expression
ExpressionNode — expression( snippet, type ): raw WGSL. A value
type prints snippet where the node is read; void writes it to the
flow as a statement. Not cacheable: each read prints it again.
Debug
DebugNode — debug( node, callback ): node’s snippet, passed
through after callback (or a log of the flow so far) has seen it.
Fields
callback: Option<DebugCallback>null logs the stage’s flow code to stderr, as three’s log()
does to the console.
StructNew
structType( values ) — StructNode: a value of a struct_type
(StructTypeNode) built from one value per member, in member order.
Always held in a var of the struct’s type, which is where three’s
StructNode lands too (nodeVar31 = StructType0( … ) in the TRAA
dump); its ty is Type::Void because the port’s
Type has no struct case, and only Node::StructGet reads it.
OutputStruct
outputStruct( ...members ) — OutputStructNode, a fragment stage’s
whole result as one @location( i ) member per value, each of its own
type. It is only ever a material’s outputNode
(DepthOfFieldNode’s CoC pass writes its near and far fields this
way); the builder turns it into the OutputType struct and its
output.mN = … lines, as it does an MrtNode’s members, and it
has no value of its own.
StructGet
structNode.get( name ) — MemberNode over a Node::StructNew
(or over a block or Fn() whose result is one): { var }.{ member }.