rhodonite
    Preparing search index...

    Class NormalMatrixShaderNode

    A shader node that provides access to the normal matrix for transforming normal vectors from local space to world space.

    The normal matrix is derived from the inverse transpose of the upper-left 3x3 portion of the model matrix (world matrix). It ensures that normal vectors remain perpendicular to surfaces after non-uniform scaling transformations. This matrix is essential for proper lighting calculations in 3D rendering.

    The node operates in the vertex shader stage and supports both WebGL (GLSL) and WebGPU (WGSL) rendering backends.

    const normalMatrixNode = new NormalMatrixShaderNode();
    // Connect to other shader nodes that require normal transformation
    const normalMatrixOutput = normalMatrixNode.getOutput('outValue');

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new NormalMatrixShaderNode instance.

      Initializes the shader node with vertex stage shader code for both GLSL and WGSL, and sets up a Mat3 float output socket for the normal transformation matrix. The output matrix can be used to transform normal vectors from local space to world space while preserving their geometric properties under non-uniform transformations.

      The node automatically retrieves the normal matrix from the rendering system's uniform buffer based on the current instance ID.

      Returns NormalMatrixShaderNode

    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

    • 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

    • 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

    • 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

    • 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