| ▸isOpaque | () => boolean | — |
Whether the material is opaque or not. |
| ▸getBindGroupsCache | () => ChainMap | — |
Returns the bind groups of the current renderer. |
| ▸createRenderTarget | (width: number, height: number, options: Object) => RenderTarget | — |
Factory method for creating an instance of {@link RenderTarget} with the given
dimensions and options. |
| width | number | — | | height | number | — | | options | Object | — |
|
| ▸createCubeRenderTarget | (size: number, options: Object) => CubeRenderTarget | — |
Factory method for creating an instance of {@link CubeRenderTarget} with the given
dimensions and options. |
| size | number | — | | options | Object | — |
|
| ▸includes | (node: Node) => boolean | — |
Whether the given node is included in the internal array of nodes or not. |
| ▸getOutputStructName | () => string | — |
Returns the output struct name which is required by
{@link OutputStructNode}. |
| ▸_getBindGroup | (groupName: string, bindings: Array<…>) => BindGroup | — |
Returns a bind group for the given group name and binding. |
| groupName | string | — | | bindings | Array<NodeUniformsGroup> | — |
|
| ▸getBindGroupArray | (groupName: string, shaderStage: "vertex" | "fragment" | "compute" | "any") => Array<…> | — |
Returns an array of node uniform groups for the given group name and shader stage. |
| groupName | string | — | | shaderStage | "vertex" | "fragment" | "compute" | "any" | — |
Returns Array<NodeUniformsGroup> |
| ▸getBindings | () => Array<…> | — |
Returns a list bindings of all shader stages separated by groups. |
| ▸sortBindingGroups | () => void | — |
Sorts the bind groups and updates {@link NodeBuilder#bindingsIndexes}. |
| ▸setHashNode | (node: Node, hash: number) => void | — |
The builder maintains each node in a hash-based dictionary.
This method sets the given node (value) with the given hash (key) into this dictionary. |
| ▸addNode | (node: Node) => void | — |
Adds a node to this builder. |
| ▸addSequentialNode | (node: Node) => void | — |
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. |
| ▸buildUpdateNodes | () => void | — |
Checks the update types of nodes |
| ▸isFilteredTexture | (texture: Texture) => boolean | — |
Whether the given texture is filtered or not. |
| ▸addChain | (node: Node) => void | — |
Adds the given node to the internal node chain.
This is used to check recursive calls in node-graph. |
| ▸removeChain | (node: Node) => void | — |
Removes the given node from the internal node chain. |
| ▸getMethod | (method: string) => string | — |
Returns the native shader method name for a given generic name. E.g.
the method name textureDimensions matches the WGSL name but must be
resolved to textureSize in GLSL. |
| ▸getTernary | () => string | — |
Returns the native snippet for a ternary operation. E.g. GLSL would output
a ternary op as cond ? x : y whereas WGSL would output it as select(y, x, cond) |
| ▸getNodeFromHash | (hash: number) => Node | — |
Returns a node for the given hash, see {@link NodeBuilder#setHashNode}. |
| ▸addFlow | (shaderStage: "vertex" | "fragment" | "compute", node: Node) => Node | — |
Adds the Node to a target flow so that it can generate code in the ‘generate’ process. |
| shaderStage | "vertex" | "fragment" | "compute" | — | | node | Node | — |
|
| ▸setContext | (context: Object) => void | — |
|
| ▸getContext | () => Object | — |
Returns the builder’s current context. |
| ▸addContext | (context: Object) => Object | — |
Adds context data to the builder’s current context. |
| ▸getSharedContext | () => Object | — |
Gets a context used in shader construction that can be shared across different materials.
This is necessary since the renderer cache can reuse shaders generated in one material and use them in another. |
| ▸setCache | (cache: NodeCache) => void | — |
|
| ▸getCache | () => NodeCache | — |
Returns the builder’s current cache. |
| ▸getCacheFromNode | (node: Node, parent?: boolean) => NodeCache | — |
Returns a cache for the given node. |
| node | Node | — | | parent? | boolean | true |
|
| ▸isAvailable | () => boolean | — |
Whether the requested feature is available or not. |
| ▸getVertexIndex | () => string | — |
Returns the vertexIndex input variable as a native shader string. |
| ▸getInstanceIndex | () => string | — |
Contextually returns either the vertex stage instance index builtin
or the linearized index of an compute invocation within a grid of workgroups. |
| ▸getDrawIndex | () => null | string | — |
Returns the drawIndex input variable as a native shader string.
Only relevant for WebGL and its WEBGL_multi_draw extension. |
| ▸getFrontFacing | () => string | — |
Returns the frontFacing input variable as a native shader string. |
| ▸getFragCoord | () => string | — |
Returns the fragCoord input variable as a native shader string. |
| ▸isFlipY | () => boolean | — |
Whether to flip texture data along its vertical axis or not. WebGL needs
this method evaluate to true, WebGPU to false. |
| ▸increaseUsage | (node: Node) => number | — |
Calling this method increases the usage count for the given node by one. |
| ▸generateTexture | () => string | — |
Generates a texture sample shader string for the given texture data. |
| ▸generateTextureLod | () => string | — |
Generates a texture LOD shader string for the given texture data. |
| ▸generateArrayDeclaration | (type: string, count?: null | number) => string | — |
Generates the array declaration string. |
| type | string | — | | count? | null | number | — |
|
| ▸generateArray | (type: string, count?: null | number, values?: null | Array<…>) => string | — |
Generates the array shader string for the given type and value. |
| type | string | — | | count? | null | number | — | | values? | null | Array<Node> | null |
|
| ▸generateStruct | (type: string, membersLayout?: Array<…>, values?: null | Array<…>) => string | — |
Generates the struct shader string. |
| type | string | — | | membersLayout? | Array<Object> | — | | values? | null | Array<Node> | null |
|
| ▸generateConst | (type: string, value?: any) => string | — |
Generates the shader string for the given type and value. |
| ▸getType | (type: string) => string | — |
It might be necessary to convert certain data types to different ones
so this method can be used to hide the conversion. |
| ▸hasGeometryAttribute | (name: string) => boolean | — |
Whether the given attribute name is defined in the geometry or not. |
| ▸getAttribute | (name: string, type: string) => NodeAttribute | — |
Returns a node attribute for the given name and type. |
| ▸getPropertyName | (node: Node) => string | — |
Returns for the given node and shader stage the property name for the shader. |
| ▸isVector | (type: string) => boolean | — |
Whether the given type is a vector type or not. |
| ▸isMatrix | (type: string) => boolean | — |
Whether the given type is a matrix type or not. |
| ▸isReference | (type: string) => boolean | — |
Whether the given type is a reference type or not. |
| ▸needsToWorkingColorSpace | () => boolean | — |
Checks if the given texture requires a manual conversion to the working color space. |
| ▸getComponentTypeFromTexture | (texture: Texture) => string | — |
Returns the component type of a given texture. |
| ▸getElementType | (type: string) => string | — |
Returns the element type for a given type. |
| ▸getComponentType | (type: string) => string | — |
Returns the component type for a given type. |
| ▸getVectorType | (type: string) => string | — |
Returns the vector type for a given type. |
| ▸getTypeFromLength | (length: number, componentType?: string) => string | — |
Returns the data type for the given the length and component type. |
| length | number | — | | componentType? | string | float |
|
| ▸getTypeFromArray | (array: TypedArray) => string | — |
Returns the type for a given typed array. |
| ▸isInteger | (type: string) => boolean | — |
Returns the type is an integer type. |
| ▸getTypeFromAttribute | (attribute: BufferAttribute) => string | — |
Returns the type for a given buffer attribute. |
| attribute | BufferAttribute | — |
|
| ▸getTypeLength | (type: string) => number | — |
Returns the length for the given data type. |
| ▸getVectorFromMatrix | (type: string) => string | — |
Returns the vector type for a given matrix type. |
| ▸changeComponentType | (type: string, newComponentType: string) => string | — |
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 | string | — | | newComponentType | string | — |
|
| ▸getIntegerType | (type: string) => string | — |
Returns the integer type pendant for the given type. |
| ▸setActiveStack | (stack: StackNode) => void | — |
Adds an active stack to the internal stack. |
| ▸removeActiveStack | (stack: StackNode) => void | — |
Removes the active stack from the internal stack. |
| ▸getActiveStack | () => StackNode | — |
Returns the active stack. |
| ▸getBaseStack | () => StackNode | — |
|
| ▸addStack | () => StackNode | — |
Adds a stack node to the internal stack. |
| ▸removeStack | () => StackNode | — |
Removes the last stack node from the internal stack. |
| ▸getDataFromNode | (node: Node, shaderStage?: "vertex" | "fragment" | "compute" | "any", cache?: null | NodeCache) => Object | — |
The builder maintains (cached) data for each node during the building process. This method
can be used to get these data for a specific shader stage and cache. |
| node | Node | — | | shaderStage? | "vertex" | "fragment" | "compute" | "any" | this.shaderStage | | cache? | null | NodeCache | null |
|
| ▸getNodeProperties | (node: Node, shaderStage?: "vertex" | "fragment" | "compute" | "any") => Object | — |
Returns the properties for the given node and shader stage.
Properties are typically used within a build stage to reference a node’s
child node or nodes manually assigned to the properties in a separate build stage.
A typical usage pattern for defining nodes manually would be assigning dependency nodes
to the current node’s properties in the setup stage and building those properties in the generate stage. |
| node | Node | — | | shaderStage? | "vertex" | "fragment" | "compute" | "any" | any |
|
| ▸getBufferAttributeFromNode | (node: BufferAttributeNode, type: string) => NodeAttribute | — |
Returns an instance of {@link NodeAttribute} for the given buffer attribute node. |
| node | BufferAttributeNode | — | | type | string | — |
|
| ▸getStructTypeNode | (name: string, shaderStage?: "vertex" | "fragment" | "compute" | "any") => null | StructType | — |
Returns an instance of {@link StructType} for the given struct name and shader stage
or null if not found. |
| name | string | — | | shaderStage? | "vertex" | "fragment" | "compute" | "any" | this.shaderStage |
|
| ▸getStructTypeFromNode | (node: OutputStructNode, membersLayout: Array<…>, name?: null | string, shaderStage?: "vertex" | "fragment" | "compute" | "any") => StructType | — |
Returns an instance of {@link StructType} for the given output struct node. |
| node | OutputStructNode | — | | membersLayout | Array<Object> | — | | name? | null | string | null | | shaderStage? | "vertex" | "fragment" | "compute" | "any" | this.shaderStage |
|
| ▸getOutputStructTypeFromNode | (node: OutputStructNode, membersLayout: Array<…>) => StructType | — |
Returns an instance of {@link StructType} for the given output struct node. |
| node | OutputStructNode | — | | membersLayout | Array<Object> | — |
|
| ▸getUniformFromNode | (node: UniformNode, type: string, shaderStage?: "vertex" | "fragment" | "compute" | "any", name?: null | string) => NodeUniform | — |
Returns an instance of {@link NodeUniform} for the given uniform node. |
| node | UniformNode | — | | type | string | — | | shaderStage? | "vertex" | "fragment" | "compute" | "any" | this.shaderStage | | name? | null | string | null |
|
| ▸getVarFromNode | (node: VarNode, name?: null | string, type?: string, shaderStage?: "vertex" | "fragment" | "compute" | "any", readOnly?: boolean) => NodeVar | — |
Returns an instance of {@link NodeVar} for the given variable node. |
| node | VarNode | — | | name? | null | string | null | | type? | string | node.getNodeType( this ) | | shaderStage? | "vertex" | "fragment" | "compute" | "any" | this.shaderStage | | readOnly? | boolean | false |
|
| ▸isDeterministic | (node: Node) => boolean | — |
Returns whether a Node or its flow is deterministic, useful for use in const. |
| ▸getVaryingFromNode | (node: any, name?: null | string, type?: string, interpolationType?: null | string, interpolationSampling?: null | string) => NodeVar | — |
Returns an instance of {@link NodeVarying} for the given varying node. |
| node | any | — | | name? | null | string | null | | type? | string | node.getNodeType( this ) | | interpolationType? | null | string | null | | interpolationSampling? | null | string | null |
|
| ▸registerDeclaration | (node: Object) => void | — |
Registers a node declaration in the current shader stage. |
| ▸getCodeFromNode | (node: CodeNode, type: string, shaderStage?: "vertex" | "fragment" | "compute" | "any") => NodeCode | — |
Returns an instance of {@link NodeCode} for the given code node. |
| node | CodeNode | — | | type | string | — | | shaderStage? | "vertex" | "fragment" | "compute" | "any" | this.shaderStage |
|
| ▸addFlowCodeHierarchy | (node: Node, nodeBlock: Node) => void | — |
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. |
| ▸addLineFlowCodeBlock | (node: Node, code: string, nodeBlock: Node) => void | — |
Add a inline-code to the current flow code-block. |
| node | Node | — | | code | string | — | | nodeBlock | Node | — |
|
| ▸addLineFlowCode | (code: string, node?: null | Node) => NodeBuilder | — |
Add a inline-code to the current flow. |
| code | string | — | | node? | null | Node | null |
|
| ▸addFlowCode | (code: string) => NodeBuilder | — |
Adds a code to the current code flow. |
| ▸addFlowTab | () => NodeBuilder | — |
Add tab in the code that will be generated so that other snippets respect the current tabulation.
Typically used in codes with If,Else. |
| ▸removeFlowTab | () => NodeBuilder | — |
|
| ▸getFlowData | (node: Node) => Object | — |
Gets the current flow data based on a Node. |
| ▸flowNode | (node: Node) => Object | — |
Executes the node flow based on a root node to generate the final shader code. |
| ▸addInclude | (node: Node) => void | — |
Includes a node in the current function node. |
| ▸buildFunctionNode | (shaderNode: ShaderNodeInternal) => FunctionNode | — |
Returns the native shader operator name for a given generic name.
It is a similar type of method like {@link NodeBuilder#getMethod}. |
| shaderNode | ShaderNodeInternal | — |
|
| ▸flowShaderNode | (shaderNode: ShaderNodeInternal) => Object | — |
Generates a code flow based on a TSL function: Fn(). |
| shaderNode | ShaderNodeInternal | — |
|
| ▸flowBuildStage | (node: Node, buildStage: string, output?: null | string | Node) => null | string | Node | — |
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 | Node | — | | buildStage | string | — | | output? | null | string | Node | null |
Returns null | string | Node |
| ▸flowStagesNode | (node: Node, output?: null | string) => Object | — |
Runs the node flow through all the steps of creation, ‘setup’, ‘analyze’, ‘generate’. |
| node | Node | — | | output? | null | string | null |
|
| ▸getFunctionOperator | () => null | string | — |
Returns the native shader operator name for a given generic name.
It is a similar type of method like {@link NodeBuilder#getMethod}. |
| ▸buildFunctionCode | () => string | — |
Builds the given shader node. |
| ▸flowChildNode | (node: Node, output?: null | string) => Object | — |
Generates a code flow based on a child Node. |
| node | Node | — | | output? | null | string | null |
|
| ▸flowNodeFromShaderStage | (shaderStage: "vertex" | "fragment" | "compute" | "any", node: Node, output?: null | string, propertyName?: null | string) => null | Object | Node | — |
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 | "vertex" | "fragment" | "compute" | "any" | — | | node | Node | — | | output? | null | string | null | | propertyName? | null | string | null |
Returns null | Object | Node |
| ▸getAttributesArray | () => Array<…> | — |
Returns an array holding all node attributes of this node builder. Returns Array<NodeAttribute> |
| ▸getAttributes | () => string | — |
Returns the attribute definitions as a shader string for the given shader stage. |
| ▸getVaryings | () => string | — |
Returns the varying definitions as a shader string for the given shader stage. |
| ▸getVar | (type: string, name: string, count?: null | number) => string | — |
Returns a single variable definition as a shader string for the given variable type and name. |
| type | string | — | | name | string | — | | count? | null | number | null |
|
| ▸getVars | (shaderStage: "vertex" | "fragment" | "compute" | "any") => string | — |
Returns the variable definitions as a shader string for the given shader stage. |
| shaderStage | "vertex" | "fragment" | "compute" | "any" | — |
|
| ▸getUniforms | () => string | — |
Returns the uniform definitions as a shader string for the given shader stage. |
| ▸getCodes | (shaderStage: "vertex" | "fragment" | "compute" | "any") => string | — |
Returns the native code definitions as a shader string for the given shader stage. |
| shaderStage | "vertex" | "fragment" | "compute" | "any" | — |
|
| ▸getHash | () => string | — |
Returns the hash of this node builder. |
| ▸setShaderStage | (shaderStage: null | "vertex" | "fragment" | "compute" | "any") => void | — |
Sets the current shader stage. |
| shaderStage | null | "vertex" | "fragment" | "compute" | "any" | — |
|
| ▸getShaderStage | () => null | "vertex" | "fragment" | "compute" | "any" | — |
Returns the current shader stage. Returns null | "vertex" | "fragment" | "compute" | "any" |
| ▸setBuildStage | (buildStage: null | "generate" | "setup" | "analyze") => void | — |
Sets the current build stage. |
| buildStage | null | "generate" | "setup" | "analyze" | — |
|
| ▸getBuildStage | () => null | "generate" | "setup" | "analyze" | — |
Returns the current build stage. Returns null | "generate" | "setup" | "analyze" |
| ▸buildCode | () => void | — |
Controls the code build of the shader stages. |
| ▸addSubBuild | (subBuild: SubBuildNode) => void | — |
Adds a sub-build layer to the node builder. |
| ▸removeSubBuild | () => SubBuildNode | — |
Removes the last sub-build layer from the node builder. |
| ▸getClosestSubBuild | (data: Node | Array<…> | Set<string>) => null | string | — |
Returns the closest sub-build layer for the given data. |
| data | Node | Array<string> | Set<string> | — |
|
| ▸getSubBuildOutput | (node: Node) => string | — |
Returns the output node of a sub-build layer. |
| ▸getSubBuildProperty | (property?: string, node?: null | Node) => string | — |
Returns the sub-build property name for the given property and node. |
| property? | string | | | node? | null | Node | null |
|
| ▸build | () => NodeBuilder | — |
Central build method which controls the build for the given object. |
| ▸getSharedDataFromNode | (node: Node) => Object | — |
Returns shared data object for the given node. |
| ▸getNodeUniform | (uniformNode: NodeUniform, type: string) => Uniform | — |
Returns a uniform representation which is later used for UBO generation and rendering. |
| uniformNode | NodeUniform | — | | type | string | — |
|
| ▸format | (snippet: string, fromType: string, toType: string) => string | — |
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 | string | — | | fromType | string | — | | toType | string | — |
|
| ▸getSignature | () => string | — |
Returns a signature with the engine’s current revision. |