Results 1 to 5 of 5

Thread: Best way to do clipping?

  1. #1
    Member Newbie
    Join Date
    Dec 2010
    Posts
    40

    Best way to do clipping?

    In general I think that it's better to let the GPU do graphics related stuff. I wouldn't say there is a discussion here. One of the things that I would like to leave to the dedicated hardware is the decision about what objects should be drawn.
    However, if I want to do this I still have to build the whole environment, which can be pretty big, and send it to the GPU. Besides, some of this work can possibly be fairly expensive, like building an animation. If I know in advance that some objects won't be seen I can save some work not only to the GPU, but to the CPU as well.
    I read something about OpenGL feedback, but that obviously wouldn't really solve the problem. Besides, the FAQ clearly says:

    Typically, OpenGL implementations don't provide a fast feedback mechanism. It might be faster to perform the clip test manually. To do so, construct six plane equations corresponding to the clip-coordinate view volume and transform them into object space by the current ModelView matrix. A point is clipped if it violates any of the six plane equations.
    So my question is: what is the best way to find out if an object has to be drawn or not? Better everything done by the GPU? By the CPU? Divide between the two?

    Thanks

  2. #2
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,675

    Re: Best way to do clipping?

    what is the best way to find out if an object has to be drawn or not?
    There isn't one. Culling is not something for which there is a general solution. There are many solutions, but each have their benefits and drawbacks. There isn't one that could be considered "best" by any measure, nor is there one that could even be considered "average" or "default".

    Indeed, there aren't a lot of "best ways" to do anything in graphics. Pretty much everything is a tradeoff of one form or another. The only way to know what the "best way" for your needs is is to learn several ways of doing something, then measure the performance for your application, and pick the one with the lowest performance.

  3. #3
    Member Newbie
    Join Date
    Dec 2010
    Posts
    40

    Re: Best way to do clipping?

    Wow, that's a fast answer, thank you.

    Okay, so basically everything is up to me. Which leaves me with a lot of flexibility, but also with a lot of doubts.
    Are there maybe any references I can look at? Books? Articles? Some generic considerations about performance issues? Would be nice to clear things up a bit

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Best way to do clipping?

    The general idea is if you can cull complex objects quickly on CPU side, do it. For example by checking the bounding box against frustum pyramid.
    If the check involves complex work for a lot of triangles, it will probably not be worth it.
    Hardware occlusion queries can help too, if you have big occluders such as buildings hiding complex geometry.
    This overview can help :
    http://geck.bethsoft.com/index.php/Occlusion_Culling
    For OQ to be efficient, it is best to work on crude placeholders, and do other stuff before asking for results (for better paralellism).

  5. #5
    Member Newbie
    Join Date
    Dec 2010
    Posts
    40

    Re: Best way to do clipping?

    Quote Originally Posted by ZbuffeR
    The general idea is if you can cull complex objects quickly on CPU side, do it. For example by checking the bounding box against frustum pyramid.
    If the check involves complex work for a lot of triangles, it will probably not be worth it.
    yeah, that's more or less what I was thinking. My idea would be to compute a rough minimum and maximum value for x,y, and z. All objects that have one of the coordinates outside that range will be excluded. In that way the CPU gets only light work, but saves a lot to the GPU, which will only have to do the more detailed filtering.

    Quote Originally Posted by ZbuffeR
    Hardware occlusion queries can help too, if you have big occluders such as buildings hiding complex geometry.
    This overview can help :
    http://geck.bethsoft.com/index.php/Occlusion_Culling
    For OQ to be efficient, it is best to work on crude placeholders, and do other stuff before asking for results (for better paralellism).
    Interesting link, thanks. I was expecting something like that to give more work to the CPU than necessary. The computations behind that don't look trivial, and my first thought would be to leave them to the GPU. Maybe I'll have to look at it.

Similar Threads

  1. 4D clipping
    By Mungo in forum OpenGL: General
    Replies: 3
    Last Post: 05-06-2004, 06:58 AM
  2. how to do clipping?
    By candy in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-11-2004, 04:36 AM
  3. Replies: 1
    Last Post: 09-02-2003, 01:45 PM
  4. Clipping (not clipping) in opengl
    By FunkyLovin in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 06-04-2001, 05:08 AM
  5. 3d clipping
    By vic in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 11-04-2000, 08:05 AM

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