File: GLSLNodeBuilder.md | Updated: 11/15/2025
A node builder targeting GLSL.
This module generates GLSL shader code from node materials and also generates the respective bindings and vertex buffer definitions. These data are later used by the renderer to create render and compute pipelines for render objects.
Constructs a new GLSL node builder renderer.
object | The 3D object.
---|---
renderer | The renderer.
A dictionary that holds for each shader stage an Array of used builtins.
A dictionary that holds for each shader stage a Map of used extensions.
An array that holds objects defining the varying and attribute data in context of Transform Feedback.
A dictionary holds for each shader stage ('vertex', 'fragment', 'compute') another dictionary which manages UBOs per group ('render','frame','object').
Controls the code build of the shader stages.
Overrides: NodeBuilder#buildCode
Builds the given shader node.
shaderNode | The shader node.
---|---
Overrides: NodeBuilder#buildFunctionCode
Returns: The GLSL function code.
Enables the given extension.
name | The extension name.
---|---
behavior | The extension behavior.
shaderStage | The shader stage. Default is this.shaderStage.
Enables hardware clipping.
planeCount | The clipping plane count.
---|---
Enables multiview.
Setups the Pixel Buffer Object (PBO) for the given storage buffer node.
storageArrayElementNode | The storage array element node.
---|---
Returns: The property name.
Generates the GLSL snippet for sampling/loading the given texture.
texture | The texture.
---|---
textureProperty | The name of the texture uniform in the shader.
uvSnippet | A GLSL snippet that represents texture coordinates used for sampling.
depthSnippet | A GLSL snippet that represents the 0-based texture array index to sample.
offsetSnippet | A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
Overrides: NodeBuilder#generateTexture
Returns: The GLSL snippet.
Generates the GLSL snippet when sampling textures with a bias to the mip level.
texture | The texture.
---|---
textureProperty | The name of the texture uniform in the shader.
uvSnippet | A GLSL snippet that represents texture coordinates used for sampling.
biasSnippet | A GLSL snippet that represents the bias to apply to the mip level before sampling.
offsetSnippet | A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
Returns: The GLSL snippet.
Generates the GLSL snippet for sampling a depth texture and comparing the sampled depth values against a reference value.
texture | The texture.
---|---
textureProperty | The name of the texture uniform in the shader.
uvSnippet | A GLSL snippet that represents texture coordinates used for sampling.
compareSnippet | A GLSL snippet that represents the reference value.
depthSnippet | A GLSL snippet that represents 0-based texture array index to sample.
offsetSnippet | A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
shaderStage | The shader stage this code snippet is generated for. Default is this.shaderStage.
Returns: The GLSL snippet.
Generates the GLSL snippet for sampling/loading the given texture using explicit gradients.
texture | The texture.
---|---
textureProperty | The name of the texture uniform in the shader.
uvSnippet | A GLSL snippet that represents texture coordinates used for sampling.
gradSnippet | An array holding both gradient GLSL snippets.
offsetSnippet | A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
Returns: The GLSL snippet.
Generates the GLSL snippet when sampling textures with explicit mip level.
texture | The texture.
---|---
textureProperty | The name of the texture uniform in the shader.
uvSnippet | A GLSL snippet that represents texture coordinates used for sampling.
levelSnippet | A GLSL snippet that represents the mip level, with level 0 containing a full size version of the texture.
offsetSnippet | A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
Returns: The GLSL snippet.
Generates the GLSL snippet that reads a single texel from a texture without sampling or filtering.
texture | The texture.
---|---
textureProperty | The name of the texture uniform in the shader.
uvIndexSnippet | A GLSL snippet that represents texture coordinates used for sampling.
levelSnippet | A GLSL snippet that represents the mip level, with level 0 containing a full size version of the texture.
depthSnippet | A GLSL snippet that represents the 0-based texture array index to sample.
offsetSnippet | A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
Returns: The GLSL snippet.
Returns the shader attributes of the given shader stage as a GLSL string.
shaderStage | The shader stage.
---|---
Overrides: NodeBuilder#getAttributes
Returns: The GLSL snippet that defines the shader attributes.
Returns the bitcast method name for a given input and outputType.
type | The output type to bitcast to.
---|---
inputType | The input type of the.
Returns: The resolved WGSL bitcast invocation.
Returns the clip distances builtin.
Returns: The clip distances builtin.
Returns the draw index builtin.
Overrides: NodeBuilder#getDrawIndex
Returns: The drawIndex shader string. Returns null if WEBGL_multi_draw isn't supported by the device.
Returns the enabled extensions of the given shader stage as a GLSL string.
shaderStage | The shader stage.
---|---
Returns: The GLSL snippet that defines the enabled extensions.
Returns the frag coord builtin.
Overrides: NodeBuilder#getFragCoord
Returns: The frag coord builtin.
Returns the frag depth builtin.
Returns: The frag depth builtin.
Returns the front facing builtin.
Overrides: NodeBuilder#getFrontFacing
Returns: The front facing builtin.
Contextually returns either the vertex stage instance index builtin or the linearized index of an compute invocation within a grid of workgroups.
Overrides: NodeBuilder#getInstanceIndex
Returns: The instance index.
Returns a builtin representing the index of an invocation within its workgroup.
Returns: The invocation local index.
Returns a builtin representing the index of an invocation within its subgroup.
Returns the native shader method name for a given generic name.
method | The method name to resolve.
---|---
Overrides: NodeBuilder#getMethod
Returns: The resolved GLSL method name.
Returns the output struct name. Not relevant for GLSL.
Overrides: NodeBuilder#getOutputStructName
Returns a GLSL snippet that represents the property name of the given node.
node | The node.
---|---
shaderStage | The shader stage this code snippet is generated for. Default is this.shaderStage.
Overrides: NodeBuilder#getPropertyName
Returns: The property name.
Returns the members of the given struct type node as a GLSL string.
struct | The struct type node.
---|---
Returns: The GLSL snippet that defines the struct members.
Returns the structs of the given shader stage as a GLSL string.
shaderStage | The shader stage.
---|---
Returns: The GLSL snippet that defines the structs.
Returns a builtin representing the index of the current invocation's subgroup within its workgroup.
Returns a builtin representing the size of a subgroup within the current shader.
Returns the native snippet for a ternary operation.
condSnippet | The condition determining which expression gets resolved.
---|---
ifSnippet | The expression to resolve to if the condition is true.
elseSnippet | The expression to resolve to if the condition is false.
Overrides: NodeBuilder#getTernary
Returns: The resolved method name.
Returns the transforms of the given shader stage as a GLSL string.
shaderStage | The shader stage.
---|---
Returns: The GLSL snippet that defines the transforms.
Returns the type for a given buffer attribute.
attribute | The buffer attribute.
---|---
Overrides: NodeBuilder#getTypeFromAttribute
Returns: The type.
This method is one of the more important ones since it's responsible for generating a matching binding instance for the given uniform node.
These bindings are later used in the renderer to create bind groups and layouts.
node | The uniform node.
---|---
type | The node data type.
shaderStage | The shader stage.
name | An optional uniform name. Default is null.
Overrides: NodeBuilder#getUniformFromNode
Returns: The node uniform object.
Returns the uniforms of the given shader stage as a GLSL string.
shaderStage | The shader stage.
---|---
Overrides: NodeBuilder#getUniforms
Returns: The GLSL snippet that defines the uniforms.
Returns the variables of the given shader stage as a GLSL string.
shaderStage | The shader stage.
---|---
Overrides: NodeBuilder#getVars
Returns: The GLSL snippet that defines the variables.
Returns the varyings of the given shader stage as a GLSL string.
shaderStage | The shader stage.
---|---
Overrides: NodeBuilder#getVaryings
Returns: The GLSL snippet that defines the varyings.
Returns the vertex index builtin.
Overrides: NodeBuilder#getVertexIndex
Returns: The vertex index.
Whether the requested feature is available or not.
name | The requested feature.
---|---
Overrides: NodeBuilder#isAvailable
Returns: Whether the requested feature is supported or not.
Whether to flip texture data along its vertical axis or not.
Overrides: NodeBuilder#isFlipY
Returns: Returns always true in context of GLSL.
Checks if the given texture requires a manual conversion to the working color space.
texture | The texture to check.
---|---
Overrides: NodeBuilder#needsToWorkingColorSpace
Returns: Whether the given texture requires a conversion to working color space or not.
Registers a transform in context of Transform Feedback.
varyingName | The varying name.
---|---
attributeNode | The attribute node.
Setups the Pixel Buffer Object (PBO) for the given storage buffer node.
storageBufferNode | The storage buffer node.
---|---