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.
occlusion culling is what you need
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 (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 (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 (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 (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 (http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter06.html) and understood ââ,¬â€ my implementation is very stupid :)
(https://dl.dropboxusercontent.com/s/74mnsnbl4ada8fa/Voxel_Moxel__41_fps_12224096_chunks_506892_triangles_2015-02-09_21-52-56.png_12001266_2015-02-09_22-07-33.png?dl=0)