Creates a new ConstantVariableShader instance.
The name of the generated shader function
The composition type (scalar, vec2, vec3, vec4, etc.) of the constant
The component type (float, int, bool) of the constant
Returns the attribute compositions required by this shader part. Since this is a constant variable shader that doesn't use any vertex attributes, it returns an empty array.
An empty array as no attribute compositions are needed for constant values.
Returns the attribute names required by this shader part. Since this is a constant variable shader that doesn't use any vertex attributes, it returns an empty array.
An empty array as no vertex attributes are needed for constant values.
Returns the vertex attribute semantics required by this shader part. Since this is a constant variable shader that doesn't use any vertex attributes, it returns an empty array.
An empty array as no vertex attribute semantics are needed for constant values.
Generates the pixel shader function definition that outputs the constant value. This is identical to the vertex shader definition as constant values are the same regardless of shader stage.
The GLSL or WGSL function definition string for the pixel shader, depending on the current process approach (WebGL or WebGPU).
Generates the vertex shader function definition that outputs the constant value. The generated function takes an output parameter and assigns the constant value to it.
The GLSL or WGSL function definition string for the vertex shader, depending on the current process approach (WebGL or WebGPU).
Sets the constant value that will be output by the generated shader function. The value is converted to the appropriate GLSL/WGSL string representation based on the component type.
The vector value to be used as the constant. The number of components used depends on the composition type specified in the constructor.
Static
getGenerates variable assignment statement with proper type declaration. Creates appropriate syntax for both WebGL (GLSL) and WebGPU (WGSL) based on the current process approach.
The name of the variable to declare
The socket containing type and default value information
The variable assignment statement string
Static
getGenerates varying variable assignment statement for fragment/pixel shaders. Creates code to read varying variables passed from vertex shader with proper type declaration.
The name of the variable to declare
The socket containing type information
The shader node that provides the varying variable
The varying variable assignment statement string for fragment shader
Static
getGenerates varying variable assignment statement for vertex shaders. Creates code to write varying variables that will be passed to fragment shader.
The shader node that provides the varying variable
Array of variable names to assign
Index of the current variable in the varNames array
The varying variable assignment statement string for vertex shader
Static
getGenerates the main function beginning code for vertex or fragment shaders. Handles differences between WebGL (GLSL) and WebGPU (WGSL) shader languages.
True if generating code for vertex shader, false for fragment shader
The shader code string for the main function beginning
Static
getGenerates the main function ending code for vertex or fragment shaders. Handles differences between WebGL (GLSL) and WebGPU (WGSL) shader languages.
True if generating code for vertex shader, false for fragment shader
The shader code string for the main function ending
Static
getStatic
getGenerates fragment/pixel shader prerequisites including definitions and varying variable declarations. Creates appropriate code for both WebGL (GLSL) and WebGPU (WGSL) based on the current process approach.
Array of shader nodes used to generate varying variables for WebGPU
The complete fragment shader prerequisites code string
Static
getGenerates vertex shader prerequisites including definitions, vertex inputs, and uniform declarations. Creates appropriate code for both WebGL (GLSL) and WebGPU (WGSL) based on the current process approach.
Array of shader nodes used to generate varying variables for WebGPU
The complete vertex shader prerequisites code string
A shader part that generates constant variable functions for both vertex and pixel shaders. This class creates GLSL/WGSL functions that output constant values of specified composition and component types.
Example