OGRE——渲染大量物體,批次(batch)

來源:互聯網
上載者:User

OGRE渲染物體,可以把物體作為InstancedGeometry,StaticGeometry,Entity執行個體來渲染。

區別:

InstancedGeometry:Pre-transforms and batches up meshes for efficient use as instanced geometry in a scene。也就是說,把所有網格作為一個instance geometry。

this shader instancing implementation stores only 80 times the object, and then re-uses the vertex data with different shader parameter.只可以儲存同一物體80次,然後重用頂點資料使用不同的渲染參數。

可以每幀調整位置,方向,大小等

StaticGeometry:把所有網格作為一個靜態幾何體,這樣每個材質就是一次批次。但是,看到一小部分,整個StaticGeometry也會全部都渲染的。

Entity:每個Entity包含一個Mesh。

每次渲染操作都是相當的耗費資源的。所以應該減少對DIP的調用。

OGRE的渲染流程

void SceneManager::renderSingleObject(Renderable* rend, const Pass* pass, ...)
{
     //...
     static RenderOperation ro;
     ro.srcRenderable = rend;
     //...
     mDestRenderSystem->_render(ro);
     //...
}

void SceneManager::SceneMgrQueuedRenderableVisitor::visit(Renderable* r)
{
   // Give SM a chance to eliminate
   if (targetSceneMgr->validateRenderableForRendering(mUsedPass, r))
   {
      // Render a single object, this will set up auto params if required
      targetSceneMgr->renderSingleObject(r, mUsedPass, scissoring, autoLights, manualLightList);
   }
}
   void QueuedRenderableCollection::acceptVisitorGrouped(
      QueuedRenderableVisitor* visitor) const
   {
      PassGroupRenderableMap::const_iterator ipass, ipassend;
      ipassend = mGrouped.end();
      for (ipass = mGrouped.begin(); ipass != ipassend; ++ipass)
      {
         // Fast bypass if this group is now empty
         if (ipass->second->empty()) continue;

         // Visit Pass - allow skip
         if (!visitor->visit(ipass->first))
            continue;

         RenderableList* rendList = ipass->second;
         RenderableList::const_iterator irend, irendend;
         irendend = rendList->end();
         for (irend = rendList->begin(); irend != irendend; ++irend)
         {
            // Visit Renderable
            visitor->visit(const_cast<Renderable*>(*irend));
         }
      }
 }

for (ipass = mGrouped.begin(); ipass != ipassend; ++ipass)
{
________//....

________RenderableList* rendList = ipass->second;

________for (irend = rendList->begin(); irend != irendend; ++irend)
______________ {

_________________visitor->visit(const_cast<Renderable*>(*irend));

______________ }
}

也就是說每個Rendable都會調用一次DIP。當把有相同的Pass的Rendable合并成一次時,可以減少對DIP的調用。

 

本文來自CSDN部落格,轉載請標明出處:http://blog.csdn.net/zhangshuncai/archive/2010/06/30/5705055.aspx

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.