Results 1 to 3 of 3

Thread: Debug/Feedback Backface Culling

  1. #1
    Junior Member Newbie
    Join Date
    May 2009
    Posts
    2

    Debug/Feedback Backface Culling

    Hi all,
    I just entered openGL.
    And already run into problems .
    For geometric calculations, I need information about triangles that are culled.
    I tried program the culling myself but it somehow does not match with the culling of opengl.
    See image: http://img268.imageshack.us/img268/7...ingproblem.jpg (this is the inner side of a head. i asked opengl to cull the front faces away)
    OpenGL and my calculations are not the same. I colored the triangles according to my culling test, and basically, all triangles should be red but some are not). So I was wondering how I can debug/reproduce openGL's calculations. From the outcome, I think openGL's results are correct.
    In the code, there is a
    gluLookAt(x, y, z,
    x + lx,y + ly,z + lz,
    0.0f,1.0f,0.0f);
    I then used the lx,ly, lz vector and multiplied it with the computed normal vector of my triangles (or the vertices, that i pushed into openGL during drawing).
    What might be wrong?
    The culling operation itself is not so hard, so I wonder what might be the error. Maybe I cannot use lx,ly,lz as a view vector?
    Would be super if someone could help, it is for a freeware tool!
    KR,
    Ben

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,294

    Re: Debug/Feedback Backface Culling

    Multiply the triangle's vertices by the final model-view-projection matrix ( = projection * model_view) . To find if a triangle should be culled, find the cross-product of two of its edges. If z is negative (or positive, I don't remember), then the triangle is culled. That's the way gpus decide whether to cull, afaik.

  3. #3
    Junior Member Newbie
    Join Date
    May 2009
    Posts
    2

    Re: Debug/Feedback Backface Culling

    Hi Ilian,
    i implemented your suggestion and it seems that you were correct. Applying the transformation to the vertexes resulted in equivalent culling. I think I need more knowledge of the mathematical fundamentals. Appearently,the perspective transformations do not leave the triangle orientation invariant. Which I thought it must, as the matrices seemed linear/affine transformations.
    Either way, thanks a lot.
    I now have a point for doing research.

Similar Threads

  1. Regarding Backface culling
    By myk45 in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 06-09-2012, 12:10 PM
  2. "Second" backface culling
    By LaBasX2 in forum OpenGL: Advanced Coding
    Replies: 11
    Last Post: 08-12-2002, 03:28 AM
  3. Debug help (backface culling)
    By Ruka in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-16-2002, 04:37 AM
  4. backface culling
    By blender in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 04-26-2002, 10:29 AM
  5. 3d backface culling
    By imported_Theo in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-19-2000, 08:19 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