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
StaticcurrentCurrent maximum object count for UID generation
Static ReadonlyInvalidInvalid object UID constant
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 base material name without variation identifier. This is the human-readable material type name (e.g., "PbrUber", "ClassicUber").
The base material name
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 is a node-based custom shader material.
True if this is a node-based material (has shaderNodeJson set)
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. This includes the full type name with variation identifier for internal use.
The material type name
Gets the unique material ID.
The material UID
Gets the material variation identifier. This represents the parameter variation part of the material type.
The variation identifier string
Gets the unique object identifier
The object's UID
Gets the shader node file name for export. This is used to specify the .rmn file name in the RHODONITE_materials_node extension.
The shader node file name, or undefined if not set
Sets the shader node file name for export.
The .rmn file name to use in the RHODONITE_materials_node extension
Gets the shader node JSON data for node-based materials. This is used by RHODONITE_materials_node extension.
The shader node JSON data, or undefined if not a node-based material
Sets the shader node JSON data for node-based materials. This marks the material as a node-based custom shader material.
The shader node JSON data
Gets the uniform values for node-based materials.
The uniform values object, or undefined if not set
Sets the uniform values for node-based materials.
The uniform values object
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
InternalAdds a primitive to the list of primitives that belong to this material. Called from Primitive class only
The primitive to add
InternalCopies tag data from another RnObject instance to this object
The source RnObject to copy tags from
InternalCreates 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
OptionalonError: (message: string) => voidOptional error callback function
A tuple containing the program UID and whether it's a new program
InternalCreates a WebGL shader program for this material and the given primitive. Called from WebGLStrategyDataTexture and WebGLStrategyUniform
method definitions for component data access for vertex shader
method definitions for component data access for pixel shader
Function to set shader properties of global data repository
Function to set shader properties of material
Function to get the morphed position
The primitive to create the program for
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
method definitions for component data access for vertex shader
method definitions for component data access for pixel shader
Function to set shader properties of global data repository
Function to set shader properties of material
Function to get the morphed position
InternalGets the current fingerprint of the material.
The material's fingerprint string
InternalGets shader property strings for vertex and pixel shaders.
Object containing vertex and pixel property strings
Checks if a value is an animated value (implements IAnimatedValue).
The value to check
True if the value is an animated value, false otherwise
Sets internal setting parameters to GPU for WebGPU rendering.
Object containing material and rendering arguments
InternalSets 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
InternalSets 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
InternalSets 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
InternalSets up basic uniform locations in the shader program. Called by WebGLStrategyDataTexture and WebGLStrategyUniform only
The primitive to set up uniforms for
Adds a shader define directive that will be included in shader compilation. This will invalidate existing shaders and require recompilation.
The define directive to add (e.g., "USE_NORMAL_MAPPING")
InternalCalculates and updates the material's fingerprint based on current state. The fingerprint is used for shader program caching and state comparison.
Gets all primitives that belong to this material.
A Map of primitive UIDs to Primitive objects
Gets the parameter value for the specified shader semantic.
The shader semantic name to get the parameter for
The parameter value or undefined if not found
Gets all shader define directives currently set on this material.
A Set containing all shader defines
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
Retrieves a complete tag object (name and value) for the specified tag name
The name of the tag to retrieve
A Tag object containing the name and value
Retrieves the value associated with a specific tag name
The name of the tag whose value to retrieve
The tag value, or undefined if the tag doesn't exist
Gets the texture parameter for the specified shader semantic.
The shader semantic name to get the texture for
The texture parameter array or undefined if not found
Checks whether this object has a tag with the specified name
The name of the tag to check for
True if the tag exists (value is not null/undefined), false otherwise
Checks if the material is in blend mode.
True if alpha mode is Blend, false otherwise
Checks if the material is either in blend mode or translucent.
True if in blend mode or translucent, false otherwise
Checks if the material is in mask mode.
True if alpha mode is Mask, false otherwise
Checks if the material is in opaque mode.
True if alpha mode is Opaque, false otherwise
Checks if a specific shader define directive is set on this material.
The define directive to check for
True if the define is set, false otherwise
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 the material is translucent but not in blend mode.
True if alpha mode is Opaque or Mask and the material is translucent
Invalidates all shader programs associated with this material. This forces shader recompilation on the next render.
Checks if this object has a tag with the specified name and value
The tag name to match
The tag value to match
True if the object has a matching tag, 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
Removes a shader define directive from the material. This will invalidate existing shaders and require recompilation.
The define directive to remove
Removes a tag from this object
The name of the tag to remove
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)
OptionalblendEquationModeAlpha: 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
Optionalsampler: 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
Unregisters this object from all tracking collections. Should be called when the object is being destroyed.
Validates that a tag string contains only allowed characters (alphanumeric and underscore)
The string to validate
True if the string contains only valid characters, false if it contains invalid characters
Static_InternalResets all static object tracking data. Used primarily for testing.
StaticgetRetrieves an RnObject instance by its unique identifier
The unique identifier of the object to retrieve
The RnObject instance or undefined if not found or garbage collected
StaticgetRetrieves an RnObject instance by its unique name
The unique name of the object to retrieve
The RnObject instance or undefined if not found or garbage collected
StaticsearchSearches 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