History: -Material
Preview of version: 17
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);
See also
- Ogre::Material Class Reference
- Texture
- Collection of Ogre material templates
- Displaying 2D Backgrounds
- Line 3D / MOGRE Line 3D - includes some code how to create a material by code
- Projective Decals - dynamic texture projection on top of a terrain texture
- Reloading materials and parsing material scripts
- MadMarx Tutorial 7 - Basic Material (part 1)
- MadMarx Tutorial 8 - Basic Material (part 2), about transparency, decals, environment map, mix percentage
Ogre Manual:
- Materials
- Material Scripts
- Techniques
- Passes - Definition of colours, transparency, blending types, etc.
- Texture Units
- Script Inheritance
- Script Variables