PDA

View Full Version : Occlusion Culling Technique



Luuk van Venrooij
22-10-2007, 06:40 PM
Everyone who ever has implemented an octree knows that the scene can have a lot of overdraw unless you have some sort of occlusion culling. There are many different techniques to implement it. After trying an image based technique and hardware occlusion culling tests with not much succes I decided to implemented my own.

It works with occlusion planes and can cull boundingboxes which I use in the octree of the engine. It creates lines from the camera to the 8 points of the boundingbox and checks if they pas thought the occlusion plane. If one of the lines doesn`t go through the occlusion plane then the boundingbox is visible and the content of the box can be rendered. A pretty simple technique but it works pretty well.

The demo can be found here:
http://www.genesisdevice.net/otherprojects/occlusioncullingexperiment.html

Ñuño Martínez
22-10-2007, 09:06 PM
Very interesting. I planed a voxel based engine few years ago and I decided to use octrees but it was too slow. As you say there was a lot of overdrawing. I'll study your code and may be I'll can success with that project.

Luuk van Venrooij
23-10-2007, 06:08 AM
This technique I believe can be used verry efficiently for this. Tonight I`m going to work on some optimalisations in the line-quad collision to make it faster for large scale use.

NecroDOME
23-10-2007, 11:56 AM
I will take a look when I get home. I'm also interested for in this technique.

technomage
23-10-2007, 12:07 PM
very interesting indeed. I'm gonna have a play with this as well :)

Luuk van Venrooij
23-10-2007, 08:15 PM
Hope you find it usefull:). I just added it to my engine and it works great. The only prob is now that I have to place my occlusion planes manually. The next step will be generating the OC planes:).

NecroDOME
24-10-2007, 05:02 PM
I got some optimization: now you check a cube (8 lines). why not make a "billboard" of your cube. I don't say this works in all situations, but you cast 4 lines instead of 8. Just turn the billboard towards the camera.

Luuk van Venrooij
24-10-2007, 10:00 PM
Not a bad idea, but is has some drawbacks. First of all the size off the billboard is tricky. To small and the object in the box can be culled even when it`s visible. To large and the object might not be culled even if its invisible. Even calculating the size is difficult. A high tower for example may use a smaller bilboard when viewed from above then when viewed from the front. How would one calculate this? Also when this calculation is done on runtime would it be faster then calculating the 4 extra lines? Also the billboard must rotate towards the camera. This requires some calculations to. In my opinion using the AABB best solution.

On another note, I optimised the calculations quite a bit today:). The most costly part of the calculation was checking if the line intersection of the plane is inside the quad. I did this by calculating the angles between the intersection point and the quadpoints. If these added to 360 degrees the lines passes though the quad. This however does a lot of costly arccos operations. I found a method on the internet without using this. After some time test the calculations 40 % faster in worse case! Not bad.

NecroDOME
25-10-2007, 05:50 AM
A tower is a bad example, but a sphere or other round/square thingy would be exelent for billboard culling.

Luuk van Venrooij
25-10-2007, 06:22 AM
True, but this would lead to a state where the designer has to chose between different OC methods. I rather just keep it simple:D.

How is your Necro3d Engine 2 comming allong btw? Just read the latest GameDev magazine:). Sound verry interresting the plugin structure for all the modules:). Also what kind of culling methods do u use?

NecroDOME
26-10-2007, 09:43 AM
Necro3D - its working :)
plugin structure took a lot of work. We managed to create a plugin that contains the game, so the engine manage part op the game.

I don't have any visual shots so far. But there will be soon :) .