190 likes | 410 Views
GameFX C# / DirectX 2005. The Rendering Pipeline. The Rendering Pipeline …. … what an „end user“ sees. The Rendering Pipeline …. … in pictures. User / Driver. Vertex Stage. Pixel Stage. Texture 0. Texture 1. Texture 2. Texture 3. Overview. Transform & Lighting. Rasterizer.
E N D
GameFXC# / DirectX 2005 The Rendering Pipeline
The Rendering Pipeline … … what an „end user“ sees. Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group
The Rendering Pipeline … … in pictures Jens Krüger & 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 Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group
Objects in 3D world Geometry subsystem 2D primitives Raster subsystem Color image Rendering pipeline Jens Krüger & 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 affin World coordinates Model-View-Transformation Viewing transform affin Eye coordinates Normalizing transform Normalized (Clip-)coord. clipping 2D Jens Krüger & 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 Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group
Point representation • Represent as row or column vector • Affects the kind of matrices we can multiply with Jens Krüger & 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 Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group
Linear transformations • Scaling • Reflection S sx = sy uniform scaling Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group
a Linear transformations • Shearing • Rotation around origin by 1 R(90°) Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group
T Affine transformations • All linear transformations can be written as matrix multiplication • What about translation ? • We want to write homogeneous coordinates Jens Krüger & 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 Jens Krüger & 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] Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group
Frustum y T t -z b B -n -f Jens Krüger & 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 Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group
Bresenham (Line Drawing) Jens Krüger & 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 Obersavtion: • m is rational • d is rational Jens Krüger & 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: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group