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)

void

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

void

setFloat (const TString & name, const float * value)

void

setInstanceBuffer (const ByteArray * buffer)

void

setInstanceCount (uint32_t number)

void

setInteger (const TString & name, const int32_t * value)

void

setMatrix4 (const TString & name, const Matrix4 * value)

void

setPriority (int32_t priority)

void

setSkinSize (uint32_t size)

void

setSurfaceType (uint16_t type)

void

setTexture (const TString & name, Texture * texture)

void

setTransform (const Matrix4 & transform, uint32_t uuid, uint32_t hash)

void

setVector2 (const TString & name, const Vector2 * value)

void

setVector3 (const TString & name, const Vector3 * value)

void

setVector4 (const TString & name, const Vector4 * value)

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)

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.


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)

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.


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)

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.


void MaterialInstance::setMatrix4 (TString & name, Matrix4 * value)

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.


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 (Matrix4 & transform, uint32_t uuid, uint32_t hash)

Sets the transform matrix. The update is performed only when the hash value differs from the currently stored transformation hash.

A uuid used to generate an identifying color. If zero, no color embedding is performed.


void MaterialInstance::setVector2 (TString & name, Vector2 * value)

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.


void MaterialInstance::setVector3 (TString & name, Vector3 * value)

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.


void MaterialInstance::setVector4 (TString & name, Vector4 * value)

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.


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().