cs 497 computer graphics
Download
Skip this Video
Download Presentation
CS 497: Computer Graphics

Loading in 2 Seconds...

play fullscreen
1 / 14

CS 497: Computer Graphics - PowerPoint PPT Presentation


  • 71 Views
  • Uploaded on

CS 497: Computer Graphics. James Money. Back Face Culling. The idea behind back-face culling is to remove faces of an object that are obscured by other faces of the same object. X. Gray polygons are back facing. Z. Back-Face Culling.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' CS 497: Computer Graphics' - yaholo


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
back face culling
Back Face Culling

The idea behind back-face culling is to remove faces of an object that are obscured by other faces of the same object.

X

Gray polygons are back facing

Z

back face culling1
Back-Face Culling

It is easy to determine if a polygon is back facing: the Z component(C in Ax+By+Cz+D=0) is <0.

Some restrictions:

  • The normals for all the faces must face outward for objects.
  • Points in a polygon, thus must be created in a clockwise fashion.

This process typically halves the number of polygons, but not always.

All we need to do is add a Boolean Function for visibility to the Polygon3D object.

visible surface determination
Visible Surface Determination

Now that you have reduced the number of polygons to draw, which ones are you actually seeing?

What about overlapping polygons???

The answer lies in algorithms called visible surface determiners.

z buffer algorithm
Z Buffer Algorithm

One of the most simple and most commonly used VSA’s is the Z Buffer algorithm. It is an image precision algorithm.

It uses the frame buffer for the picture, but also a Z Buffer, where instead of pixel values, it has the Z depth of the closest polygon.

slide6
void zBuffer(void){

int x,y;

double *zBuf

zBuf=new double[XMAX*YMAX];

for(y=0;y<YMAX;y++)

for(x=0;x<XMAX;x++){

SetPixel(hDC,x,y,RGB(0,0,0));//background

zBuf[y*XMAX,+x]=Zv.max-Zv.min;//as far back //as we can go!

}

for(each polygon){

for(each pixel in polygon’s projection){

double pz=-[poly’s Z-value at (x,y)];

if (pz<=zBuf[y*XMAX+x]){

zBuf[y*XMAX+x]=pz;

SetPixel(hDC,x,y,PixelColor);

}

}

}

}

determining z
Determining Z
  • Remember for polygons we can get the normal from 3 points of the polygon:
      • Ax+By+Cz+D=0
  • For our first point we find z by:
determining z1
Determining Z

However, this is expensive to computer for every (x,y). We can do this by increments:

  • At
  • At
  • If C=0 then use an average of Z at the vertices.
filling a 2d polygon
Filling a 2D Polygon

In order to draw these 3D polygons with the Z Buffer algorithm, we need to design our own function to draw the polygons.

filling a 2d polygon1
Filling a 2D polygon

First we must compose the points of the polygon into edges:

AB

EA

BC

DE

CD

filling a 2d polygon2
Filling a 2D polygon
  • First we must create a structure for each edge to contain:
    • Ymin
    • Ymax
    • X - the X coordinate of point with Ymin
    • 1/m or the X increment
filling a 2d polygon3
Filling a 2D polygon
  • Next we create a table for these edges sorted by Ymin as on page 98.
  • These edges are sorted by the X coordinate in increasing order.
  • This makes up the edge table.
filling a 2d polygon4
Filling a 2D polygon
  • Now you will have Active Edge Table(AET) for all the active edges on the line y=xxx. You initialize it to empty.
  • Set y to the smallest y in the edge table.
filling a 2d polygon5
Filling a 2D polygon
  • Repeat until Y=max Y of polygon(or until AET and ET are empty).
    • Move from ET to AET any edge whose Ymin=y.
    • Remove from AET any edge whose entry has y=Ymax. Sort AET on increasing X.
    • Fill in pixels using pairs of X coordinates on line y.
    • Increment y by 1.
    • Add 1/m to x.
ad