Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Graphic pipeline  Scan-conversion algorithm (high level)  Pixels.

Similar presentations


Presentation on theme: "1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Graphic pipeline  Scan-conversion algorithm (high level)  Pixels."— Presentation transcript:

1 1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Graphic pipeline  Scan-conversion algorithm (high level)  Pixels covered by a triangle’s projection  Why scan-conversion is faster than ray-casting  Conversion of points and vectors to screen coordinates

2 2 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Scan-conversion algorithm (high level) For each triangle T do For each pixel P covered by the projection of T { If (T is in front of previously visited triangles seen through P) { Update the color of P} } The “in front of” test is accomplished by storing the distance to the nearest triangle encountered so far along ray(E,P) in the zbuffer Z[P] The color is computed through linear interpolation of the colors at the vertices of the triangle

3 3 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Graphic Pipeline  Model transforms  Vertex lighting  Viewing transform  Frustum clipping  Perspective transform  Slope computation  Scan-conversion

4 4 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Conversion screen coordinates Screen center O, horizontal axis unit vector I, viewing direction K.  Compute the (x,y,z) coordinates of a point Q in the screen coordinate system K J I O x=OQI y=OQJ z=OQK Q

5 5 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Frustum

6 6 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac  What does it do? –Trims each triangle to the portion that projects onto the screen  Why? –To avoid processing pixels that do not exist  How? –Could (should?) do this during scan-conversion clip the range of L to the vertical range of the screen clip the pixel range [S..E] to the horizontal range of the screen –Usually done as a separate preprocessing stage In model space (before perspective transform) –Intersect the triangle the viewing frustum »Intersection of 5 or 6 half-spaces Or in image space (after perspective) –Using axis-aligned half-spaces Clipping

7 7 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Clipping a triangle by a half-space  Compute the intersection of triangle (A,B,C) with half-space H(Q,N) defined by {P:NPQ>0} –If (NAQ)(NBQ)<0 Insert intersection point M –Binary search or –Division »t:= NAQ / NBA »M:=A+tAB –Repeat for other 2 edges –Discard bad vertices (B) –Triangulate  How complex can the result be? –Block/plane intersection : convex hexagon –Intersect it with a triangle N Q A BC M Could we get 10 vertices?

8 8 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Perspective  Transform the model so that the (x,y) of each vertex correspond to its projection on the screen.  But if we set z to 0, we will not know what is hidden We need a perspective transform that preserves depth order!

9 9 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Pixels covered by a triangle’s projection  Their center must fall inside the projection of the triangle  We need only to worry about the pixels inside the axis aligned rectangle around the projection of T  Could test each one of them against the triangle (expensive)  Could update linear inequality of the 3 clipping half-spaces –F(x+1,y) = f(x,y) + constant  Usually done in scan-line –Establish leading and trailing pixels –Using slope of edges

10 10 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac A naïve 3D graphics rasterization process Clear z-buffer Z[*,*] and back frame buffer I[*,*] For each triangle (A,B,C) do Lit A, B, C using normals, surface attributes, lighting parameters Transform vertices {A’=dA/(d+A.z); B’=dC/(d+B.z); C’=dC/(d+C.z)} Compute slopes for c (color), z (depth), and leading/trailing edges For each scanline L covered by triangle (A’,B’,C’) do Compute pixel range [S..E] by interpolation on leading/trailing edges Compute z and c at pixel (S,L, by interpolation on the leading edge For each pixel P in [S..E] do Compute z and c using interpolation If z < Z[P,L] then {Z[P,L]:=z; I[P,L]:=c} Swap back and front frame buffer to show image PSE L

11 11 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Rasterization costs  Per vertex –Lighting calculations –Perspective transformation –Slopes calculation  Per pixel –Interpolations of z, c (and leading trailing edges, amortized) –Read, compare, right to update the z-buffer and frame buffer

12 12 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Ray-casting / scan-conversion similarities  Ray-casting: –For each pixel P do For each triangle T projecting over P do –Decide if the triangle is visible –Compute reflected color and store in the pixel  Scan-conversion: –For each triangle T do For each pixel P covered by the projection of T do –Decide if the triangle is visible –Compute reflected color and store in the pixel

13 13 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Scan-conversion is faster than ray-casting  Ray casting consider all ray-triangle pairs.  Scan-conversion only considers pixels covered by each triangle. –10,000 times less work if you have 10x10 pixel triangles  Ray-casting requires multiplications and divisions for selecting which triangles cover a pixel and for computing the corresponding depth.  Scan-conversion uses a constant number of multiplications and division per triangle (to compute vertex projections and slopes), but only additions to test which pixels are covered and to compute the color and depth for each pixel.


Download ppt "1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Graphic pipeline  Scan-conversion algorithm (high level)  Pixels."

Similar presentations


Ads by Google