Lecture 8: 1 October 2002Today:Viewport CoordinatesPolygon Scan Conversion & FillingSubtleties of Floating Point vs. IntegerShadow RulesHidden Surface EliminationSpatial CoherenceThursday:Assignment 2 (*scene exhibition)Mysteries of homogeneous coordinates explainedAssignment 4 (Polygon fill with ivscan)postedFriday:Assignment 3 (Polygon wireframe rendering) due 5pmMIT 6.837 Computer Graphics Tuesday, 1 October 2002 (L8) Page 1Framebuffer and Discrete CoordinatesUsually “RGB” or “24-bit” or “full color” framebuffer2D array of xres × yres pixels (picture elements)RGB colordepth... depthyres xres At each pixel can be stored:Color (3 × 8 bit RGB = 24 bits, sometimes 36)Depth (b =24orb = 32 bits: values 0..2b− 1)Other attributes: α, stencil, window ID, etc.High-end machine may store > 200 bits per pixel!MIT 6.837 Computer Graphics Tuesday, 1 October 2002 (L8) Page 2Discretizing the Normalized View VolumeNDC parallelepiped is x = ±1, y = ±1, z = ±1Map this parallelepiped into 3D “device coordinates”Normalized Device Coordinates3D Screen Spacex1x2y1y2 xres yres0 xres−1 0 yres −1zres0 2b −1S(−1, −1, −1)(1, 1, 1)yxzx, y interval:range of values depends on framebuffer resolutiontypically specified as a rectangular “viewport”:(x1,y1)to(x2,y2)z interval:range of values depends on precision of (depth buffer)b bits: unsigned integer in range [0..2b− 1]MIT 6.837 Computer Graphics Tuesday, 1 October 2002 (L8) Page 3Viewport Transformation (first attempt)Pixel centers at integer coordinates; pixel (0, 0) at lower leftEasy: map x ∈ [−1.. +1]toxS∈ [x1..x2],and map y ∈ [−1.. +1]toyS∈ [y1..y2]x1x2y1y2 xres yres0 xres−1 0 yres −1Then:xS= x1+x+12(x2− x1)yS= y1+y+12(y2− y1)... Problem ?MIT 6.837 Computer Graphics Tuesday, 1 October 2002 (L8) Page 4Viewport Transformation (incorrect)This transform maps NDC extreme points to pixel centersxS= x1+x +12(x2− x1); yS= y1+y +12(y2− y1)Example:xS(−1) = x1+−1+12(x2− x1)=x1; yS(−1) = y1+−1+12(y2− y1)=y1x1x2y1y2Pixels have non-zero extent,which we must take into account!MIT 6.837 Computer Graphics Tuesday, 1 October 2002 (L8) Page 5Viewport Transformation (corrected)Accounting for pixel extents means mapping:x ∈ [−1.. +1]toxS∈ [x1−12..x2+12]y ∈ [−1.. +1]toyS∈ [y1−12..y2+12]0h−10w−1x1x2y1y2( x1 − 1/2, y1− 1/2 )( x2 + 1/2, y2 + 1/2 )xS= x1− 0.5+x +12(x2− x1+1)yS= y1− 0.5+y +12(y2− y1+1)Note: this is a floating point coordinate system!Depth (z ∈ [−1.. + 1]) is mapped linearly as:zS=z +12(2b− 1)MIT 6.837 Computer Graphics Tuesday, 1 October 2002 (L8) Page 6Viewport TransformationMatrix
View Full Document