Jump to content
  • Advertisement
Sign in to follow this  
matt_j

[newbie] Octree occlusion issue

This topic is 3980 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

I've noticed that it doesn't seem to work if you check if the points in an octree node are within the frustum to determine if a given node should be rendered, if the camera is oriented in such a way that none of the points appear within the frustum. This can easily occur if the camera is inside a given node. I could just align the camera with a side of the cube. This could be the root node, which is very large; none of the points are within the frustum so nothing is rendered. What are some possible solutions to this?

Share this post


Link to post
Share on other sites
Advertisement
The correct way to test if a box is inside the frustum is to check if all of the box's vertices are outside of one of the frustum planes (doesn't matter which one). This article has some code that does this (it assumes the box is axis-aligned, but if you're using an octree that's just what you need), and might also contain some other information useful to you.

Share this post


Link to post
Share on other sites
It sounds from the question like you're currently testing visibility by seeing if any of the corner points of a node are inside the frustum. That's not the best way to go about it, as you'll have the sorts of problems you mentioned. Googling for "frustum aabb" produces lots of nice stuff, try this from Toymaker's Direct3D FAQ: http://www.toymaker.info/Games/html/direct3d_faq.html - about half way down the page there's a function.

[eep, beaten to it]

Share this post


Link to post
Share on other sites
here is my code of frustum-aabb if it helps anyone

        public CollisionTestResult contains(AABB aabb)
{
CollisionTestResult result = CollisionTestResult.Inside;

for (int i = 0; i < 6; i++)
{
Vector3 p = aabb.Min;
if (planes.A >= 0)
p.X = aabb.Max.X;
if (planes.B >= 0)
p.Y = aabb.Max.Y;
if (planes.C >= 0)
p.Z = aabb.Max.Z;

Vector3 n = aabb.Max;
if (planes.A >= 0)
n.X = aabb.Min.X;
if (planes.B >= 0)
n.Y = aabb.Min.Y;
if (planes.C >= 0)
n.Z = aabb.Min.Z;

if ((planes.A * p.X + planes.B * p.Y + planes.C * p.Z + planes.D) < 0)
return CollisionTestResult.Outside;
else if ((planes.A * n.X + planes.B * n.Y + planes.C * n.Z + planes.D) < 0)
result = CollisionTestResult.Intersects;
}
return result;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!