How it works
When Ogre requests a technique for a specific LOD index, the Factory selects the appropriate LOD configuration which then temporarily overrides the global settings in the shaders. We can use this to disable shader features one by one at a lower LOD, resulting in simpler and faster techniques for distant objects.
How to use it
- Create a file with the extension '.lod'. There you can specify shader features to disable at a specific LOD level. Higher LOD index refers to a lower LOD. Example contents:
lod_configuration 1
{
specular_mapping false
}
lod_configuration 2
{
specular_mapping false
normal_mapping false
}
lod_configuration 3
{
terrain_composite_map true
specular_mapping false
normal_mapping false
}
- Note
- You can also add LOD configurations by calling sh::Factory::registerLodConfiguration.
-
Do not use an index of 0. LOD 0 refers to the highest LOD, and you will never want to disable features at the highest LOD level.
- In your materials, specify the distances at which a lower LOD kicks in. Note that the actual distance might also be affected by the viewport and current entity LOD bias. In this example, the first LOD level (lod index 1) would normally be applied at a distance of 100 units, the next after 300, and the last after 1000 units.
material sample_material
{
lod_values 100 300 1000
... your passes, texture units etc ...
}