PixelCountLodStrategy works by analyzing how many pixels a model occupies on screen on any given instance of time, and selects a LOD mesh/material accordingly.
PixelCountLodStrategy is fully integrated into latest Ogre SDK versions
NOTE: To simplify things, I am using generic terms, simple explanations and approximations in this sub-section. They do not convey full details, but are easy to understand. After this sub-section, actual Ogre terms are used
LOD stands for Level Of Details. The concept of LOD is to use high quality (complex and slow to draw) models when an object is viewed from close and low quality (simple and fast to draw) models when an object is viewed from a distance.
LOD strategies are all about calculating that which version of a model (complex one or simple one) should be displayed at any diven time. They do it by generating a LOD value for a 3d model and the active camera at any given time
LOD models consist of a series of models starting with most detailed model with successive ones decreasing in complexity and quality (hence increasing in speed). While creating these models, we specify which LOD strategy will be applicable to a certain model. Then we specify at what lod values, what lod version of the models will be displayed
PixelCountLodStrategy works by (approximately) counting that how many pixels does a Mesh occupy on screen at any time. The value calculated is pixel area (height*width). For example, if a model occupy 200*200 pixels on screen at any time, value calculated will be 40,000.
NOTE: code needs testing
For PixelCountLodStrategy, mesh lod values are stored in decreasing orger, starting with MAX_FLOAT value. Here is what you have to do
// define base mesh MeshPtr mesh = MeshManager::getSingleton().load("something-100p.mesh"); // level 0, 100 percent // add LOD strategy mesh->setLodStrategy(Ogre::PixelCountLodStrategy::getSingletonPtr()); // might need to reapply after load // add level 1 mesh, for pixel area below 500*500 mesh->createManualLodLevel(250000, "something-50p.mesh"); // level 1, 50 percent // add level 2 mesh, for pixel area below 200*200 mesh->createManualLodLevel(40000, "something-25p.mesh"); // level 2, 25 percent // export LODed mesh MeshSerializer ser; ser.exportMesh(mesh1.get(), "something-with-lod.mesh");
NOTE: code needs testing
Entity* enty = sceneManager->createEntity("MyLodMesh", "something-with-lod.mesh"); enty->setLodStrategy(Ogre::PixelCountLodStrategy::getSingletonPtr()); // optional