-Material        

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | 0-9


Material - A material determines how the surface of a {LEX()}mesh{LEX} will appear after being rendered. You can e.g. assign {LEX()}texture{LEX}s, set colours, enable lighting or {LEX()}shadow{LEX}-receiving as well as assigning {LEX()}shader{LEX}s.

Transparency


If you have problems with transparency, look for some important material options.

  • Use the correct value for alpha (0.0 is completely transparent and 1.0 is fully opaque)
  • Set scene blend to alpha blend
  • Disable depth write


Depth write can be turned off when rendering static backgrounds or when rendering a collection of transparent objects at the end of a scene so that they overlap each other correctly.

Apply in material script:

material TransparencyExample
{
    technique
    {
        pass
        {
            //...
            scene_blend alpha_blend
            depth_write off
        }
    }
}



Apply by code:

myMaterialPtr->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
myMaterialPtr->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);



Apply by code (C# example for Mogre):

myMaterialPtr.GetTechnique(0).GetPass(0).SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
myMaterialPtr.GetTechnique(0).GetPass(0).DepthWriteEnabled = false;



Both-side visibility


By default a material is only visible from one side.
This is usable for volumetric bodies. (e.g. an (unripped) monster you don't need to see from inside).
For flat surfaces (e.g. a water surface or billboards) often there is a whish to have a both-side visibility.

Enable both-side visibility by a *.material file:
(For details look to this section of the Ogre manual.)

material TransparencyExample
{
    technique
    {
        pass
        {
            //...
            cull_hardware none
            cull_software none 
        }
    }
}


To enable both-side visibility by code call the material related method Pass::setCullingMode().
Example:

myMaterialPtr::getTechnique(0)::getPass(0)::setCullingMode(CullingMode::CULL_NONE);




Apply to Mesh


Apply a material to a (sub)mesh by code:

entity::getSubEntity(0)::setMaterialName("myMaterialName");



Dynamic usage

It's possible to update a ManualObject to change it's shape or properties. For this you need to set the dynamic flag:

ManualObject::setDynamic(true);

Then you can update its content:

manObj->beginUpdate();
...
// Recreate object
...
manObj->end();

When you are going to be changing the number of vertices, you additionally should call this:

ManualObject::estimateVertexCount();
ManualObject::estimateIndexCount()


Alternatively you can use the low level class DynamicRenderable. A usage example is on page DynamicGrowingBuffers.


See also



Ogre Manual: