Class Material
Material asset that contains shader for rendering models on the GPU.
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Content/Assets/Material.h
Syntax
public class Material : public ShaderAssetTypeBase
Methods
Bind(BindParameters& params)
Binds the material state to the GPU pipeline. Should be called before the draw command.
Declaration
public virtual void Bind(BindParameters& params) override
Parameters
BindParameters
params
The material bind settings. |
Overrides
CanUseInstancing(InstancingHandler& handler)
Returns true if material can use draw calls instancing.
Declaration
public virtual bool CanUseInstancing(InstancingHandler& handler) const override
Parameters
InstancingHandler
handler
The output data for the instancing handling used to hash, batch and write draw calls. Valid only when function returns true. |
Returns
bool
True if can use instancing, otherwise false. |
Overrides
CanUseLightmap()
Returns true if material can use lightmaps (this includes lightmaps offline baking and sampling at runtime).
Declaration
public virtual bool CanUseLightmap() const override
Returns
bool
True if can use lightmaps, otherwise false |
Overrides
getChunksToPreload()
Gets packed chunks indices to preload before asset loading action
Declaration
protected virtual AssetChunksFlag getChunksToPreload() const override
Returns
AssetChunksFlag
Chunks to load flags |
Overrides
GetDrawModes()
Gets the mask of render passes supported by this material.
Declaration
public virtual DrawPass GetDrawModes() const override
Returns
DrawPass
The draw passes supported by this material. |
Overrides
GetInfo()
Gets the material info, structure which describes material surface.
Declaration
public virtual MaterialInfo GetInfo() const override
Returns
MaterialInfo
The constant reference to the material descriptor. |
Overrides
GetShader()
Gets the shader resource.
Declaration
public virtual GPUShader* GetShader() const override
Returns
GPUShader
The material shader resource. |
Overrides
InitCompilationOptions(ShaderCompilationOptions& options)
Prepare shader compilation options.
Declaration
public virtual void InitCompilationOptions(ShaderCompilationOptions& options) override
Parameters
ShaderCompilationOptions
options
The output options. |
Overrides
IsMaterialInstance()
Returns true if material is a material instance.
Declaration
public virtual bool IsMaterialInstance() const override
Returns
bool
|
Overrides
IsReady()
Returns true if material is ready for rendering.
Declaration
public virtual bool IsReady() const override
Returns
bool
True if can render that material |
Overrides
load()
Load data from the chunks
Declaration
protected virtual LoadResult load() override
Returns
LoadResult
Loading result |
Overrides
LoadSurface(bool createDefaultIfMissing)
Tries to load surface graph from the asset.
Declaration
public BytesContainer LoadSurface(bool createDefaultIfMissing)
Parameters
bool
createDefaultIfMissing
True if create default surface if missing. |
Returns
BytesContainer
The output surface data, or empty if failed to load. |
OnDependencyModified(BinaryAsset* asset)
Called when one of the asset dependencies gets modified (it was saved or reloaded or reimported).
Declaration
protected virtual void OnDependencyModified(BinaryAsset* asset) override
Parameters
BinaryAsset
asset
The modified asset that this asset depends on. |
Overrides
Save(const StringView& path=StringView::Empty)
Saves this asset to the file. Supported only in Editor.
Declaration
public virtual bool Save(const StringView& path=StringView::Empty) override
Parameters
StringView
path
The custom asset path to use for the saving. Use empty value to save this asset to its own storage location. Can be used to duplicate asset. Must be specified when saving virtual asset. |
Returns
bool
True when cannot save data, otherwise false. |
Overrides
SaveSurface(const BytesContainer& data, const MaterialInfo& info)
Updates the material surface (save new one, discard cached data, reload asset).
Declaration
public bool SaveSurface(const BytesContainer& data, const MaterialInfo& info)
Parameters
BytesContainer
data
The surface graph data. |
MaterialInfo
info
The material info structure. |
Returns
bool
True if cannot save it, otherwise false. |
unload(bool isReloading)
Unloads asset data
Declaration
protected virtual void unload(bool isReloading) override
Parameters
bool
isReloading
True if asset is reloading data, otherwise false. |