Table of Contents Glide Programming Guide



Download 6.22 Mb.
Page28/106
Date03.02.2023
Size6.22 Mb.
#60547
1   ...   24   25   26   27   28   29   30   31   ...   106
GLIDEPGM

8Backface Culling


Glide supports backface culling based on the signed area of a polygon. When Glide renders a polygon, the first step is to divide the polygon into triangles, the rendering primitive of the Voodoo Graphics hardware. Figure Rendering Primitives.4 shows a pair of triangles whose vertices have been labeled according to the rule given above.
Figure Rendering Primitives.4 Polygon orientation and the sign of the area.
The polygons on the left are defined relative to an origin in the upper left corner; the ones on the right have the origin in the lower left corner. Clockwise and counter-clockwise refer to the direction that the vertices are traversed in alphabetical order.

The sign of the area of the triangle can be used for backface culling (quickly discarding triangles that won’t be visible on the screen before they are rendered). Because the area must be computed anyway, this is a cheap way to cull. However, removing back-facing triangles earlier may be advantageous. For example, if back face removal is performed before lighting, then the computationally expensive lighting calculations for invisible triangles can be skipped.


The Glide function grCullMode() has one parameter, a mode that can be set to GR_CULL_NONE, GR_CULL_NEGATIVE, or GR_CULL_POSITIVE. When the culling mode is GR_CULL_NONE, the default value, all polygons are rendered to the screen regardless of their signed area. Otherwise, if the sign of the area matches the mode, then the triangle is rejected. grCullMode() assumes that GR_CULL_POSITIVE corresponds to a counter-clockwise orientation when the origin is in the lower left corner of the screen, and a clockwise oriented triangle when the origin is in the upper left corner, as shown in Table Rendering Primitives.1.
void grCullMode( GrCullMode_t mode )

Note that grCullMode() has no effect on points and lines, but does effect the rendering of triangles and polygons.



  1. Table Rendering Primitives.1 The location of the origin affects triangle orientation and the sign of its area.



If the origin location is

and the triangle orientation is

then the sign of the area will be

GR_ORIGIN_LOWERLEFT

clockwise

negative

GR_ORIGIN_LOWERLEFT

counter-clockwise

positive

GR_ORIGIN_UPPERLEFT

clockwise

positive

GR_ORIGIN_UPPERLEFT

counter-clockwise

negative



Download 6.22 Mb.

Share with your friends:
1   ...   24   25   26   27   28   29   30   31   ...   106




The database is protected by copyright ©ininet.org 2024
send message

    Main page