Jump to content

  • Log In with Google      Sign In   
  • Create Account

octree view frustum culling


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Yours3!f   Members   -  Reputation: 1336

Like
2Likes
Like

Posted 01 March 2014 - 05:08 AM

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, 01 March 2014 - 05:10 AM.


Sponsor:

#2 mark ds   Members   -  Reputation: 1248

Like
5Likes
Like

Posted 01 March 2014 - 05:54 AM

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

 

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


Edited by mark ds, 01 March 2014 - 05:55 AM.


#3 Yours3!f   Members   -  Reputation: 1336

Like
0Likes
Like

Posted 02 March 2014 - 03:41 AM

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, 02 March 2014 - 04:03 AM.


#4 Yours3!f   Members   -  Reputation: 1336

Like
1Likes
Like

Posted 13 March 2014 - 07:49 AM

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.



#5 kalle_h   Members   -  Reputation: 1387

Like
0Likes
Like

Posted 13 March 2014 - 11:28 AM

What is performance when just using bruteforce culling?



#6 Yours3!f   Members   -  Reputation: 1336

Like
0Likes
Like

Posted 16 March 2014 - 02:35 AM

What is performance when just using bruteforce culling?

 

under the same extreme conditions

2 that is two fps


Edited by Yours3!f, 16 March 2014 - 02:35 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS