Meshbuffer culling.

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Meshbuffer culling.

Post by Mel »

The meshbuffer rendering isn't culled anywhere?

Because they could use, at least, the view frustum culling as they have their own bounding box and all, but the rendering code of the static meshes (for instance) doesn't cull them, and it could happen perfectly that the meshbuffer was completely out of the view, but still the draw call would be issued.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

overall we need a new method of culling, I do not see why irrlicht doesn't employ occlusion queries which after all are easy to do (which I am going to implement in my engine).

http://http.developer.nvidia.com/GPUGem ... _ch29.html

Also you could use hierarchical Z, where you downscale the Z buffer and download the data outside of "driver->begin" and "driver->end" and use it to discard nodes at bounding box level (use the right size map so the bounding box Max and Min are preferably in the same pixel or in adjacent ones).
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

@Mel, yeah, not sure where we'd put such code though. Any suggestions?
devsh wrote:I do not see why irrlicht doesn't employ occlusion queries which after all are easy to do
Easy to do in a very specific case, but a one-frame-behind method that works in the general case would be reasonably tricky.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

devsh wrote:overall we need a new method of culling, I do not see why irrlicht doesn't employ occlusion queries which after all are easy to do
Irrlicht has Occlusion queries since Irrlicht 1.7 :roll: Maybe live with the present, not with the past 8)
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

hybrid wrote:
devsh wrote:overall we need a new method of culling, I do not see why irrlicht doesn't employ occlusion queries which after all are easy to do
Irrlicht has Occlusion queries since Irrlicht 1.7 :roll: Maybe live with the present, not with the past 8)
where is that function/class/functionality? i would love to try that.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

@bitplane: I don't know... Maybe it could be useful that the video driver knew also something about the currently active camera, or that there was any way to know the view Frustum from the meshbuffers

The occlusion queries can be found in the IVideoDriver. This is not on the current API reference in the web though... (copied from IVideoDriver.h)

Code: Select all

//! Create occlusion query.
		/** Use node for identification and mesh for occlusion test. */
		virtual void createOcclusionQuery(scene::ISceneNode* node,
				const scene::IMesh* mesh=0) =0;

Code: Select all

//! Remove occlusion query.
		virtual void removeOcclusionQuery(scene::ISceneNode* node) =0;

Code: Select all

//! Remove all occlusion queries.
		virtual void removeAllOcclusionQueries() =0;

Code: Select all

//! Run occlusion query. Draws mesh stored in query.
		/** If the mesh shall not be rendered visible, use
		overrideMaterial to disable the color and depth buffer. */
		virtual void runOcclusionQuery(scene::ISceneNode* node, bool visible=false) =0;

Code: Select all

//! Run all occlusion queries. Draws all meshes stored in queries.
		/** If the meshes shall not be rendered visible, use
		overrideMaterial to disable the color and depth buffer. */
		virtual void runAllOcclusionQueries(bool visible=false) =0;

Code: Select all

//! Update occlusion query. Retrieves results from GPU.
		/** If the query shall not block, set the flag to false.
		Update might not occur in this case, though */
		virtual void updateOcclusionQuery(scene::ISceneNode* node, bool block=true) =0;

Code: Select all

//! Update all occlusion queries. Retrieves results from GPU.
		/** If the query shall not block, set the flag to false.
		Update might not occur in this case, though */
		virtual void updateAllOcclusionQueries(bool block=true) =0;

Code: Select all

//! Return query result.
		/** Return value is the number of visible pixels/fragments.
		The value is a safe approximation, i.e. can be larger than the
		actual value of pixels. */
		virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const =0;
This method uses the OQ to calculate the visibility of the meshes dynamically. I don't know how hard would it be to port to Irrlicht.

http://citeseerx.ist.psu.edu/viewdoc/do ... 1&type=pdf
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

well we know one thing that needs to be done... enabling the occlusion queries by default in the pipeline (surprised irrlicht doesnt do that automatically...)

AND updating the API reference
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

devsh wrote:well we know one thing that needs to be done... enabling the occlusion queries by default in the pipeline (surprised irrlicht doesnt do that automatically...)

AND updating the API reference
well not really. old hardware can't afford that. so having it as an option is perfectly valid at least for me.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yeah, the idea was to add it to the culling algorithms. By that, it would be possible to enable and disable it on a per-node base. We need some changes to the culling pipeline, though. So for now it was just left as-is. Works pretty good on low-end gfx as well, though.
Post Reply