Modifying a Material Priority

Changing a material priority is very easy, you just need to call the RED::IMaterial::SetPriority function:

// Let imat1, imat2 and imat3 three existing RED::IMaterial.
// Let ishape1, ishape2 and ishape3 three RED::IShape.

// Change the material priorities:
RC_TEST( imat1->SetPriority( 1, iresmgr->GetState() ) );
RC_TEST( imat2->SetPriority( 0, iresmgr->GetState() ) );
// imat3 keeps it default priority.

// Set the material to the shapes:
RC_TEST( ishape1->SetMaterial( mat1, iresmgr->GetState() ) );
RC_TEST( ishape2->SetMaterial( mat2, iresmgr->GetState() ) );
RC_TEST( ishape3->SetMaterial( mat3, iresmgr->GetState() ) );

The previous code sample defines three RED::IMeshShape, each with its own material.

Material priorities are defined as:

  • priority 1 for the material of the shape 1

  • priority 0 for the material of the shape 2

  • default priority for the material of the shape 3

The rendering order will be:

  • shape 2 (priority 0)

  • shape 1 (priority 1)

  • shape 3 (default priority)