Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

johnp

My Direct3D/Octree Tip

This topic is 6918 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!