rhodonite
    Preparing search index...

    Class CustomMaterialContent

    Custom material content class that extends AbstractMaterialContent to provide custom shader handling and rendering capabilities with support for IBL (Image-Based Lighting), morphing, skinning, and various shader semantics.

    Hierarchy (View Summary)

    Index
    • Creates a new CustomMaterialContent instance with custom shaders and configuration.

      Parameters

      • engine: Engine
      • params: {
            additionalShaderSemanticInfo: ShaderSemanticsInfo[];
            definitions?: string[];
            isLighting: boolean;
            isMorphing: boolean;
            isSkinning: boolean;
            name: string;
            pixelShader?: ShaderityObject;
            pixelShaderWebGpu?: ShaderityObject;
            vertexShader?: ShaderityObject;
            vertexShaderWebGpu?: ShaderityObject;
        }

        Configuration object for the custom material

        • additionalShaderSemanticInfo: ShaderSemanticsInfo[]

          Array of additional shader semantic information

        • Optionaldefinitions?: string[]

          Optional array of preprocessor definitions for shaders

        • isLighting: boolean

          Whether this material uses lighting calculations

        • isMorphing: boolean

          Whether this material supports vertex morphing/blending

        • isSkinning: boolean

          Whether this material supports skeletal animation skinning

        • name: string

          The name identifier for this material content

        • OptionalpixelShader?: ShaderityObject

          Optional pixel/fragment shader object for WebGL rendering

        • OptionalpixelShaderWebGpu?: ShaderityObject

          Optional pixel/fragment shader object for WebGPU rendering

        • OptionalvertexShader?: ShaderityObject

          Optional vertex shader object for WebGL rendering

        • OptionalvertexShaderWebGpu?: ShaderityObject

          Optional vertex shader object for WebGPU rendering

      Returns CustomMaterialContent

    __definitions: string = ''
    __materialName: string
    __semantics: ShaderSemanticsInfo[] = []
    _engine?: Engine

    The engine instance this material content is associated with

    _tags: RnTags = {}

    Collection of tags associated with this object

    shaderType: EnumIO = ShaderType.VertexAndPixelShader
    __tmp_vector2: MutableVector2 = ...
    __tmp_vector4: MutableVector4 = ...
    currentMaxObjectCount: number = 0

    Current maximum object count for UID generation

    InvalidObjectUID: -1

    Invalid object UID constant

    materialNodes: AbstractMaterialContent[] = []
    • get _semanticsInfoArray(): ShaderSemanticsInfo[]

      Gets the shader semantics information array for this material.

      Returns ShaderSemanticsInfo[]

      Array of shader semantics information

    • get isLighting(): boolean

      Checks if this material supports lighting calculations.

      Returns boolean

      True if lighting is enabled

    • get isMorphing(): boolean

      Checks if this material supports morph target animation.

      Returns boolean

      True if morphing is enabled

    • get isMultiDrawCompatible(): boolean

      Whether draws of this material can be batched into one multi-draw call. Material contents that set per-primitive uniforms in the per-primitive hook must override this to false.

      Returns boolean

    • get isSkinning(): boolean

      Checks if this material supports skeletal animation.

      Returns boolean

      True if skinning is enabled

    • get objectUID(): number

      Gets the unique object identifier

      Returns number

      The object's UID

    • get pixelShaderityObject(): ShaderityObject | undefined

      Gets the pixel shader object associated with this material.

      Returns ShaderityObject | undefined

      The pixel shader object or undefined if not set

    • get uniqueName(): string

      Gets the unique name of this object

      Returns string

      The unique name string

    • get vertexShaderityObject(): ShaderityObject | undefined

      Gets the vertex shader object associated with this material.

      Returns ShaderityObject | undefined

      The vertex shader object or undefined if not set

    • Internal

      Copies tag data from another RnObject instance to this object

      Parameters

      • rnObject: RnObject

        The source RnObject to copy tags from

      Returns void

    • Sets internal material parameters for WebGL rendering on a per-material basis. Configures world/view/projection matrices, lighting, skinning, and IBL parameters.

      Parameters

      • params: {
            args: RenderingArgWebGL;
            engine: Engine;
            firstTime: boolean;
            material: Material;
            shaderProgram: WebGLProgram;
        }

        Parameters object

        • args: RenderingArgWebGL

          WebGL rendering arguments containing matrices, entities, and rendering context

        • engine: Engine
        • firstTime: boolean

          Whether this is the first time setting up this material

        • material: Material

          The material instance to configure

        • shaderProgram: WebGLProgram

          The WebGL shader program to use

      Returns void

    • Sets internal parameters for WebGL rendering on a per-primitive basis. Handles morph target/blend shape information for vertex animation.

      Parameters

      • params: { args: RenderingArgWebGL; shaderProgram: WebGLProgram }

        Parameters object

        • args: RenderingArgWebGL

          WebGL rendering arguments containing entity, mesh, and primitive data

        • shaderProgram: WebGLProgram

          The WebGL shader program to use

      Returns void

    • Sets internal parameters for WebGL rendering on a per-shader-program basis. Primarily handles IBL environment texture setup including diffuse, specular, and sheen cube maps.

      Parameters

      • params: {
            args: RenderingArgWebGL;
            engine: Engine;
            material: Material;
            shaderProgram: WebGLProgram;
        }

        Parameters object

        • args: RenderingArgWebGL

          WebGL rendering arguments containing cube map textures and rendering context

        • engine: Engine
        • material: Material

          The material instance to configure

        • shaderProgram: WebGLProgram

          The WebGL shader program to use

      Returns void

    • Performs shader reflection to extract semantics information from vertex and pixel shaders.

      Parameters

      • engine: Engine
      • vertexShader: ShaderityObject

        The vertex shader object for WebGL

      • pixelShader: ShaderityObject

        The pixel shader object for WebGL

      • vertexShaderWebGpu: ShaderityObject

        The vertex shader object for WebGPU

      • pixelShaderWebGpu: ShaderityObject

        The pixel shader object for WebGPU

      • definitions: string[]

        Array of shader definitions

      Returns ShaderSemanticsInfo[]

      Array of shader semantics information

    • Gets the base material name (e.g., "PbrUber", "ClassicUber"). Double trailing underscores are removed for cleaner display.

      Returns string

      The base material name string

    • Gets the shader definition string for this material. This method should be overridden by derived classes to provide specific definitions.

      Returns string

      Empty string by default

    • Gets the shader definitions string for this material.

      Returns string

      The definitions string

    • Gets the material semantics variant name for this material. This is the full identifier combining material name and variation identifier.

      Returns string

      The unique variant name string

    • Gets the material variation identifier (without the base material name). This represents only the parameter variation part of the material type.

      Returns string

      The variation identifier string

    • 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 unique variant name for this material based on its shader semantics. This name is used to differentiate materials with different semantic configurations.

      Returns void

    • 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 billboard flag uniform in the shader.

      Parameters

      • shaderProgram: WebGLProgram

        The WebGL shader program

      • isBillboard: boolean

        Whether the object should be rendered as a billboard

      Returns void

    • Sets the visibility flag uniform in the shader.

      Parameters

      • shaderProgram: WebGLProgram

        The WebGL shader program

      • isVisible: boolean

        Whether the object should be rendered

      Returns void

    • Sets the normal transformation matrix uniform in the shader.

      Parameters

      • shaderProgram: WebGLProgram

        The WebGL shader program

      • normalMatrix: IMatrix33

        The normal transformation matrix

      Returns void

    • Sets the pixel shader object for this material.

      Parameters

      • OptionalpixelShaderityObject: ShaderityObject

        The pixel shader object to set

      • Optionalengine: Engine

        Optional engine instance (uses this._engine if not provided)

      Returns void

    • Sets the projection matrix uniform in the shader.

      Parameters

      • shaderProgram: WebGLProgram

        The WebGL shader program

      • cameraComponent: CameraComponent

        The camera component

      • isVr: boolean

        Whether rendering in VR mode

      • displayIdx: number

        The display index for VR rendering

      Returns void

    • Sets up basic rendering information including matrices, camera, and lighting.

      Parameters

      Returns void

    • Sets the vertex shader object for this material.

      Parameters

      • OptionalvertexShaderityObject: ShaderityObject

        The vertex shader object to set

      • Optionalengine: Engine

        Optional engine instance (uses this._engine if not provided)

      Returns void

    • Sets view-related uniforms including view matrix and camera position.

      Parameters

      • shaderProgram: WebGLProgram

        The WebGL shader program

      • cameraComponent: CameraComponent

        The camera component

      • isVr: boolean

        Whether rendering in VR mode

      • displayIdx: number

        The display index for VR rendering

      Returns void

    • Sets the world transformation matrix uniform in the shader.

      Parameters

      • shaderProgram: WebGLProgram

        The WebGL shader program

      • worldMatrix: Matrix44

        The world transformation matrix

      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

      Cleans up static caches for a specific Engine instance. This should be called when the Engine is destroyed to prevent stale references.

      Parameters

      • engine: Engine

        The Engine instance being destroyed Called from Engine.destroy()

      Returns void

    • 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