Culling invisible chunks

Started by geakstr, February 06, 2015, 16:23:58

Previous topic - Next topic

geakstr

Hello everyone!

How can I culling invisible chunks in my minecraft clone? I implemented frustum culling and it does job very well. But it not does (and it should not) culling chunks behind other chunks. I read about octree but not sure what they were applicable for this problem because chunk is complex object, not simple cube with smooth sides. For example, chunk may have through-hole and therefore behind chunk must be rendered.

abcdef

occlusion culling is what you need

geakstr

Ok. I spent some time for implementing occlusion culling (I want to believe that almost complete). But I have problems.

If I disabled frustum culling, occlusion culling worked and cull chunks not in frustum. But if I look on one chunk (behind him chunks placed, yes) chunks counter show me many chunks, not one. For demonstrate this, I attached screenshots. Actually, invisible chunks in camera frustum not culling, but chunks out of frustum ââ,¬â€ culling fine.

I don't understand where is problem. I think... Must I sort chunks before rendering?

Code:
1. Begin occlusion query https://github.com/geakstr/voxel-moxel/blob/occlusion-query/src/me/geakstr/voxel/model/Chunk.java#L453
2. Render black box scene https://github.com/geakstr/voxel-moxel/blob/occlusion-query/src/me/geakstr/voxel/model/Chunk.java#L453
3. Render real scene https://github.com/geakstr/voxel-moxel/blob/occlusion-query/src/me/geakstr/voxel/model/World.java#L118
4. Render calls https://github.com/geakstr/voxel-moxel/blob/occlusion-query/src/me/geakstr/voxel/game/Game.java#L50

UPD: Oh, I have read this article http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter06.html and understood ââ,¬â€ my implementation is very stupid :)