Presentation is loading. Please wait.

Presentation is loading. Please wait.

12.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 12 – 3D Graphics Transformation Pipeline: Projection and Clipping.

Similar presentations


Presentation on theme: "12.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 12 – 3D Graphics Transformation Pipeline: Projection and Clipping."— Presentation transcript:

1 12.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 12 – 3D Graphics Transformation Pipeline: Projection and Clipping

2 12.2 Si23_03 Viewing Pipeline So Far n From the last lecture, we now should understand the viewing pipeline mod’g co-ords world co-ords viewing co-ords Modelling Transform’n Viewing Transform’n The next stage is the projection transformation…. Projection Transform’n

3 12.3 Si23_03 Perspective and Parallel Projection perspective parallel

4 12.4 Si23_03 Puzzle from Earlier Lecture

5 12.5 Si23_03 Ames Room

6 12.6 Si23_03 Another Example

7 12.7 Si23_03 Viewing Co-ordinate System viewing co-ordinate system n The viewing transformation has transformed objects into the viewing co-ordinate system, where the camera position is at the origin, looking along the negative z-direction zVzV yVyV xVxV camera direction

8 12.8 Si23_03 View Volume zVzV yVyV xVxV camera near plane far plane  We determine the view volume by: - view angle,  - aspect ratio of viewplane - distances to near plane d NP and far plane d FP d NP d FP

9 12.9 Si23_03 Projection We shall project on to the near plane. Remember this is at right angles to the z V direction, and has z-coordinate z NP = - d NP zVzV yVyV xVxV camera near plane d NP

10 12.10 Si23_03 Perspective Projection Calculation looking down x-axis towards the origin zVzV yVyV xVxV camera near plane d NP z NP zVzV view plane Q camera yVyV z NP zQzQ

11 12.11 Si23_03 Perspective Projection Calculation zVzV view plane Q camera yVyV z NP zQzQ P By similar triangles, y P / y Q = ( - z NP ) / ( - z Q ) and so y P = y Q * (- z NP ) / ( - z Q ) or y P = y Q * d NP / ( - z Q ) Similarly for the x-coordinate of P: x P = x Q * d NP / ( - z Q )

12 12.12 Si23_03 Using Matrices and Homogeneous Co-ordinates n We can express the perspective transformation in matrix form n Point Q in homogeneous coordinates is (x Q, y Q, z Q, 1) n We shall generate a point H in homogeneous co-ordinates (x H, y H, z H, w H ), where w H is not 1 n But the point (x H /w H, y H /w H, z H /w H, 1) is the same as H in homogeneous space n This gives us the point P in 3D space, ie x P = x H /w H, sim’ly for y P

13 12.13 Si23_03 Transformation Matrix for Perspective 1 0 0 0 0 1 0 0 0 0 1 0 0 0 -1/d NP 0 xQyQzQ1xQyQzQ1 xHyHzHwHxHyHzHwH = Thus in Homogeneous co-ordinates: x H = x Q ; y H = y Q ; z H = z Q ; w H = (-1/d NP )z Q In Cartesian co-ordinates: x P = x H / w H = x Q *d NP /(-z Q ); y P similar; z P = -d NP = z NP

14 12.14 Si23_03 OpenGL n Perspective projection achieved by: gluPerspective (angle_of_view, aspect_ratio, near, far) – aspect ratio is width/height – near and far are positive distances

15 12.15 Si23_03 Vanishing Points vanishing point n When a 3D object is projected onto a view plane using perspective, parallel lines in object NOT parallel to the view plane converge to a vanishing point view plane vanishing point one-point perspective projection of cube

16 12.16 Si23_03 One- and Two-Point Perspective Drawing

17 12.17 Si23_03 One-point Perspective Said to be the first painting in perspective This is: Trinity with the Virgin, St John and Donors, by Mastaccio in 1427

18 12.18 Si23_03 Two-point Perspective Edward Hopper Lighthouse at Two Lights -see www.postershop.com

19 12.19 Si23_03 Parallel Projection - Two types n Orthographic n Orthographic parallel projection has view plane perpendicular to direction of projection n Oblique n Oblique parallel projection has view plane at an oblique angle to direction of projection P1 P2 view plane P1 P2 view plane orthographic projection We shall only consider orthographic projection

20 12.20 Si23_03 Parallel Projection Calculation zVzV yVyV xVxV near plane d NP zVzV view plane Q yVyV looking down x-axis z NP zQzQ P y P = y Q similarly x P = x Q

21 12.21 Si23_03 Parallel Projection Calculation n So this is much easier than perspective! – x P = x Q – y P = y Q – z P = z NP n The transformation matrix is simply 1 0 0 0 0 1 0 0 0 0 z NP /z Q 0 0 0 0 1

22 12.22 Si23_03 Clipping

23 12.23 Si23_03 View Frustum and Clipping zVzV yVyV xVxV camera near plane far plane  The view volume is a frustum in viewing co-ordinates - we need to be able to clip objects outside of this region d NP d FP

24 12.24 Si23_03 Clipping to View Frustum n It is quite easy to clip lines to the front and back planes (just clip in z).. n.. but it is difficult to clip to the sides because they are ‘sloping’ planes n Instead we carry out the projection first which converts the frustum to a rectangular parallelepiped (ie a cuboid) Retain the Z-coord

25 12.25 Si23_03 Clipping for Parallel Projection n In the parallel projection case, the viewing volume is already a rectangular parallelepiped far plane near plane zVzV view volume

26 12.26 Si23_03 Normalized Projection Co-ordinates normalize n Final step before clipping is to normalize the co-ordinates of the rectangular parallelepiped to some standard shape – for example, in some systems, it is the cube with limits +1 and -1 in each direction scale n This is just a scale transformation n Clipping is then carried out against this standard shape

27 12.27 Si23_03 Viewing Pipeline So Far n Our pipeline now looks like: mod’g co-ords world co-ords view’g co-ords proj’n co-ords normalized projection co-ordinates NORMALIZATION TRANSFORMATION

28 12.28 Si23_03 Viewport Transformation

29 12.29 Si23_03 And finally... n The last step is to position the picture on the display surface viewport transformation n This is done by a viewport transformation where the normalized projection co-ordinates are transformed to display co-ordinates, ie pixels on the screen

30 12.30 Si23_03 Viewing Pipeline - The End n A final viewing pipeline is therefore: mod’g co-ords world co-ords view’g co-ords proj’n co-ords normalized projection co-ordinates device co-ordinates DEVICE TRANSFORMATION


Download ppt "12.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 12 – 3D Graphics Transformation Pipeline: Projection and Clipping."

Similar presentations


Ads by Google