rhodonite
    Preparing search index...

    Class Random_HashPRNGShaderNode

    A shader node that outputs a random number between 0 and 1 using Hash-based PRNG. This node outputs a random number between 0 and 1. The node optimizes random_f32() calls based on which outputs are connected.

    Output sockets and their required random_f32() calls:

    • outX: 1 call
    • outY, outXY: 2 calls
    • outZ, outXYZ, outXYZ1: 3 calls
    • outW, outZW, outXYZW: 4 calls

    Hierarchy (View Summary)

    Index
    __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

    • 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 shaderFunctionName(): string

      Gets the shader function name for this node.

      Returns string

      The function name used in shader code

    • get shaderNodeUid(): number

      Gets the unique identifier for this shader node.

      Returns number

      The unique node identifier

    • get uniqueName(): string

      Gets the unique name of this object

      Returns string

      The unique name string

    • 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

    • Gets the current shader stage of this node.

      Returns ShaderStage

      The current shader stage

    • 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 shader code for calling the random function. Analyzes connected outputs and selects the optimal function variant to minimize random_f32() calls.

      Parameters

      • engine: Engine

        The engine instance

      • i: number

        The index of the current shader node call

      • _shaderNode: AbstractShaderNode

        The shader node instance (unused)

      • _functionName: string

        The base function name (overridden based on analysis)

      • varInputNames: string[][]

        Array of input variable names for each call

      • varOutputNames: string[][]

        Array of output variable names for each call

      Returns string

      The generated shader code string for the function call

    • 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 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