jens krüger & polina kondratieva – computer graphics and visualization group computer graphics &...

Download Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization GameFX C# / DirectX 2005 The Rendering Pipeline

If you can't read please download the document

Upload: byron-cox

Post on 17-Jan-2018

218 views

Category:

Documents


0 download

DESCRIPTION

computer graphics & visualization Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group The Rendering Pipeline … … in pictures

TRANSCRIPT

Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group computer graphics & visualization GameFX C# / DirectX 2005 The Rendering Pipeline computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group what an end user sees. The Rendering Pipeline computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group The Rendering Pipeline in pictures computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group Pixel Stage Vertex Stage User / DriverOverview Transform & Lighting Rasterizer Texturing Blending/Ops Texture 3 Texture 2 Texture 1 Texture 0 computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group Rendering pipeline Geometry subsystem Raster subsystem Objects in 3D world Color image 2D primitives computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group Rendering pipeline Geometry subsystem Raster subsystem Objects in 3D world Color image 2D primitives 2D Object coordinates World coordinates Eye coordinates Modelling transform Viewing transform Normalizing transform Normalized (Clip-)coord. clipping affin Model-View-Transformation computer graphics & visualization Jens Krger & 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 computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group Point representation - Represent as row or column vector - Affects the kind of matrices we can multiply with computer graphics & visualization Jens Krger & 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 computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group Linear transformations - Scaling - Reflection s x = s y uniform scaling S computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group Linear transformations - Shearing - Rotation around origin by a 1 R(90) computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group Affine transformations - All linear transformations can be written as matrix multiplication - What about translation ? - We want to write T homogeneouscoordinates computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group General Camera Setup - Look at: - Position - Orientation - Frustum: - Camera parameters - Viewport: - 2D coordinate system Look at FrustumFrustum ViewportViewport computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group Camera look at - Move camera C to origin Translate by C - Build orthonormal frame rightR=DxU zenithU=RxD - Adjust orientation Rotation [R,U,D][X,Y,-Z] computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group Frustum T t B b -f -n -z y computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group Pixel Stage Vertex Stage User / DriverOverview Transform & Lighting Rasterizer Texturing Blending/Ops Texture 3 Texture 2 Texture 1 Texture 0 computer graphics & visualization Jens Krger & Polina Kondratieva Computer Graphics and Visualization Group Bresenham (Line Drawing) computer graphics & visualization Jens Krger & 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--; } /********************************* * 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 arithmeticstill floating point arithmeticObersavtion: m is rationalm is rational d is rationald is rational computer graphics & visualization Jens Krger & 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; } 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: