Presentation is loading. Please wait.

Presentation is loading. Please wait.

Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.

Similar presentations


Presentation on theme: "Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics."— Presentation transcript:

1 Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics

2 Graphics Rendering Pipeline Rendering: conversion from scene to image Scene is represented as a model composed of primitives. Model is generated by a program or input by a user. Image is drawn on an output device: monitor, printer, memory, file, video frame. Device independence. 3D Scene 2D Image

3 Graphics pipeline Typically rendering process is divided into steps called the graphics/rendering pipeline. Ray tracing – Model your scene in WCS – Generate rays – Find pixel color by an Illumination/Shadow/Reflection model

4 Ray Tracing Pipeline

5 Forward Projection Pipeline

6 Forward projection pipeline Model M1 M2 M3 3D World Scene 3D View Scene V P Clip Normalize 2D/3D Device Scene 2D Image Projection Rasterization Modeling Transformations Viewing Transformations MCS WCS VCS NDCS DCS SCS

7

8 Modeling Transformation Model coordinates to World coordinates: World coordinates: All shapes with their absolute coordinates and sizes. z world x world y world

9 3D Viewing-Coordinate Parameters World coordinates to Viewing coordinates: Viewing transformations World coordinates Viewing coordinates: Viewers (Camera) position and viewing plane. z world x world y world x view y view z view

10 Basic Geometric Transformations Geometric transformations are used to transform the objects and the camera in a scene (for animation or modelling) and are also used to transform World Coordinates to View Coordinates Given the shape, transform all the points of the shape? Transform the points and/or vectors describing it. For example: Polygon: corner points Circle, Ellipse: center point(s), point at angle 0 Some transformations preserves some of the attributes like sizes, angles, ratios of the shape.

11 Translation Simply move the object to a relative position. T P P'P'

12 Rotation A rotation is defined by a rotation axis and a rotation angle. For 2D rotation, the parameters are rotation angle (θ) and the rotation point (x r,y r ). We reposition the object in a circular path arround the rotation point (pivot point) a xrxr yryr

13 Rotation When (x r,y r ) = (0,0) we have r P P'P' The original coordinates are: Substituting them in the first equation we get: In the matrix form we have: where

14 Rotation Rotation around an arbitrary point (x r,y r ) This equations can be written as matrix operations (we will see when we discuss homogeneous coordinates). r P P'P' (x r,y r )

15 Scaling Change the size of an object. Input: scaling factors (s x,s y ) P P'P' non-uniform vs. uniform scaling

16 Homogenous Coordinates All transformations can be represented by matrix operations. Translation is additive, rotation and scaling is multiplicative (+ additive if you rotate around an arbitrary point or scale around a fixed point); making the operations complicated. Adding another dimension to transformations make translation also representable by multiplication. Cartesian coordinates vs homogenous coordinates.

17 Many points in homogenous coordinates can represent the same point in Cartesian coordinates. In homogenous coordinates, all transformations can be written as matrix multiplications.

18 Transformations in Homogenous C. Translation Rotation Scaling

19 Composite Transformations Application of a sequence of transformations to a point:

20 Composite Transformations First: composition of similar type transformations If we apply to successive translations to a point:

21 Composite Transformations

22 Rotation around a pivot point – Translate the object so that the pivot point moves to the origin – Rotate around origin – Translate the object so that the pivot point is back to its original position

23 Scaling with respect to a fixed point – Translate to origin – Scale – Translate back

24 Order of matrix compositions Matrix composition is not commutative. So, be careful when applying a sequence of transformations. pivot same pivot

25 Other Transformations Reflection

26 Shear: Deform the shape like shifted slices. (1,1) (3,1) (2,1) (0,1)

27 3 DIMENSIONAL TRANSFORMATIONS

28 3D Transformations x,y,z coordinates. Usual notation: Right handed coordinate system Similar to 2D we have 4 dimensions in homogenous coordinates. Basic transformations: – Translation – Rotation – Scaling x y z z x y y z x

29 Translation move the object to a relative position. z y x z y x

30 Rotation Rotation arround the coordinate axes x axisy axisz axis z x y z x y z x y z x y z x y z x y Counterclockwise when looking along the positive half towards origin

31 Rotation around coordinate axes Arround x Arround y Arround z

32 Rotation Around a Parallel Axis Rotating the object around a line parallel to one of the axes: Translate to axis, rotate, translate back. z y x z y x z y x z y x TranslateRotateTranslate back

33 Rotation Around an Arbitrary Axis Translate the object so that the rotation axis passes though the origin Rotate the object so that the rotation axis is aligned with one of the coordinate axes Make the specified rotation Reverse the axis rotation Translate back z y x

34 Rotation Around an Arbitrary Axis

35 u is the unit vector along V: First step: Translate P 1 to origin: Next step: Align u with the z axis we need two rotations: rotate around x axis to get u onto the xz plane, rotate around y axis to get u aligned with z axis.

36 Rotation Around an Arbitrary Axis z x u Align u with the z axis 1) rotate around x axis to get u into the xz plane, 2) rotate around y axis to get u aligned with the z axis y α z x u y β z x u u' α uzuz y

37 Rotation Around an Arbitrary Axis z x u u' α Align u with the z axis 1) rotate around x axis to get u into the xz plane, 2) rotate around y axis to get u aligned with the z axis uzuz We need cosine and sine of α for rotation Projection of u on yz plane

38 Rotation Around an Arbitrary Axis z x u u''= (a,0,d) β Align u with the z axis 1) rotate around x axis to get u into the xz plane, 2) rotate around y axis to get u aligned with the z axis

39 Rotation,... Alternative Method Any rotation around origin can be represented by 3 orthogonal unit vectors: Define a new coordinate system with the given rotation axis u using: This matrix can be thought of as rotating the unit r 1*, r 2*, and r 3* vectors onto x, y, and z axes. So, to align a given rotation axis u onto the z axis, we can define an (orthogonal) coordinate system and form this R matrix

40 Rotation,... Alternative Method Check if this is equal to

41 Scaling Change the coordinates of the object by scaling factors. z y x z y x

42 Scaling with respect to a Fixed Point Translate to origin, scale, translate back z y x z y x z y x z y x TranslateScaleTranslate back

43 Scaling with respect to a Fixed Point

44 Reflection Reflection over planes, lines or points z y x z y x z y x z y x

45 OpenGL Geometric-Transformation Functions In the core OpenGL library, – a separate function is available for each basic transformation (translate, rotate, scale) – all transformations are specified in 3D Parameters – Translation: translation amount in x, y, z axes – Rotation: angle, orientation of the rotation axis that passes through the origin – Scaling: scaling factors for three coordinates

46 Basic OpenGL Transformations glTranslate* (tx, ty, tz); – For 2D applications set tz = 0 glRotate* (theta, vx, vy, vz); – theta in degrees – The rotation axis is defined by the vector (vx,vy,vz), i.e., P0 = (0,0,0) P1 = (vx,vy,vz) glScale* (sx, sy, sz); – Use negative values to get reflection transformation


Download ppt "Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics."

Similar presentations


Ads by Google