210 likes | 366 Views
3D Rendering Praktikum: Shader Gallery. The Rendering Pipeline. The Rendering Pipeline …. … what an „end user“ sees. The Rendering Pipeline …. … in pictures. Objects in 3D world. Geometry subsystem. 2D primitives. Raster subsystem. Color image. Rendering pipeline. User / Driver.
E N D
3D Rendering Praktikum:Shader Gallery The Rendering Pipeline
The Rendering Pipeline … … what an „end user“ sees. Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
The Rendering Pipeline … … in pictures Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
Objects in 3D world Geometry subsystem 2D primitives Raster subsystem Color image Rendering pipeline Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
User / Driver Vertex Stage Pixel Stage Texture 0 Texture 1 Texture 2 Texture 3 Overview Transform & Lighting Rasterizer Texturing Blending/Ops Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
Objects in 3D world Geometry subsystem 2D primitives Raster subsystem Color image Rendering pipeline Object coordinates Modelling transform affine World coordinates Model-View-Transformation Viewing transform affine Eye coordinates Normalizing transform Normalized (Clip-)coord. clipping 2D Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
Transformations • A transformation is like a function of a point • Modeling: • Define objects in „convenient“ coordinate systems • Multiply-instantiated geometry • Hierarchically defined linked figures • Viewing: • Window systems • Virtual camera • Perspective transformations Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
Point representation • Represent as row or column vector • Affects the kind of matrices we can multiply with Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
Transformation representation • Represent 2D transformations by a 2x2 matrix • If the point is a column vector • If the point is a row vector Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
Linear transformations • Scaling • Reflection S sx = sy uniform scaling Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
a Linear transformations • Shearing • Rotation around origin by 1 R(90°) Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
T Homogeneous coordinates! Affine transformations • Affine transformations: parallelism is preserved, length & angles not • All linear transformations can be written as matrix multiplication • What about translation ? • We want to write Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
General Camera Setup • Look at: • Position • Orientation • Frustum: • Camera parameters • Viewport: • 2D coordinate system Look at Frustum Viewport Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
Camera look at • Move camera C to originTranslate by –C • Build orthonormal frame„right“ R=DxU„zenith“ U=RxD • Adjust orientationRotation [R,U,D][X,Y,-Z] Up View direction Right Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
Frustum (Perspective Projection) y T t -z b B -n -f Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
Last Transformations • After all the projections we have: • Perspective division: • Viewport transformation: Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
User / Driver Vertex Stage Pixel Stage Texture 0 Texture 1 Texture 2 Texture 3 Overview Transform & Lighting Rasterizer Texturing Blending/Ops Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
Bresenham (Line Drawing) Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
Getting to Bresenham … /********************************* * Input: * xP: x-value of the startpoint * yP: y-value of the startpoint * xQ: x-value of the endpoint * yQ: y-value of the endpoint *********************************/ function drawLine(int xP, int yP, int xQ, int yQ) { x = xP; y = yP; d = 0; m = (yQ - yP) / (xQ - xP) while(true) { // put the pixel on the screen putPixel(x, y); if(x == xQ) break; x++; d += m; if(d > 0.5) { y++; d--; } } } Problem: • still floating point arithmetic Obersvation: • m is rational • d is rational Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group
Bresenham … function drawLine(int xP, int yP, int xQ, int yQ) { x = xP; y = yP; D = 0; H = xQ - xP; c = 2 * H; M = 2 * (yQ - yP); while(true) { putPixel(x, y); if(x == xQ) break; x++; D += M; if(D > H) { y++; D -= c; } } } Introduce the following integer variables: Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group