class
Material
Material that controls how objects are rendered.
It is represented by a shader and parameters used to set up that shader. It provides a simple interface for manipulating the parameters.
Public
Methods
~Material
SetShader
Sets a shader that will be used by the material.
SetVariation
Initialize
Initializes all the internal data of this object.
Must be called right after construction for new objects, or after deserialization for deserialized objects. If requested, render proxy is created and queued for initialization on the render thread.
Clone
Creates a deep copy of the material and returns the new object.
staticCreate
Creates a new empty material.
staticCreate
Creates a new material with the specified shader.
staticCreate
Creates a new material with the specified shader, and a set of parameters that determine which subset of variations in the shader should the material use.
staticGetRttiStatic
~TMaterial<IsRenderProxy>
GetShader
Returns the currently active shader.
GetVariationParameters
Set of parameters that determine which subset of variations in the assigned shader should be used.
Only the variations that have the provided parameters with the provided values will match. This will control which variation is considered the default variation and which subset of variations are searched during a call to FindVariation().
GetVariationCount
Returns the total number of variations supported by this material.
GetVariation
Returns the variation at the specified index.
FindVariation
Attempts to find a variation matching the specified variation and tags among the supported variations.
- information
- Object containing an optional set of tags and a set of variation parameters to look for.
Returns: First variation that matches the variation parameters specified in .
GetDefaultVariation
Finds the index of the default (primary) variation to use.
This will be the first variation that matches the currently set variation parameters (if any).
GetPassCount
Returns the number of passes that are used by the variation at the specified index.
- variationIndex
- Index of the variation to retrieve the number of passes for. 0 is always guaranteed to be the default variation.
Returns: Number of passes used by the variation.
GetPass
Retrieves a specific shader pass from the provided variation.
- passIndex
- Sequential index of the pass to retrieve.
- variationIndex
- Index of the variation to retrieve the pass for. 0 is always guaranteed to be the default variation.
Returns: Pass if found, null otherwise.
CreateParameterAdapter
Creates an adapter that can be used for transferring parameters from the material to GpuParameterSet objects.
The adapter will take care of tracking when material parameters change and can be used to update the underlying GpuParameterSet objects. Adapter is only valid for a particular material variation, you will need to create a different adapter for each variation.
SetFloat
Assigns a float value to the shader parameter with the specified name.
Optionally if the parameter is an array you may provide an array index to assign the value to.
SetFloatCurve
SetColor
Assigns a color to the shader parameter with the specified name.
Optionally if the parameter is an array you may provide an array index to assign the value to.
SetColorGradient
Assigns a color gradient to the shader parameter with the specified name.
The system will automatically evaluate the gradient with the passage of time and apply the evaluated value to the parameter.
Optionally if the parameter is an array you may provide an array index to assign the value to.
SetVec2
Assigns a 2D vector to the shader parameter with the specified name.
Optionally if the parameter is an array you may provide an array index to assign the value to.
SetVec3
Assigns a 3D vector to the shader parameter with the specified name.
Optionally if the parameter is an array you may provide an array index to assign the value to.
SetVec4
Assigns a 4D vector to the shader parameter with the specified name.
Optionally if the parameter is an array you may provide an array index to assign the value to.
SetMat3
Assigns a 3x3 matrix to the shader parameter with the specified name.
Optionally if the parameter is an array you may provide an array index to assign the value to.
SetMat4
Assigns a 4x4 matrix to the shader parameter with the specified name.
Optionally if the parameter is an array you may provide an array index to assign the value to.
SetStructData
Assigns a structure to the shader parameter with the specified name.
Structure is provided as a raw buffer and caller must ensure structure in buffer matches what the shader expects.
Optionally if the parameter is an array you may provide an array index to assign the value to.
SetTexture
Assigns a texture to the shader parameter with the specified name.
SetSpriteImage
Assigns a sprite image to the shader parameter with the specified name.
If the sprite image contains animation it will be automatically evaluated every frame.
SetLoadStoreTexture
Assigns a texture to be used for random load/store operations to the shader parameter with the specified name.
SetBuffer
Assigns a buffer to the shader parameter with the specified name.
SetSamplerState
Assigns a sampler state to the shader parameter with the specified name.
GetFloat
Returns a float value assigned with the parameter with the specified name.
If a curve is assigned to this parameter, returns the curve value evaluated at time 0. Use getBoundParamType() to determine the type of the parameter.
Optionally if the parameter is an array you may provide an array index you which to retrieve.
GetFloatCurve
Returns a curve value assigned to the parameter with the specified name.
If the parameter has a constant value bound instead of a curve then this method returns an empty curve. Use getBoundParamType() to determine the type of the parameter.
Optionally if the parameter is an array you may provide an array index you which to retrieve.
GetColor
Returns a color assigned with the parameter with the specified name.
If a color gradient is assigned to this parameter, returns the gradient color evaluated at time 0. Use getBoundParamType() to determine the type of the parameter.
Optionally if the parameter is an array you may provide an array index you which to retrieve.
GetColorGradient
Returns a color gradient assigned with the parameter with the specified name.
If the parameter has a constant value bound instead of a gradient then this method returns an empty gradient. Use getBoundParamType() to determine the type of the parameter.
Optionally if the parameter is an array you may provide an array index you which to retrieve.
GetVec2
Returns a 2D vector assigned with the parameter with the specified name.
Optionally if the parameter is an array you may provide an array index you which to retrieve.
GetVec3
Returns a 3D vector assigned with the parameter with the specified name.
Optionally if the parameter is an array you may provide an array index you which to retrieve.
GetVec4
Returns a 4D vector assigned with the parameter with the specified name.
Optionally if the parameter is an array you may provide an array index you which to retrieve.
GetMat3
Returns a 3x3 matrix assigned with the parameter with the specified name.
Optionally if the parameter is an array you may provide an array index you which to retrieve.
GetMat4
Returns a 4x4 matrix assigned with the parameter with the specified name.
Optionally if the parameter is an array you may provide an array index you which to retrieve.
IsAnimated
Checks does the data parameter with the specified name currently contains animated data.
This could be an animation curve or a color gradient.
GetTexture
Returns a texture assigned with the parameter with the specified name.
GetSpriteImage
Returns a sprite image assigned to the parameter with the specified name.
If the parameter has a regular texture attached instead of a sprite image, null will be returned. Use getBoundParamType() to determine the type of the parameter.
GetSamplerState
Returns a sampler state assigned with the parameter with the specified name.
GetStructData
Returns a buffer representing a structure assigned to the parameter with the specified name.
Optionally if the parameter is an array you may provide an array index you which to retrieve.
GetParamFloat
Returns a handle that allows you to assign a constant value to a floating point parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamFloatCurve
Returns a handle that allows you to assign a time-varying curve to a floating point parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamColor
Returns a handle that allows you to assign a constant value to a color parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamColorGradient
Returns a handle that allows you to assign a time-varying gradient to a color parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamVec2
Returns a handle that allows you to assign a constant value to a 2D vector parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamVec3
Returns a handle that allows you to assign a constant value to a 3D vector parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamVec4
Returns a handle that allows you to assign a constant value to a 4D vector parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamMat3
Returns a handle that allows you to assign a constant value to a 3x3 matrix parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamMat4
Returns a handle that allows you to assign a constant value to a 4x4 matrix parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamStruct
Returns a handle that allows you to assign a structure GPU parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamTexture
Returns a handle that allows you to assign a texture GPU parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamSpriteImage
Returns a handle that allows you to assign a sprite texture GPU parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamLoadStoreTexture
Returns a handle that allows you to assign a load-store texture GPU parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamBuffer
Returns a handle that allows you to assign a buffer GPU parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
GetParamSamplerState
Returns a handle that allows you to assign a sampler state GPU parameter.
This handle may be used for more efficiently getting/setting GPU parameter values than calling Material::Get* / Material::Set* methods.
Internal
Methods
MarkRenderProxyDataDirtyInternal
Marks the render proxy data as dirty.
This causes the syncToCore() method to trigger the next time objects are synced between render and main threads.
MarkDependenciesDirtyInternal
Notifies the core object manager that this object is dependant on some other CoreObject(s), and the dependencies changed since the last call to this method.
This will trigger a call to GetCoreDependencies() to collect the new dependencies.
MarkResourcesDirtyInternal
Marks the resource dependencies list as dirty and schedules it for rebuild.
GetMaterialParameters
Returns an object containg all of material's parameters.
Allows the caller to manipulate the parameters more directly.
Protected
Methods
InitializeVariations
Initializes the material by using the compatible variations from the currently set shader.
Shader must contain the variations that matches the current renderer and GPU backend.
InitializeDefaultParameters
Assigns all the default parameters specified in the shader to the material.
ReportIfNotInitialized
Reports an error if no shader is set, or no acceptable variation was found.
Fields
mShader
mParameters
mVariations
mVariationParameters
Private
Constructors
Material
Material
Methods
CreateRenderProxy
Creates an object that contains render thread specific data and methods for this object.
Can be null if such object is not required.
CreateRenderProxySyncPacket
Creates a data packet that will be used for syncing the core object with it's render proxy.
Caller must free the retrieved packet using the provided allocator when done using it.
GetCoreDependencies
Populates the provided array with all core objects that this core object depends upon.
Dependencies are required for syncing to the render thread, so the system can be aware to update the dependant objects if a dependency is marked as dirty (for example updating a camera's viewport should also trigger an update on camera so it has a chance to potentially update its data).
GetListenerResources
Retrieves all the resources that the class depends on.
NotifyResourceLoaded
Called when a resource has been fully loaded.
NotifyResourceChanged
Called when the internal resource the resource handle is pointing to changes.
InitializeIfLoaded
Performs material initialization when all resources are ready.
SetParams
Uses the provided list of parameters to try to set every parameter in this material.
Parameter whose name, type or size don't match are ignored and will not be set.
staticCreateEmpty
Creates a new empty material but doesn't initialize it.