Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

In my cube world, I want to use octrees to represent my chunks of 20x20x20 cubes for frustum and occlusion culling. I understand how octrees work, I just dont know if I'm going about this the right way.

My base octree class is taken from here: http://www.xnawiki.com/index.php/Octree

What I'm wondering is how to apply occlusion culling using this class. Does it make sense to have one octree for each cube chunk? Or should I make the octree bigger? Since I'm using cubes, each cube should fit into a node without overlap so that won't be an issue

share|improve this question
    
What problems do you foresee with occlusion culling? - Perhaps add this to your question. –  Nick Wiggill Oct 17 '13 at 18:05
2  
one octree for each cube chunk would be not very useful, since ostensibly each chunk would be one buffer. You'd want to cull chunks, not individual blocks. –  Jimmy Oct 17 '13 at 18:09
    
I cant get a 20x20x20 chunk on the screen without some frame rate dropping unless i cull individual blocks. I did occlusion culling but the completely wrong way –  Christian Frantz Oct 17 '13 at 18:10
    
Why do you want you want to use octrees? What benefit do you see from this? Do you want fine voxels? Or is there some other reason? –  Nick Wiggill Oct 17 '13 at 18:16
3  
@ChristianFrantz If you can't draw 8,000 (20x20x20) cubes on screen without occlusion culling and without your frame rate dropping then you might have bigger issues right now than octrees can fix - that should be well within the range of any hardware without substantial trouble. –  Steven Stadnicki Oct 17 '13 at 18:18

2 Answers 2

This question deals with the same problem, even if its c++ & opengl most of the concept apply to your case too. There is also a good general article on Gamasutra regarding visibility culling.

For your special case you could construct an octree, where the leaves contain batches of cubes and than use bounding boxes to check if a region is visible or not.

Just to make sure if you are familiar with the general concept: Occlusion Culling with octree works this way: You develop a simplified visibility check and divide your word into an octree. You start on a higher level and move down the tree. If a branch isn´t visible all the sub branches and leaves can be discarded too.

Using the class given, you could probably make use of the CanContainOrIntersect method to test for visibility.

But I also agree with Steven, if you have problems with 20x20x20 cubes you should definitely look into some other optimizations.

share|improve this answer

For occlusion culling with an octree, you could build low-res hierarchical depth buffer first from potential occluders (taking max depth of 4 samples for lower-res LOD) and test the octree against it. You need to determine the octree node size in screen and pick the proper LOD to test against to reduce the test to 4 samples per octree node.

The main issue is how you build the initial occlusion buffer to test the octree against without rendering everything. You could: 1) Hand pick larger models and render them to the buffer 2) Reproject previous frame depth (only stationary objects), but this introduces holes so you would need to patch it somehow 3) Render objects which were visible last frame, but you need some way to determine which objects were visible (e.g. render object ID buffer)

Since you said you are using instancing, this could be done entirely in GPU side by building an instance stream thus you don't need to figure out how to get the rasterized depth buffer to CPU (without latency issues). You might be better off not using octree though but just throwing all the instances in FOV to the shader which does the occlusion test and builds your visible instance stream.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.