Thread: Backface Culling in Lesson10 NeheGL Tutorials

  1. #1

    Backface Culling in Lesson10 NeheGL Tutorials

    I have tried to perform backface culling in the code of lesson10 nehe's tutorials, and i succeeded.

    1. I suppose that the camera position is 0,0,0 and it's direction is 0,0,-1 initially.

    2. I rotate the camera direction in the same direction as the rotation of the scene, but translate the camera position in opposite direction.

    3. I then apply the plane eqn. taking the camera as a plane and check all vertices of all polys again it.

    4. If all vertices of a polygon lie to the back of the camera, I mark it as not to be displayed.

    5. It works!

    6. Why ?

    (note : nothing else works - I've tried everything else)

    plz. help

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    i don't understand what your asking.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Not sure what you are asking here. Backface culling works because if a polygon is facing in a positive z direction, it is facing away from the camera/viewer. If it is facing in a negative direction then it is facing the camera/viewer.

    By taking the cross-product of two adjacent edges of the polygon you can determine which way the polygon is facing.

    However, there is a catch. In order for backface culling to work correctly you must know what type of coordinate system you are using.

    This simple, and not always accurate, backface cull will only work when all polygons are designed so that when they are viewed from their visible sides, the vertexes proceed around the polygon in a counterclockwise direction.

    z=(x1-x0)*(y2-y0)-(y1-y0)*(x2-x0) where

    x0,y0,z0 = first vertex
    x1,y1,z1 = second vertex
    x2,y2,z2= third vertex

    This is a simpler version of backface culling. It will only work when objects are close to the center of your display.

    For a better backface cull:
    (used float, but recommend fixed point)
    float c=

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Does Oblivion implement backface culling?
    By cboard_member in forum A Brief History of
    Replies: 13
    Last Post: 07-14-2006, 10:53 PM
  2. should update their tutorials.
    By PorkyChop in forum C++ Programming
    Replies: 17
    Last Post: 09-19-2004, 10:51 PM