Creates a new Material instance.
The material type ID
The unique material ID
The material serial ID within the material type
The name of the material type
The abstract material content associated with this material
Collection of tags associated with this object
Static
Readonly
InvalidInvalid object UID constant
Static
_soloStatic
currentCurrent maximum object count for UID generation
Gets the current alpha mode of the material.
The alpha mode
Sets the alpha mode of the material. This will invalidate shaders and recalculate the fingerprint.
The alpha mode to set
Gets whether alpha-to-coverage is enabled for this material.
True if alpha-to-coverage is enabled, false otherwise
Sets whether alpha-to-coverage is enabled for this material. NOTE: To apply alpha-to-coverage, the output alpha value must not be fixed to a constant value. However, some shaders in Rhodonite fix the output alpha value to 1 by setAlphaIfNotInAlphaBlendMode. The shader needs to be improved to properly use alpha-to-coverage.
Whether to apply alpha-to-coverage to this material
Gets the blend equation mode for RGB channels.
The blend equation mode
Gets the blend equation mode for the alpha channel.
The alpha blend equation mode
Gets the destination blend factor for the alpha channel.
The alpha destination blend factor
Gets the source blend factor for the alpha channel.
The alpha source blend factor
Gets the destination blend factor for RGB channels.
The destination blend factor
Gets the source blend factor for RGB channels.
The source blend factor
Gets an array of all field information for this material.
Array of shader semantics information
Checks if this material supports lighting.
True if lighting is supported, false otherwise
Checks if this material supports morphing.
True if morphing is supported, false otherwise
Checks if this material supports skinning.
True if skinning is supported, false otherwise
Gets the material serial ID within the material type.
The material SID
Gets the material type ID.
The material type ID
Gets the material type name.
The material type name
Gets the unique material ID.
The material UID
Gets the unique object identifier
The object's UID
Gets the current state version of this material. This is incremented whenever the material's state changes.
The state version number
Gets the unique name of this object
The unique name string
Static
stateGets the global state version for all materials. This is incremented whenever any material's state changes.
The global state version number
Internal
Adds a primitive to the list of primitives that belong to this material. Called from Primitive class only
The primitive to add
Internal
Copies tag data from another RnObject instance to this object
The source RnObject to copy tags from
Internal
Creates a shader program using updated shader source code. Called from WebGLStrategyDataTexture and WebGLStrategyUniform
The updated shader source code
The primitive to create the program for
Optional
onError: ((message: string) => void)Optional error callback function
A tuple containing the program UID and whether it's a new program
Internal
Creates a WebGL shader program for this material and the given primitive. Called from WebGLStrategyDataTexture and WebGLStrategyUniform
Vertex shader method definitions for uniforms
Function to set shader properties
The primitive to create the program for
Whether to create a WebGL2 program
A tuple containing the program UID and whether it's a new program
Creates a WebGPU shader program for this material and the given primitive.
The primitive to create the program for
Vertex shader method definitions
Function to set shader properties
Internal
Gets shader property strings for vertex and pixel shaders.
Function to set shader properties
Whether to generate WebGL2-compatible properties
Object containing vertex and pixel property strings
Sets internal setting parameters to GPU for WebGPU rendering.
Object containing material and rendering arguments
Internal
Sets parameters to GPU for WebGL rendering per material. Called from WebGLStrategyDataTexture and WebGLStrategyUniform only
Object containing rendering parameters
Sets parameters to GPU for WebGL rendering per primitive.
Object containing rendering parameters
Sets parameters to GPU for WebGL rendering per shader program.
Object containing rendering parameters
Sets parameters to GPU for WebGL rendering without internal settings.
Object containing rendering parameters
Internal
Sets up uniform locations for material nodes in the shader program. Called from WebGLStrategyDataTexture and WebGLStrategyUniform only
Whether to operate in uniform-only mode
The primitive to set up uniforms for
Internal
Sets up additional uniform locations in the shader program. Called by WebGLStrategyDataTexture and WebGLStrategyUniform only
Array of shader semantics to set up
Whether to operate in uniform-only mode
The primitive to set up uniforms for
Internal
Sets up basic uniform locations in the shader program. Called by WebGLStrategyDataTexture and WebGLStrategyUniform only
The primitive to set up uniforms for
Gets the shader program UID for the given primitive.
The primitive to get the shader program UID for
The shader program UID or -1 if not found
Checks if the shader program is ready for the given primitive.
The primitive to check shader readiness for
True if the shader program is ready, false otherwise
Checks if this object has all the specified tags with exactly matching values
Object containing tag names as keys and expected values
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.
Array of strings that must all be present in the combined tag string
True if all strings are found in the combined tag string, false otherwise
Sets the blend equation mode for blending operations. This method only works if the alpha mode is set to blend.
The blend equation mode (e.g., gl.FUNC_ADD)
Optional
blendEquationModeAlpha: BlendEnumOptional separate blend equation mode for alpha channel
Sets blend function factors for both RGB and alpha channels. This method only works if the alpha mode is set to blend.
Source blend factor
Destination blend factor
Sets separate blend function factors for RGB and alpha channels. This method only works if the alpha mode is set to blend.
Source blend factor for RGB
Destination blend factor for RGB
Source blend factor for alpha
Destination blend factor for alpha
Sets a parameter value for the specified shader semantic. The parameter can be a static value or an animated value.
The shader semantic name to set the parameter for
The value to set (can be static or animated)
Sets a texture parameter for the specified shader semantic. If the texture has transparency, the material's alpha mode may be automatically set to Blend.
The shader semantic name for the texture
The texture to assign
Optional
sampler: SamplerOptional sampler to use with the texture. If not provided, uses default sampler
Sets a texture parameter from a Promise that resolves to a texture. This is useful for asynchronous texture loading.
The shader semantic name for the texture
A Promise that resolves to the texture
Attempts to set a tag on this object. If the tag already exists, it will be replaced.
The tag object containing the name and value to set
True if the tag was successfully set, false if the tag name contains invalid characters
Attempts to set a unique name for this object
The desired unique name
If true, appends UID to make name unique when conflicts occur; if false, fails on conflict
True if the name was successfully set, false if there was a conflict and toAddNameIfConflict was false
Static
_resetStatic
getStatic
getStatic
searchSearches for the first object that has a specific tag with the given value
The tag name to search for
The tag value to match
WeakRef to the first matching object, or undefined if not found
The Material class represents a material definition for 3D rendering in the Rhodonite engine.
A material defines how a 3D object's surface appears when rendered, including:
Key Features:
Material Types:
Materials are categorized by type (e.g., PBR, Phong, Custom) and can support:
Usage Examples:
State Management:
The material maintains internal state versioning for efficient change detection and shader program invalidation when parameters change.
See