MaterialInstance

Inherited: None

Description

The MaterialInstance class enables customization of material parameters and textures for rendering objects. It supports various types of parameters, and the customization can be done per-instance.

Public Methods

int32_t

finalPriority () const

uint32_t

instanceCount () const

uint32_t

instanceSize () const

Material *

material () const

void

overrideTexture (int32_t binding, Texture * texture)

int32_t

priority () const

ByteArray

rawUniformBuffer ()

void

setBool (const TString & name, const bool * value, int32_t count = 1)

void

setBufferValue (const TString & name, const void * value)

void

setFloat (const TString & name, const float * value, int32_t count = 1)

void

setInstanceBuffer (ByteArray * buffer)

void

setInstanceCount (uint32_t number)

void

setInteger (const TString & name, const int32_t * value, int32_t count = 1)

void

setMatrix4 (const TString & name, const Matrix4 * value, int32_t count = 1)

void

setPriority (int32_t priority)

void

setSkinSize (uint32_t size)

void

setSurfaceType (uint16_t type)

void

setTexture (const TString & name, Texture * texture)

void

setTransform (Transform * transform)

void

setTransform (const Matrix4 & transform)

void

setVector2 (const TString & name, const Vector2 * value, int32_t count = 1)

void

setVector3 (const TString & name, const Vector3 * value, int32_t count = 1)

void

setVector4 (const TString & name, const Vector4 * value, int32_t count = 1)

uint16_t

surfaceType () const

Texture *

texture (CommandBuffer & buffer, int32_t binding)

Static Methods

None

Methods Description

int32_t MaterialInstance::finalPriority () const

Returns the final material instance priority used for sorting of rendering queue. Calculated as Material::priority + priority


uint32_t MaterialInstance::instanceCount () const

Returns the number of GPU instances to be rendered.

See also setInstanceCount().


uint32_t MaterialInstance::instanceSize () const

Returns a size of data for instances.


Material * MaterialInstance::material () const

Getter for the base material associated with the instance.


void MaterialInstance::overrideTexture (int32_t binding, Texture * texture)

Overrides the texture for the specified shader binding point.


int32_t MaterialInstance::priority () const

Returns the instance priority.

See also setPriority().


ByteArray MaterialInstance::rawUniformBuffer ()

Returns a reference to CPU part of uniform buffer. Developer can modify it for their needs.


void MaterialInstance::setBool (TString & name, bool * value, int32_t count = 1)

Sets a boolean parameter with optional array support. Parameter name specifies a name of the boolean parameter. Parameter value pointer to the boolean value or array of boolean values. Parameter count a number of elements in the array.


void MaterialInstance::setBufferValue (TString & name, void * value)

Sets the value of a parameter with specified name in the uniform buffer.


void MaterialInstance::setFloat (TString & name, float * value, int32_t count = 1)

Sets a float parameter with optional array support. Parameter name specifies a name of the float parameter. Parameter value pointer to the float value or array of float values. Parameter count a number of elements in the array.


void MaterialInstance::setInstanceBuffer (ByteArray * buffer)

Sets instances buffer.


void MaterialInstance::setInstanceCount (uint32_t number)

Sets the number of GPU instances to be rendered.

See also instanceCount().


void MaterialInstance::setInteger (TString & name, int32_t * value, int32_t count = 1)

Sets a integer parameter with optional array support. Parameter name specifies a name of the integer parameter. Parameter value pointer to the integer value or array of integer values. Parameter count a number of elements in the array.


void MaterialInstance::setMatrix4 (TString & name, Matrix4 * value, int32_t count = 1)

Sets a Matrix4 parameter with optional array support. Parameter name specifies a name of the Matrix4 parameter. Parameter value pointer to the Matrix4 value or array of Matrix4 values. Parameter count a number of elements in the array.


void MaterialInstance::setPriority (int32_t priority)

Sets the instance priority.

See also priority().


void MaterialInstance::setSkinSize (uint32_t size)

Sets the skinned mesh bones buffer size. This buffer must be recorded to the end of instance data structure (after all uniforms).


void MaterialInstance::setSurfaceType (uint16_t type)

Sets the surface type associated with the material instance.

See also surfaceType().


void MaterialInstance::setTexture (TString & name, Texture * texture)

Sets a texture parameter with specified name.

See also texture().


void MaterialInstance::setTransform (Transform * transform)

Sets the transform component to track it.


void MaterialInstance::setTransform (Matrix4 & transform)

Sets the transform matrix.


void MaterialInstance::setVector2 (TString & name, Vector2 * value, int32_t count = 1)

Sets a Vector2 parameter with optional array support. Parameter name specifies a name of the Vector2 parameter. Parameter value pointer to the Vector2 value or array of Vector2 values. Parameter count a number of elements in the array.


void MaterialInstance::setVector3 (TString & name, Vector3 * value, int32_t count = 1)

Sets a Vector3 parameter with optional array support. Parameter name specifies a name of the Vector3 parameter. Parameter value pointer to the Vector3 value or array of Vector3 values. Parameter count a number of elements in the array.


void MaterialInstance::setVector4 (TString & name, Vector4 * value, int32_t count = 1)

Sets a Vector4 parameter with optional array support. Parameter name specifies a name of the Vector4 parameter. Parameter value pointer to the Vector4 value or array of Vector4 values. Parameter count a number of elements in the array.


uint16_t MaterialInstance::surfaceType () const

Gets the surface type associated with the material instance.

See also setSurfaceType().


Texture * MaterialInstance::texture (CommandBuffer & buffer, int32_t binding)

Getter for the overridden texture associated with a specific parameter binding point.

The command buffer used for texture resolution and resource access.

See also setTexture().