rhodonite
    Preparing search index...

    Class ConstantVector4VariableShaderNode<T>

    A shader node that represents a constant 4D vector variable in shader programs. This node extends the base ConstantVariableShaderNode to provide specific functionality for Vec4 composition types, allowing developers to set and use constant 4D vector values within shader materials. Vec4 values are commonly used for RGBA colors, quaternions, or homogeneous coordinates.

    // Create a Vec4 constant node with float components for RGBA color
    const colorNode = new ConstantVector4VariableShaderNode(ComponentType.Float);
    colorNode.setDefaultInputValue(Vector4.fromCopy4(1.0, 0.5, 0.2, 1.0)); // Orange with full alpha

    // Connect it to other shader nodes in a material graph
    const multiplyNode = new MultiplyShaderNode(CompositionType.Vec4, ComponentType.Float);
    multiplyNode.addInputConnection(colorNode, colorNode.getSocketOutput(), multiplyNode.getSocketInputLhs());

    Type Parameters

    • T extends ComponentTypeEnum

      The component type enum that defines the data type of the vector components (e.g., Float, Int, UnsignedInt, etc.)

    Hierarchy

    • ConstantVariableShaderNode<typeof CompositionType.Vec4, T>
      • ConstantVector4VariableShaderNode
    Index

    Constructors

    Properties

    __commonPart?: CommonShaderPart
    __inputConnections: ShaderNodeInputConnectionType[] = []
    __inputs: Socket<
        string,
        CompositionTypeEnum,
        ComponentTypeEnum,
        SocketDefaultValue,
    >[] = []
    __outputs: Socket<
        string,
        CompositionTypeEnum,
        ComponentTypeEnum,
        SocketDefaultValue,
    >[] = []
    __shaderFunctionName: string
    __shaderNodeUid: number
    _tags: RnTags = {}

    Collection of tags associated with this object

    _shaderNodes: AbstractShaderNode[] = []
    currentMaxObjectCount: number = 0

    Current maximum object count for UID generation

    InvalidObjectUID: -1

    Invalid object UID constant

    Accessors

    • get inputConnections(): ShaderNodeInputConnectionType[]

      Gets all input connections for this node.

      Returns ShaderNodeInputConnectionType[]

      An array of input connection configurations

    • get objectUID(): number

      Gets the unique object identifier

      Returns number

      The object's UID

    • get uniqueName(): string

      Gets the unique name of this object

      Returns string

      The unique name string

    Methods

    • Internal

      Copies tag data from another RnObject instance to this object

      Parameters

      • rnObject: RnObject

        The source RnObject to copy tags from

      Returns void

    • Adds an input connection to this node from another shader node. This establishes a data flow connection between the output of one node and the input of this node.

      Type Parameters

      Parameters

      • inputShaderNode: AbstractShaderNode

        The source shader node to connect from

      • outputSocketOfInput: Socket<string, N, T, SocketDefaultValue>

        The output socket of the source node

      • inputSocketOfThis: Socket<string, N, T, SocketDefaultValue>

        The input socket of this node to connect to

      Returns void

    • Finds and returns an input socket by name.

      Parameters

      • name: string

        The name of the input socket to find

      Returns
          | Socket<
              string,
              CompositionTypeEnum,
              ComponentTypeEnum,
              SocketDefaultValue,
          >
          | undefined

      The input socket if found, undefined otherwise

    • Finds and returns an output socket by name.

      Parameters

      • name: string

        The name of the output socket to find

      Returns
          | Socket<
              string,
              CompositionTypeEnum,
              ComponentTypeEnum,
              SocketDefaultValue,
          >
          | undefined

      The output socket if found, undefined otherwise

    • Retrieves the shader code for the specified shader stage. Returns appropriate code based on the current rendering approach (WebGL/WebGPU).

      Parameters

      • engine: Engine

        The engine instance

      • shaderStage: EnumIO

        The shader stage (vertex or fragment) to get code for

      Returns string

      The shader code string for the specified stage

    • Gets the derivative shader function name for this node. By default, returns the same as the regular function name.

      Parameters

      Returns string

      The derivative function name used in shader code

    • Retrieves the output socket of this constant variable node.

      Returns Socket<string, CompositionTypeEnum, ComponentTypeEnum, SocketDefaultValue>

      The output socket that can be connected to other shader nodes

      This constant variable node has exactly one output socket that provides the constant value to the shader graph. The socket's type matches the composition and component types specified during construction.

    • Retrieves a complete tag object (name and value) for the specified tag name

      Parameters

      • tagName: string

        The name of the tag to retrieve

      Returns Tag

      A Tag object containing the name and value

    • Retrieves the value associated with a specific tag name

      Parameters

      • tagName: string

        The name of the tag whose value to retrieve

      Returns any

      The tag value, or undefined if the tag doesn't exist

    • Checks whether this object has a tag with the specified name

      Parameters

      • tagName: string

        The name of the tag to check for

      Returns boolean

      True if the tag exists (value is not null/undefined), false otherwise

    • Generates a function call statement for this shader node in the final shader code. This method constructs the appropriate function call syntax with proper parameter passing for both WebGL and WebGPU rendering approaches.

      Parameters

      • engine: Engine

        The engine instance

      • i: number

        The index of this node in the execution order

      • shaderNode: AbstractShaderNode

        The shader node to generate the call for

      • functionName: string

        The name of the function to call

      • varInputNames: string[][]

        Array of input variable names for each node

      • varOutputNames: string[][]

        Array of output variable names for each node

      Returns string

      The generated function call statement string

    • Checks if this object has a tag with the specified name and value

      Parameters

      • tagName: string

        The tag name to match

      • tagValue: string

        The tag value to match

      Returns boolean

      True if the object has a matching tag, false otherwise

    • Checks if this object has all the specified tags with exactly matching values

      Parameters

      • tags: RnTags

        Object containing tag names as keys and expected values

      Returns boolean

      True if all specified tags exist with matching values, false otherwise

    • Checks if the object's combined tag string contains all the provided search strings. This allows for flexible searching within tag names and values.

      Parameters

      • stringArray: string[]

        Array of strings that must all be present in the combined tag string

      Returns boolean

      True if all strings are found in the combined tag string, false otherwise

    • Removes a tag from this object

      Parameters

      • tagName: string

        The name of the tag to remove

      Returns void

    • Sets the default input value for this constant Vec4 shader node. This method updates the underlying constant value used by the shader, which will be injected into the generated shader code as a constant.

      Parameters

      • value: IVector4

        The 4D vector value to set as the constant input value. This should be an object implementing IVector4 interface, typically a Vector4 instance with x, y, z, and w components.

      Returns void

      const node = new ConstantVector4VariableShaderNode(ComponentType.Float);
      // Set RGBA color value
      node.setDefaultInputValue(Vector4.fromCopy4(1.0, 0.0, 0.0, 1.0)); // Red color

      // Set homogeneous coordinate
      node.setDefaultInputValue(Vector4.fromCopy4(10.0, 5.0, 2.0, 1.0)); // Position in homogeneous coords
    • Sets the shader stage for this node (Neutral, Vertex, or Fragment).

      Parameters

      • stage: ShaderStage

        The shader stage to assign to this node

      Returns void

    • Attempts to set a tag on this object. If the tag already exists, it will be replaced.

      Parameters

      • tag: Tag

        The tag object containing the name and value to set

      Returns boolean

      True if the tag was successfully set, false if the tag name contains invalid characters

    • Attempts to set a unique name for this object

      Parameters

      • name: string

        The desired unique name

      • toAddNameIfConflict: boolean

        If true, appends UID to make name unique when conflicts occur; if false, fails on conflict

      Returns boolean

      True if the name was successfully set, false if there was a conflict and toAddNameIfConflict was false

    • Unregisters this object from all tracking collections. Should be called when the object is being destroyed.

      Returns void

    • Validates that a tag string contains only allowed characters (alphanumeric and underscore)

      Parameters

      • val: string

        The string to validate

      Returns boolean

      True if the string contains only valid characters, false if it contains invalid characters

    • Internal

      Resets all static object tracking data. Used primarily for testing.

      Returns void

    • Retrieves an RnObject instance by its unique identifier

      Parameters

      • objectUid: number

        The unique identifier of the object to retrieve

      Returns RnObject | undefined

      The RnObject instance or undefined if not found or garbage collected

    • Retrieves an RnObject instance by its unique name

      Parameters

      • uniqueName: string

        The unique name of the object to retrieve

      Returns RnObject | undefined

      The RnObject instance or undefined if not found or garbage collected

    • Searches for the first object that has a specific tag with the given value

      Parameters

      • tag: string

        The tag name to search for

      • value: string

        The tag value to match

      Returns WeakRef<RnObject> | undefined

      WeakRef to the first matching object, or undefined if not found