Download presentation

Presentation is loading. Please wait.

Published byShea Hudnell Modified over 2 years ago

1
1 z-buffer and shading ©Anthony Steed 1999

2
2 Overview n Coping with depth Scan-line depth buffering Z-buffer Recursive sub-division Trade-offs n gouraud shading n phong shading

3
3 Extending the AET n Easy enough if polygon do NOT intersect n Put all polygon edges into ET with extra depth information and proceed as before except … n … now consider overlapping ranges of edges

4
4 AET Example

5
5 AET Example Notes n Our edge table must contain data which enables us to look up z at at intersection point n From x1 to x2 only A is considered. n At x2 A and B are considered plane equations are solved to get depth A is closest so x2 to x3 is filled as A n At x3 A finishes so we draw B from x3 to x4 n At x4 B and C are considered, B in front etc… n Would usually store this in a 1D BSP tree for large numbers of polygons!

6
6 zbuffer n Don’t bother with per span tests - just test every pixel n Most common usage is a a full window sized array (M*N) of 16, 24 or 32 bit “depth” values. n Basic idea: For each pixel in each polygon –IF col = colour on polygon at unprojected point x,y –If z < ZBUF[x,y] set CBUF[x,y] = col Initialise buffer to Z_MAX

7
7 Zbuffer Details n Can do this in several ways n 1D z-buffer re-used on each scan line Process each polygon with separate AET Use as adjunct to extended AET for multiple polygons n Problems … Aliasing on depth (z-buffer tearing)

8
8 Scanning Depth into the Zbuffer n Now we have to write a z-value for each point directly from plane equation (re-calculate for each point) incremental across the scan-line (store z_start and dz) interpolate …

9
9 Interpolating Depth n Interpolate z along edges AND interpolate between edges on each scan-line (bi-linear interpolation) (X1,Y1,Z1) (X2,Y2,Z2) (XL,YL,ZL) (XR,YR,ZR)

10
10 Zbuffer Fill Example n General form of ET (y2,x1,dx/dy,z1,dz/dy) n ET[1] = ac (7,3,1/6,1,3/6) ab (4,3,4/3,1,1/3) n ET[4] = cb (7,7,-1,2,2/3) a=(3,1,1) b=(7,4,2) c=(4,7,4)

11
11 …Contents of AET n Scanline y=1 ac (7,3,1/6,1,3/6) ab (4,3,4/3,1,1/3) zspans 1 to 1 n y=2 ac (7,3.166,1/6,1.5,3/6) ab (4,4.333,4/3, 1.333, 1/3) zspans 1.5 to 1.333 n y3 ac (7,3.333,1/6,2.0,3/6) ab (4,5.666, 4/3, 1.666, 1/3) zspans 2 to 1.666

12
12 Recursive Subdivision Visibility n The window is covered by a polygon that is in front of all others (draw it) n The window does not intersect a polygon (draw nothing) n The window overlaps a single polygon (draw it clipped) n The window contains a single polygon (draw it unclipped) n ELSE quarter rectangle and repeat

13
13 Trade-Offs n Zbuffer can be inaccurate with few bits really simple to implement though! n Scan-line AET good for large polygons good coherency across lines requires non-intersecting polygons n zbuffer good for small, sparse polygons AET more time consuming to maintain

14
14 Gouraud Shading n Recall simple model for local diffuse reflection n Gouraud interpolates this colour down edges and across scan-lines in the same manner as we just did for depth

15
15 Gouraud Details n ET now contains (y2,x1,dx,z1,dz,r1,dr,g1,dg,b1,db) –(we are running out of registers!) n Problems not constant colour on rotation of points misses specular highlights

16
16 Phong Shading n Include specular component n Interpolate normals across the scan-line instead of colours n Recaptures highlights in the centre of polygons

Similar presentations

OK

CS248 Final Review Derek Chan and Abe Davis. CS248 Final Monday, December 8, 3:30 to 6:30 pm Closed book, closed notes Mainly from material in the second.

CS248 Final Review Derek Chan and Abe Davis. CS248 Final Monday, December 8, 3:30 to 6:30 pm Closed book, closed notes Mainly from material in the second.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on genetically modified crops Ppt on series and parallel combination of resistors in series Ppt on employee time management Ppt on waves tides and ocean currents activity Ppt on computer science subject Ppt on regional rural banks Production in the short run ppt on tv Ppt on content development services Ppt on area of trapezium Ppt on role of political parties in india