Solo datum fields for each material type (engine-specific, not shared across engines)
Gets the current state version for materials in this repository. This version is incremented whenever any material's state changes.
The current state version number
InternalIncrements the state version counter. Called when a material's state changes.
InternalInvalidates all shader programs for all registered materials. This method is typically called when global shader settings change and all materials need to recompile their shaders.
InternalInvalidates shader programs only for materials that are affected by morph changes. Affected materials are those that support morphing and are currently used by primitives with morph targets.
Creates a new material instance of the specified type. The material type must be registered before calling this method. This method handles instance counting and initialization.
The name of the registered material type
The material content definition for this specific instance
A new Material instance with proper initialization
Forcibly registers a material type, overwriting any existing registration. This method bypasses the duplicate check and always performs the registration. Use with caution as it can replace existing material type definitions.
The unique name identifier for the material type
The material content definition containing shader semantics and properties
The number of materials per buffer view
Always returns true as the registration is forced
Gets all currently active material instances from the repository. Returns an array of WeakRef objects that may contain undefined values if materials have been garbage collected.
Array of WeakRef objects pointing to all registered materials
Gets the memory location offset for a specific property of a material type. The offset is calculated in 16-byte aligned units for GPU buffer access. This is used for efficient GPU memory access in shaders.
The engine instance
The name of the material type
The shader semantic name of the property
The byte offset divided by 16 (IndexOf16Bytes) for the property location
Retrieves a material instance by its unique identifier. Returns undefined if the material doesn't exist or has been garbage collected.
The unique identifier of the material to retrieve
The material instance if found and still alive, undefined otherwise
Determines if a new material node is compatible with an existing material. Compatibility is checked by comparing shader semantics information arrays. Materials are compatible if they have identical shader semantic structures.
The existing material to compare against
The new material node to check for compatibility
True if the materials are compatible, false otherwise
Checks if a material type is already registered in the repository.
The name of the material type to check
True if the material type is registered, false otherwise
Registers a new material type with the repository. This method creates the necessary data structures and allocates memory for the material type. If the material type is already registered, the registration will be skipped.
The unique name identifier for the material type
The material content definition containing shader semantics and properties
The number of materials per buffer view
True if the material type was successfully registered, false if it was already registered
Repository class for managing material types and instances. Handles registration, creation, and lifecycle management of materials.