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

void

batch (MaterialInstance & instance)

uint32_t

instanceCount () const

uint32_t

instanceSize () const

Material *

material () const

uint32_t

paramCount () const

std::string

paramName (uint32_t index) const

Variant

paramValue (uint32_t index) const

ByteArray &

rawUniformBuffer ()

void

resetBatches ()

void

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

void

setBufferValue (const char * name, const void * value)

void

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

void

setInstanceCount (uint32_t number)

void

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

void

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

void

setSurfaceType (uint16_t type)

void

setTexture (const char * name, Texture * texture)

void

setTransform (Transform * transform)

void

setTransform (const Matrix4 & transform)

void

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

void

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

void

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

uint16_t

surfaceType () const

Texture *

texture (const char * name)

Transform *

transform ()

Static Methods

None

Methods Description

void MaterialInstance::batch (MaterialInstance & instance)

Batches a material instance to draw using GPU instancing.


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 per instance.


Material * MaterialInstance::material () const

Getter for the base material associated with the instance.


uint32_t MaterialInstance::paramCount () const

Gets the total count of parameters in the material.


std::string MaterialInstance::paramName (uint32_t index) const

Gets the name of a parameter by index.


Variant MaterialInstance::paramValue (uint32_t index) const

Gets the overridden or default value of a parameter by index.


ByteArray & MaterialInstance::rawUniformBuffer ()

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


void MaterialInstance::resetBatches ()

Rests batch buffer.


void MaterialInstance::setBool (char * 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 value*s. Parameter *count a number of elements in the array.


void MaterialInstance::setBufferValue (char * name, void * value)

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


void MaterialInstance::setFloat (char * 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 value*s. Parameter *count a number of elements in the array.


void MaterialInstance::setInstanceCount (uint32_t number)

Sets the number of GPU instances to be rendered.

See also instanceCount().


void MaterialInstance::setInteger (char * 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 value*s. Parameter *count a number of elements in the array.


void MaterialInstance::setMatrix4 (char * 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 value*s. Parameter *count a number of elements in the array.


void MaterialInstance::setSurfaceType (uint16_t type)

Sets the surface type associated with the material instance.

See also surfaceType().


void MaterialInstance::setTexture (char * 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.

See also *transform*().


void MaterialInstance::setTransform (Matrix4 & transform)

Sets the transform matrix.


void MaterialInstance::setVector2 (char * 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 value*s. Parameter *count a number of elements in the array.


void MaterialInstance::setVector3 (char * 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 value*s. Parameter *count a number of elements in the array.


void MaterialInstance::setVector4 (char * 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 value*s. 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 (char * name)

Getter for the overridden texture associated with a specific parameter name.

See also setTexture().


Transform * MaterialInstance::transform ()

Returns the a transform component.

See also setTransform().