Skip to main content

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]
        

History

Information Version
Wed 17 of Jun, 2020 22:19 GMT-0000 sercero 22
Thu 17 of Jul, 2014 12:12 GMT-0000 petersvp Fixed a typo ;] 21
Fri 08 of Feb, 2013 13:10 GMT-0000 spacegaier removed duplicated "See Also" section 20
Sun 31 of Jul, 2011 22:14 GMT-0000 jacmoe 19
Sun 24 of Apr, 2011 12:49 GMT-0000 Beauty added code snippet how to apply material by code 18
Wed 23 of Feb, 2011 13:08 GMT-0000 Beauty added section about both-side visibility 17
Mon 21 of Feb, 2011 10:53 GMT-0000 Beauty tiny change 16
Mon 21 of Feb, 2011 10:51 GMT-0000 Beauty added note for alpha value and transparency 15
Fri 11 of Feb, 2011 13:06 GMT-0000 Beauty added section about transparency 14
Fri 11 of Feb, 2011 13:01 GMT-0000 Beauty added section about transparency 13
Thu 03 of Feb, 2011 15:59 GMT-0000 Beauty added 2 links 12
Wed 08 of Dec, 2010 05:26 GMT-0000 sarcacid cleaned up lexicon links 11
Tue 07 of Dec, 2010 19:30 GMT-0000 Beauty added links to Ogre manual 10
Tue 07 of Dec, 2010 16:13 GMT-0000 Beauty highlight 9
Thu 09 of Sep, 2010 11:50 GMT-0000 Beauty added link 8
Wed 18 of Aug, 2010 15:44 GMT-0000 Beauty added link 7
Wed 18 of Aug, 2010 15:41 GMT-0000 Beauty added link 6
Fri 08 of Jan, 2010 00:06 GMT-0000 jacmoe 5
Thu 07 of Jan, 2010 22:36 GMT-0000 jacmoe 4
Thu 07 of Jan, 2010 22:36 GMT-0000 jacmoe 3
Tue 29 of Dec, 2009 09:40 GMT-0000 jacmoe 2
Sat 28 of Nov, 2009 17:32 GMT-0000 Spacegaier linked to the API 1