Advertisement Jump to content
Sign in to follow this  
Yours3!f

octree view frustum culling

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

hi there,

 

I'm trying to implement view frustum culling using an octree. I'm using aabb vs frustum testing to determine if the given octant is inside the view frustum or not. I used this tutorial to implement it:
http://www.lighthouse3d.com/tutorials/view-frustum-culling/geometric-approach-testing-boxes-ii/

 

it works well for small objects, however as the tutorial says there may be cases where the aabb's vertices are not inside the view frustum, or the view frustum's vertices are not inside the aabb, yet, the DO intersect. And I ran into exactly this problem, some of my octants are getting culled despite being clearly visible.

 

is there a common solution to this problem?

 

best regards,

Yours3!f

Edited by Yours3!f

Share this post


Link to post
Share on other sites
Advertisement

http://www.racer.nl/reference/vfc_markmorley.htm

 

Scroll down to "Is This Box In the Frustum?". It handles the 'awkward' cases.

 

thank you for the reply. I think I'm already doing this, but correct me if I'm wrong:
 

class plane : public shape
{
public:
  //define a plane by a normal and a point
  mm::vec3 normal, point;
  float d; //cache -(normal dot point)

  //...
};

class aabb : public shape
{
public:
  mm::vec3 pos; //center of the aabb
  mm::vec3 extents; //half-width/height of the aabb
  mm::vec3 min, max; //minimum/maximum apex of the aabb

  //...
};

  mm::vec3 aabb::get_pos_vertex( const mm::vec3& n )
  {
    mm::vec3 res = min;

    if( n.x >= 0 )
      res.x = max.x;

    if( n.y >= 0 )
      res.y = max.y;

    if( n.z >= 0 )
      res.z = max.z;

    return res;
  }

  float plane::distance( const mm::vec3& p )
  {
    return d + mm::dot( normal, p );
  }

  //aabb vs plane
  //is the aabb on the side of the plane where the normal vector points
  static bool is_on_right_side_ap( shape* aa, shape* bb )
  {
    auto a = static_cast<aabb*>(aa);
    auto b = static_cast<plane*>(bb);

    if( b->distance( a->get_pos_vertex( b->normal ) ) < 0 )
      return false;

    return true;
  }

  //does this aabb intersect this frustum?
  static bool intersect_fa( shape* aa, shape* bb )
  {
    auto a = static_cast<frustum*>(aa);

    for( int c = 0; c < 6; ++c )
    {
      if( !is_on_right_side_ap( bb, a->planes[c] ) )
        return false;
    }

    return true;
  }

I actually implemented that function from the article but it didn't help either.

Edited by Yours3!f

Share this post


Link to post
Share on other sites

turns out I messed up somewhere else, and my original implementation worked without having to modify the culling.

I tried it out with these settings:
6.25 million cubes placed in a grid on the x-z plane

camera with 25 degrees vertical fov

near plane = 1

far plane = 100

1000+ fps when using octree + brute force culling, no popping, nothing at all.

the octree culling usually left 150-200 objects visible, and the brute force culling (that I ran on the remaining visible objects) left 50-100, so I'd say it turned out really well.

I'll need to optimize the amount of memory the octree takes, as the application took 700MB, most of which was the octree...

but that's future work.

Share this post


Link to post
Share on other sites

What is performance when just using bruteforce culling?

 

under the same extreme conditions

2 that is two fps

Edited by Yours3!f

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!