Base class for builders which generate a shader program based on a 3D object and its node material definition.
Constructs a new node builder.
object
The 3D object.
renderer
The current renderer.
parser
A reference to a node parser.
The active stack nodes.
This array holds the node attributes of this builder created via AttributeNode.
Reference to the array of bind groups.
This dictionary holds the bindings for each shader stage.
This dictionary maintains the binding indices per bind group.
This array holds the node attributes of this builder created via BufferAttributeNode.
The current build stage.
The builder's cache.
The camera the 3D object is rendered with.
Default is null.
A chain of nodes. Used to check recursive calls in node-graph.
The current clipping context.
This dictionary holds the (native) node codes of this builder. The codes are maintained in an array for each shader stage.
The generated compute shader.
The builder's context.
Reference to the current function node.
Default is null.
A reference the current node which is the last node in the chain of nodes.
This dictionary holds the declarations for each shader stage.
A reference to the current environment node.
Default is null.
Current code flow. All code generated in this stack will be stored in .flow.
Nodes code from .flowNodes.
Nodes used in the primary flow of code generation.
The current TSL function(Fn) call node.
Default is null.
A reference to the current fog node.
Default is null.
The generated fragment shader.
The geometry of the 3D object.
Since the NodeBuilder#cache might be temporarily overwritten by other caches, this member retains the reference to the builder's own cache.
Default is this.cache.
A dictionary that assigns each node to a unique hash.
A reference to the current lights node.
Default is null.
The material of the 3D object.
A list of all nodes the builder is processing for this 3D object.
The 3D object.
A reference to a node material observer.
Default is null.
A reference to a node parser.
The current renderer.
The scene the 3D object belongs to.
Default is null.
A list of all nodes the builder is processing in sequential order.
This is used to determine the update order of nodes, which is important for NodeUpdateType#UPDATE_BEFORE and NodeUpdateType#UPDATE_AFTER.
The current shader stage.
The current stack. This reflects the current process in the code block hierarchy, it is useful to know if the current process is inside a conditional for example.
List of stack nodes. The current stack hierarchy is stored in an array.
This dictionary holds the output structs of the builder. The structs are maintained in an array for each shader stage.
Returns the current sub-build layer.
The current sub-build TSL function(Fn).
Default is null.
The sub-build layers.
Default is [].
A tab value. Used for shader string generation.
Default is '\t'.
This dictionary holds the types of the builder.
This dictionary holds the node uniforms of the builder. The uniforms are maintained in an array for each shader stage.
A list of all nodes which Node#updateAfter method should be executed.
A list of all nodes which Node#updateBefore method should be executed.
A list of all nodes which Node#update method should be executed.
This dictionary holds the node variables of this builder. The variables are maintained in an array for each shader stage. This dictionary is also used to count the number of variables according to their type (const, vars).
This array holds the node varyings of this builder.
The generated vertex shader.
Adds the given node to the internal node chain. This is used to check recursive calls in node-graph.
node
The node to add.
Adds context data to the builder's current context.
context
The context to add.
Returns: The previous context.
Adds the Node to a target flow so that it can generate code in the 'generate' process.
shaderStage
The shader stage.
node
The node to add.
Returns: The node.
Adds a code to the current code flow.
code
Shader code.
Returns: A reference to this node builder.
Adds a code flow based on the code-block hierarchy. This is used so that code-blocks like If,Else create their variables locally if the Node is only used inside one of these conditionals in the current shader stage.
node
The node to add.
nodeBlock
Node-based code-block. Usually 'ConditionalNode'.
Add tab in the code that will be generated so that other snippets respect the current tabulation. Typically used in codes with If,Else.
Returns: A reference to this node builder.
Includes a node in the current function node.
node
The node to include.
Add a inline-code to the current flow.
code
The code to add.
node
Optional Node, can help the system understand if the Node is part of a code-block.
Default is null.
Returns: A reference to this node builder.
Add a inline-code to the current flow code-block.
node
The node to add.
code
The code to add.
nodeBlock
Current ConditionalNode
Adds a node to this builder.
node
The node to add.
It is used to add Nodes that will be used as FRAME and RENDER events, and need to follow a certain sequence in the calls to work correctly. This function should be called after 'setup()' in the 'build()' process to ensure that the child nodes are processed first.
node
The node to add.
Adds a stack node to the internal stack.
Returns: The added stack node.
Adds a sub-build layer to the node builder.
subBuild
The sub-build layer to add.
Central build method which controls the build for the given object.
Returns: A reference to this node builder.
Controls the code build of the shader stages.
Builds the given shader node.
shaderNode
The shader node.
Returns: The function code.
Returns the native shader operator name for a given generic name. It is a similar type of method like NodeBuilder#getMethod.
shaderNode
The shader node to build the function node with.
Returns: The build function node.
Checks the update types of nodes
For a given type this method changes the component type to the given value. E.g. vec4 should be changed to the new component type uint which results in uvec4.
type
The type.
newComponentType
The new component type.
Returns: The new type.
Factory method for creating an instance of CubeRenderTarget with the given dimensions and options.
size
The size of the cube render target.
options
The options of the cube render target.
Returns: The cube render target.
Factory method for creating an instance of RenderTarget with the given dimensions and options.
width
The width of the render target.
height
The height of the render target.
options
The options of the render target.
Returns: The render target.
Executes the node in a specific build stage.
This function can be used to arbitrarily execute the specified build stage outside of the standard build process. For instance, if a node's type depends on properties created by the 'setup' stage, then flowBuildStage(node, 'setup') can be used to execute the setup build stage and access its generated nodes before the standard build process begins.
node
The node to execute.
buildStage
The build stage to execute the node in.
output
Expected output type. For example 'vec3'.
Default is null.
Returns: The result of the node build.
Generates a code flow based on a child Node.
node
The node to execute.
output
Expected output type. For example 'vec3'.
Default is null.
Returns: The code flow.
Executes the node flow based on a root node to generate the final shader code.
node
The node to execute.
Returns: The code flow.
Executes a flow of code in a different stage.
Some nodes like varying() have the ability to compute code in vertex-stage and return the value in fragment-stage even if it is being executed in an input fragment.
shaderStage
The shader stage.
node
The node to execute.
output
Expected output type. For example 'vec3'.
Default is null.
propertyName
The property name to assign the result.
Default is null.
Returns: The code flow or node.build() result.
Generates a code flow based on a TSL function: Fn().
shaderNode
A function code will be generated based on the input.
Runs the node flow through all the steps of creation, 'setup', 'analyze', 'generate'.
node
The node to execute.
output
Expected output type. For example 'vec3'.
Default is null.
Formats the given shader snippet from a given type into another one. E.g. this method might be used to convert a simple float string "1.0" into a vec3 representation: "vec3<f32>( 1.0 )".
snippet
The shader snippet.
fromType
The source type.
toType
The target type.
Returns: The updated shader string.
Generates the array shader string for the given type and value.
type
The type.
count
The count.
values
The default values.
Default is null.
Returns: The generated value as a shader string.
Generates the array declaration string.
type
The type.
count
The count.
Returns: The generated value as a shader string.
Generates the shader string for the given type and value.
type
The type.
value
The value.
Default is null.
Returns: The generated value as a shader string.