Results 1 to 5 of 5

Thread: How to do Culling?

  1. #1
    Guest

    How to do Culling?

    Hello,

    I have a question about Culling:
    a) How can I use Backface-Culling?
    b) How can I cull Objects which are behind the Player?

  2. #2
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Nov 2010
    Posts
    2,466

    Re: How to do Culling?

    this are 2 sorts of culling

    a/ glEnable( GL_CULL_FACE ), u can also do the math yourself but 1/ it might be slower on hardware t+l cards 2/ u're restricted to using GL_TRIANGLES ie u can use strips
    b/ get the near clipplane (info in the faq for this) and test if the objects BB or all polygons are in front of it.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Re: How to do Culling?

    You can write a decent culling function for frustrum culling (dont draw objects outside of the view frustrum). I have an example down the bottom. Note that this is rather slower (alot) than using advanced techniques such as Quadtrees. But it is far better than no culling at all or just "behind the camera" culling.

    int cull(float x, float y, float z){
    if((z + zoom) >= -1.0 &#0124; &#0124; -(z + zoom) < 2.4*(x-4.0) &#0124; &#0124; -(z + zoom) < -2.4*(x-3.5)){
    return 1;
    }
    else{
    return 0;
    }
    }

    This assumes 45 degree viewing frustrum...
    :: Sleep is a poor substitute for caffeine ::

  4. #4
    Senior Member Regular Contributor
    Join Date
    Sep 2004
    Location
    Montreal
    Posts
    132

    Re: How to do Culling?

    There another quick way of culling objects and it involves the view volume. Whatever that is not inside it, you remove it.

    Today, octrees and BSPs seem to be popular but these don't apply to some situations.

    V-man

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Dec 2007
    Posts
    1,077

    Re: How to do Culling?

    BSP's are getting old fashioned right now. They are too restrictive, and get complicated if you want dynamic scenes. Collision detection may be faster. We also don't need back to front rendering anymore, since when using stencil test, zbuffer come for free!
    I'd try to use a combination of sector/portal and octree.

Similar Threads

  1. How is culling done
    By Hemalatha in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 11-26-2005, 01:49 AM
  2. How is culling done
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-24-2005, 07:59 AM
  3. culling
    By grimoire in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-27-2004, 03:51 AM
  4. how to use culling
    By bigtime in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-30-2003, 12:08 PM
  5. culling
    By frogger in forum OpenGL: Advanced Coding
    Replies: 13
    Last Post: 06-04-2000, 04:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean