MaterialAsset
MaterialAsset wraps a Material with UUID references to texture assets. Load() parses a .mdfmat MDF file. CreateGPU() resolves texture UUIDs via AssetManager.
- Module
- AssetSystem
- Header
#include "AssetSystem/Assets/MaterialAsset.h"- Namespace
Mowo
Type aliases
| Alias | Description |
|---|---|
using FGraphShaderReadyCallback = void (*)(const Ref<Material>& material) | Called when a graph shader finishes compiling during CreateGPU, so the pipeline compile can start before a mesh wearing the material reaches a viewport. The scene renderer installs it: the asset layer sits below the renderer and cannot call it by name. |
Constructors
| Signature | Name | Description |
|---|---|---|
MaterialAsset() | MaterialAsset | |
~MaterialAsset() override | ~MaterialAsset |
Public functions
| Returns | Name | Description |
|---|---|---|
bool | SetScalarParameter | R4: runtime material parameters. |
bool | SetVectorParameter | |
const std::vector<MaterialGraph::FGraphParam>& | GetGraphParameters | |
uint32_t | GetGraphParamLanes | |
bool | HasStaticSwitchOverride | Static-switch overrides: the permutation this material selects from its root graph. |
bool | GetStaticSwitchOverride | |
void | SetStaticSwitchOverride | |
void | ClearStaticSwitchOverride | |
const MaterialGraph::FStaticSwitchSet& | GetStaticSwitchOverrides | |
bool | HasGraphParameterOverride | |
bool | GetGraphParameterOverride | |
void | SetGraphParameterOverride | |
void | ClearGraphParameterOverride | |
const std::vector<FGraphParameterOverride>& | GetGraphParameterOverrides | |
bool | EffectiveGraphParameter | The value a named graph parameter resolves to for this material: the root graph's default with every override from the root down applied. |
const MaterialGraph* | CompiledGraph | The graph the compiled shader comes from: this material's own, or the root's for an instance (walked through the asset manager). |
MaterialGraph::FStaticSwitchSet | EffectiveStaticSwitches | The switch set this material compiles at: the root graph's defaults with every override from the root down to this material applied in order. |
void | SetGraphShaderReadyCallback | |
FGraphShaderReadyCallback | GetGraphShaderReadyCallback | |
bool | Load | Asset interface |
void | Unload | |
bool | CreateGPU | |
void | DestroyGPU | |
void | CollectDependencyIDs | Parent + textures |
void | CollectDependencyPaths | The .mphysmat the surface names |
Material* | GetMaterial | The asset owns the material through a Ref and keeps the SAME object across a reimport (Unload + Load reset it in place), so a raw view taken from here stays valid for as long as the asset lives. |
const Ref<Material>& | GetMaterialRef | |
UUID | GetAlbedoTextureID | Texture UUID references (set during Load from .mdfmat) |
UUID | GetNormalTextureID | |
UUID | GetMetallicTextureID | |
UUID | GetRoughnessTextureID | |
UUID | GetAOTextureID | |
UUID | GetEmissiveTextureID | |
UUID | GetDetailAlbedoTextureID | |
UUID | GetDetailNormalTextureID | |
UUID | GetMaskMapTextureID | |
UUID | GetHeightTextureID | |
UUID | GetOpacityTextureID | |
void | SetAlbedoTextureID | |
void | SetNormalTextureID | |
void | SetMetallicTextureID | |
void | SetRoughnessTextureID | |
void | SetAOTextureID | |
void | SetEmissiveTextureID | |
void | SetDetailAlbedoTextureID | |
void | SetDetailNormalTextureID | |
void | SetMaskMapTextureID | |
void | SetHeightTextureID | |
void | SetOpacityTextureID | |
UUID | GetParentMaterialID | Material instancing |
void | SetParentMaterialID | |
bool | IsInstance | |
bool | ResolveTextures | Try to resolve texture UUIDs to GPU textures (can be called repeatedly until all resolve) Returns true if all textures are resolved. |
bool | HasUnresolvedTextures | |
bool | SaveToFile | Save material to a .mdfmat MDF file |
bool | HasGraph | Node graph — optional authoring layer. |
MaterialGraph& | GetGraph | |
const MaterialGraph& | GetGraph | |
void | SetGraph | |
void | ClearGraph |
Function details
MaterialAsset
MaterialAsset()~MaterialAsset
~MaterialAsset() overrideSetScalarParameter
bool SetScalarParameter(const std::string& name, float value)R4: runtime material parameters. A NAMED Scalar/Vector param node in the graph compiles to a push-constant lane read; these setters write the live value by name (no shader recompile, no pipeline churn). Unknown names return false. Values are per-ASSET (every draw using this material sees the change) and are not serialized — defaults come from the graph on load.
SetVectorParameter
bool SetVectorParameter(const std::string& name, const Vec4& value)GetGraphParameters
const std::vector<MaterialGraph::FGraphParam>& GetGraphParameters() constGetGraphParamLanes
uint32_t GetGraphParamLanes() constHasStaticSwitchOverride
bool HasStaticSwitchOverride(const std::string& name) constStatic-switch overrides: the permutation this material selects from its root graph. A root's switches default from the graph's StaticBool nodes; an instance carries only the names it overrides (absent = inherited), and its compiled shader is the parent graph emitted at the resulting switch set. Serialized as a StaticSwitches section of the .mdfmat.
GetStaticSwitchOverride
bool GetStaticSwitchOverride(const std::string& name, bool& outValue) constSetStaticSwitchOverride
void SetStaticSwitchOverride(const std::string& name, bool value)ClearStaticSwitchOverride
void ClearStaticSwitchOverride(const std::string& name)GetStaticSwitchOverrides
const MaterialGraph::FStaticSwitchSet& GetStaticSwitchOverrides() constHasGraphParameterOverride
bool HasGraphParameterOverride(const std::string& name) constGetGraphParameterOverride
bool GetGraphParameterOverride(const std::string& name, Vec4& outValue) constSetGraphParameterOverride
void SetGraphParameterOverride(const std::string& name, const Vec4& value)ClearGraphParameterOverride
void ClearGraphParameterOverride(const std::string& name)GetGraphParameterOverrides
const std::vector<FGraphParameterOverride>& GetGraphParameterOverrides() constEffectiveGraphParameter
bool EffectiveGraphParameter(const std::string& name, Vec4& outValue) constThe value a named graph parameter resolves to for this material: the root graph's default with every override from the root down applied. False when the root graph declares no parameter of that name.
CompiledGraph
const MaterialGraph* CompiledGraph() constThe graph the compiled shader comes from: this material's own, or the root's for an instance (walked through the asset manager). Null when there is none.
EffectiveStaticSwitches
MaterialGraph::FStaticSwitchSet EffectiveStaticSwitches() constThe switch set this material compiles at: the root graph's defaults with every override from the root down to this material applied in order.
SetGraphShaderReadyCallback
static void SetGraphShaderReadyCallback(FGraphShaderReadyCallback callback)GetGraphShaderReadyCallback
static FGraphShaderReadyCallback GetGraphShaderReadyCallback()Load
bool Load(const std::string& path) overrideAsset interface
Unload
void Unload() overrideCreateGPU
bool CreateGPU(const GPUContext& ctx) overrideDestroyGPU
void DestroyGPU() overrideCollectDependencyIDs
void CollectDependencyIDs(std::vector<UUID>& out) const overrideParent + textures
CollectDependencyPaths
void CollectDependencyPaths(std::vector<std::string>& out) const overrideThe .mphysmat the surface names
GetMaterial
Material* GetMaterial() constThe asset owns the material through a Ref and keeps the SAME object across a reimport (Unload + Load reset it in place), so a raw view taken from here stays valid for as long as the asset lives. Hold the Ref instead when the holder may outlive the asset.
GetMaterialRef
const Ref<Material>& GetMaterialRef() constGetAlbedoTextureID
UUID GetAlbedoTextureID() constTexture UUID references (set during Load from .mdfmat)
GetNormalTextureID
UUID GetNormalTextureID() constGetMetallicTextureID
UUID GetMetallicTextureID() constGetRoughnessTextureID
UUID GetRoughnessTextureID() constGetAOTextureID
UUID GetAOTextureID() constGetEmissiveTextureID
UUID GetEmissiveTextureID() constGetDetailAlbedoTextureID
UUID GetDetailAlbedoTextureID() constGetDetailNormalTextureID
UUID GetDetailNormalTextureID() constGetMaskMapTextureID
UUID GetMaskMapTextureID() constGetHeightTextureID
UUID GetHeightTextureID() constGetOpacityTextureID
UUID GetOpacityTextureID() constSetAlbedoTextureID
void SetAlbedoTextureID(UUID id)SetNormalTextureID
void SetNormalTextureID(UUID id)SetMetallicTextureID
void SetMetallicTextureID(UUID id)SetRoughnessTextureID
void SetRoughnessTextureID(UUID id)SetAOTextureID
void SetAOTextureID(UUID id)SetEmissiveTextureID
void SetEmissiveTextureID(UUID id)SetDetailAlbedoTextureID
void SetDetailAlbedoTextureID(UUID id)SetDetailNormalTextureID
void SetDetailNormalTextureID(UUID id)SetMaskMapTextureID
void SetMaskMapTextureID(UUID id)SetHeightTextureID
void SetHeightTextureID(UUID id)SetOpacityTextureID
void SetOpacityTextureID(UUID id)GetParentMaterialID
UUID GetParentMaterialID() constMaterial instancing
SetParentMaterialID
void SetParentMaterialID(UUID id)IsInstance
bool IsInstance() constResolveTextures
bool ResolveTextures(const GPUContext& ctx, bool blockingImport = true)Try to resolve texture UUIDs to GPU textures (can be called repeatedly until all resolve) Returns true if all textures are resolved. blockingImport allows pulling a slot's texture in on THIS thread when it is not resident. The editor's async drain passes false: a material with eight 4K slots would otherwise pay eight decodes and eight uploads inside the one frame that receives it, which is the freeze the async importer exists to prevent. Its slots bind on a later pass instead.
HasUnresolvedTextures
bool HasUnresolvedTextures() constSaveToFile
bool SaveToFile(const std::string& path) constSave material to a .mdfmat MDF file
HasGraph
bool HasGraph() constNode graph — optional authoring layer. When present it is the authority: compiling it produces the flat PBR fields + texture UUIDs above (the runtime never sees the graph). Absent → the flat fields are used directly, which is what keeps older graph-less materials working.
GetGraph
MaterialGraph& GetGraph()GetGraph
const MaterialGraph& GetGraph() constSetGraph
void SetGraph(const MaterialGraph& graph)ClearGraph
void ClearGraph()