History: -Material
Source of version: 14
Copy to clipboard
{INCLUDE(page="ogrelex ext tpl")/}
---
__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.
Normally it's just visible from one side (e.g. surface of a {LEX()}mesh{LEX}), but this can be changed (e.g. for {LEX()}water{LEX} surfaces). Material properties can be defined by material files or by source code.
!!Transparency
If you have problems with transparency, look for some important material options.
* 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:
{CODE(wrap="1")}material TransparencyExample
{
technique
{
pass
{
//...
scene_blend alpha_blend
depth_write off
}
}
}
{CODE}
Apply by code:
{CODE(wrap="1", colors="c++")}
myMaterialPtr->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
myMaterialPtr->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
{CODE}
Apply by code (C# example for ((Mogre))):
{CODE(wrap="1", colors="c#")}
myMaterialPtr.GetTechnique(0).GetPass(0).SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
myMaterialPtr.GetTechnique(0).GetPass(0).DepthWriteEnabled = false;
{CODE}
%%%
!!See also
* [http://www.ogre3d.org/docs/api/html/classOgre_1_1Material.html|Ogre::Material] __Class Reference__
* ((-Texture|Texture))
* ((Materials|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:__
* [http://www.ogre3d.org/docs/manual/manual_11.html#SEC14|Materials]
* [http://www.ogre3d.org/docs/manual/manual_14.html#SEC23|Material Scripts]
** [http://www.ogre3d.org/docs/manual/manual_15.html#SEC33|Techniques]
** [http://www.ogre3d.org/docs/manual/manual_16.html#SEC39|Passes] - Definition of colours, transparency, blending types, etc.
** [http://www.ogre3d.org/docs/manual/manual_17.html#SEC77|Texture Units]
** [http://www.ogre3d.org/docs/manual/manual_25.html#SEC139|Script Inheritance]
** [http://www.ogre3d.org/docs/manual/manual_27.html#SEC144|Script Variables]