My Direct3D/Octree Tip

Started by
4 comments, last by johnp 23 years, 11 months ago
Time to provide some info rather than just ask questions. I have found a really easy way of rendering an octree using Direct3D immediate mode. D3D immediate mode has a function called ComputeSphereVisibility which given a bounding sphere (or a list of) in world space, it tells you if the sphere is inside the view frustrum, outside or clipped. By passing it the bounding spheres of the eight children cubes of a node, it will tell me which nodes are in view and obviously which nodes to examine further. When I get to a node with polygons I render and let Direct3D do clipping etc. I have not tried this but is sounds like an easy way (for a beginner like me) to cut down the number of polygons drawn. It would be interesting to get feedback on this idea as it sounds too easy and i''m sure I am missing something. I am going to try it anyway and will update this post with the results. I hope this helps someone as the DirectX documentation is crap. john_pullen@yahoo.com
Advertisement
After about 4 or 6 months, I finally know what that does.
Firstly, using a bounding sphere would not be as effective as a bounding cube (for this application) as it could erroneously report that one of your sectors is actually in view when it isn''t (ie. the area where the sphere extends beyond the cube). Secondly, I believe ComputeSphereVisibility is pretty slow? But don''t quote me on that. Of course, it may be quick enough for this purpose, so I don''t know.
While the bounding sphere might wrongfully report the node to be visible it is much faster to use bounding spheres than bounding boxes since all that is needed to cull the sphere is one test against each of the six view frustum clipplanes. For bounding boxes you would need 8*6 tests, one for each corner and clipplane.
If you want more accurate culling of the octree nodes then I suggest you first make a bounding sphere test and then, if the sphere is inside the viewfrustum, make a bounding box test. This will infact be faster than making only bounding box tests, since most tests will not pass the sphere test, thus saving you much work.

johnp:
From what you describe it sounds like you have the right idea. And you are right it is easy, but not too easy.
If you want to make it more difficult you can expand on the testing so that octree nodes that are occluded by other nodes wont be rendered.



WitchLord

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I first do a very simple test to find out if the actual octree node could be visible at all (this includes node occlusion tests). If this test returns TRUE, I check if it is entirely or partially within the frustrum. If it is entirely within the frustrum, I can skip the checks for all childs. If it is partially within the frustrum, I check the child visibility. This works pretty quickly.

DaBit.

Any tips on Octree occlusion tests?

This topic is closed to new replies.

Advertisement