Getting material lod to work

Problems building or running the engine, queries about how to use features etc.
User avatar
Injector
Gremlin
Posts: 174
Joined: Wed Jan 21, 2004 2:42 pm
Location: Frankfurt, Germany

Getting material lod to work

Post by Injector »

Hello again,

I want to make use of Ogre's material lod system for cheaper render to texture effects. As a test I set up a material with two techniques assigning lod indices (lod_index 0 for the 'real' technique, lod_index 1 for the stripped down one). When updating the render texture, I tried to assign a lod bias value of 0.5 to the camera the render texture uses, but this had no effect.

I played with the lod bias value (trying sth. between 0.001 and 10), but there is no difference (the technique used is always the one with lod_index 0). I also tried and set up lod distances for the material, but this seems to have no effect either.

Some time ago I tried mesh lod (with autogenerated lod levels) and it worked at once...

Can anyone help me?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

Did you actually assign distances to the lods? You must do this using the ' lod_distances' attribute of the outer material definition. The LOD bias just adjusts the distance calculation, if you never assigned lod distances in the first place it will have no effect.
User avatar
Injector
Gremlin
Posts: 174
Joined: Wed Jan 21, 2004 2:42 pm
Location: Frankfurt, Germany

Post by Injector »

Maybe someone can take a look at my material script. We interprete world units as cm, so the distances are 2m, 4m and 6m. The material always uses the glass_grey.tga texture, i.e. lod_index 0. So I have got no problems with the bias, but with lod in general. :(

Maybe I have to 'globally enable' material lod and I missed it in the docs?

Code: Select all

material glass_grey
{
  lod_distances 200 400 600

  technique
  {
    lod_index 0
    pass
    {
      texture_unit
      {
        texture glass_grey.tga
      }
    }
  }

  technique
  {
    lod_index 1
    pass
    {
      texture_unit
      {
        texture floor_stone_square_terracotta.tga
      }
    }
  }
 
  technique
  {
    lod_index 2
    pass
    {
      texture_unit
      {
        texture backpack.tga
      }
    }
  }

  technique
  {
    lod_index 3
    pass
    {
      texture_unit
      {
        texture fabric_wool_white.tga
      }
    }
  }
}
Ogre silently and happily parses the file without errors.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

Well, Entity LOD is calculated in Entity::_notifyCurrentCamera, and then used in SubEntity::getTechnique. I've tried this out in the past and it definitely worked, and I've heard from others who used it too.

This of course won't work if you're using your own custom renderables. Renderable has a getTechnique method that must take into account material LOD if it want's to use it.
User avatar
Injector
Gremlin
Posts: 174
Joined: Wed Jan 21, 2004 2:42 pm
Location: Frankfurt, Germany

Post by Injector »

That's it! I was using the dotsceneoctree plugin which in turn defines its own Renderable class. It works as expected when using Ogre's core classes. So, problem solved.

Thank you very much. I am always stunned to see how much patience you show helping others out!

Injector