Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 40. Advanced 3D > Backface Culling

40.4. Backface Culling

When you're rendering a convex object by drawing its shell (broken up into lots of little polygons), there's one problem. Think of a simple object like a sphere. The shell of the sphere goes all the way around the sphere, of course. When you look at the sphere, however, you only see part of the shell. The back side is right there on the far side of the sphere, but if the sphere is opaque like a baseball, you can't see through to it. One way to solve this problem is to z-sort the polygons, drawing the front of the shell on top of the back, so that all you see is the opaque front side. However, drawTriangles() is drawing all the triangles on the same Graphics object at the same depth. (I'll show how to z-sort faces in the section "Z-Sorting, Shading, and Further Topics.") Another approach is to determine which part of the shell faces away from you and simply elect not to draw it. So in reality only the front half of the baseball would exist, but you'd never know. As you rotate the ball, the new parts that face you become visible. You can never see parts of it that face away from you. (If the object isn't convex, this guarantee breaks down.)

When you don't draw polygons that face away from you, those polygons are sometimes called single-sided; removing those faces from the list of polygons to draw is called backface culling. Beyond solving the depth sorting issue for convex objects, it's an easy way to speed up rendering, because (to make a rash generalization) around half of the surface is usually facing away from you.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint