Pixel Count LOD Strategy

Pixel Count LOD Strategy

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.

Status

PixelCountLodStrategy is fully integrated into latest Ogre SDK versions

How To Use

Some Background: How LOD models and strategies work in general?

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

How PixelCountLodStrategy Works?

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.

How To Programatically Prepare A Mesh For PixelCountLodStrategy?

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");

  

How to use LODed mesh

NOTE: code needs testing

Entity* enty = sceneManager->createEntity("MyLodMesh", "something-with-lod.mesh");
enty->setLodStrategy(Ogre::PixelCountLodStrategy::getSingletonPtr()); // optional

  

Also See

http://www.ogre3d.org/tikiwiki/ScreenRatioLodStrategy(external link) 

References

http://www.ogre3d.org/docs/api/html/classOgre_1_1PixelCountLodStrategy.html(external link) 
http://www.ogre3d.org/forums/viewtopic.php?f=13&t=40308(external link) 

http://www.ogre3d.org/tikiwiki/SoC2008+LOD(external link)


摘自:http://www.ogre3d.org/tikiwiki/PixelCountLodStrategy

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值