Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original
Universidade Federal da Paraíba Centro de Informática Canonical and Screen Space Lecture 10 1107190 - Introdução à Computação Gráfica – Turma 01 Prof. Christian Azambuja Pagot CI / UFPB Universidade Federal da Paraíba Centro de Informática How the space looks like after homogenization? ● After projection and division by w: y z y z Geometry was distorted by the homogenization. However, is the new space a canonical space? y z y z Universidade Federal da Paraíba Centro de Informática Canonical Space ● The concept of a canonical space involves a space that contains our scene and that is limited by unit coordinates: z y x (1, 1, 1) (-1, -1, -1) How to fit a scene into this space? Universidade Federal da Paraíba Centro de Informática Generating Canonical Spaces ● The canonical space should contain our scene. ● Therefore, we have to define a bounding volume around our scene somehow in camera space. ● That bounding volume will become the the canonical space. ● We will have to include additional transformations to both projection transforms: – Orthogonal. – Perspective. Universidade Federal da Paraíba Centro de Informática Canonical Space for Orthogonal Projections ● As seen before, the orthogonal projection matrix is just the identity. ● To generate a canonical space, we will bound our scene (a portion of camera space) with an axis-aligned bounding box. ● The whole camera space is translated and stretched such that the axis-aligned bounding box becomes a canonical cube centered at the origin. Universidade Federal da Paraíba Centro de Informática Canonical Space for Orthogonal Projections z y x Camera Space Bounding box z y x (1, 1, 1) (-1, -1, -1) Canonical Space l = left b = bottom n = near r = right t = top f = far (r, t, f) (l, b, n) Universidade Federal da Paraíba Centro de Informática Canonical Space for Orthogonal Projections ● 1st: Translate the bounding box to the origin: ● 2nd: Scale the bounding box: d x=− r+l 2 , d y=− t+b 2 , d z=− n+ f 2 sx= 2 r−l , sx= 2 t−b , s x= 2 n− f p '=Mcanp Mcan=[ 2 r−l 0 0 − r +l r−l 0 2 t−b 0 − t+b t−b 0 0 2 n− f − n+ f n− f 0 0 0 1 ], onde z y x Camera Space Bounding box l = left b = bottom n = near r = right t = top f = far (r, t, f) (l, b, n) Universidade Federal da Paraíba Centro de Informática Canonical Space for Perspective Projections ● It would be convenient to have a perspective transform capable to deliver vertices in clipping space such that, after homogenization, we could have everything within the canonical space. Universidade Federal da Paraíba Centro de Informática Canonical Space for Perspective Projections z yp p' d z y y' c = camera position p(z,y) = a point in cam. space. p'(d,y') = projection of p onto the vp. c Mproj=[ 1 0 0 00 1 0 00 0 1 d0 0 −1 d 0] Our previous Perspective Projection Setup ● Does not automatically generate a canonical volume after /W ! Universidade Federal da Paraíba Centro de Informática Canonical Space for Perspective Projections z y n f y n = distance of the near plane. f = distance of the far plane. c The New Setup ● Scene is bounded along the z axis by a near and a far plane. ● The new projection matrix M proj is shown below: Mproj=[ 1 0 0 0 0 1 0 0 0 0 −n+ f n f 0 0 −1 n 0 ] q p Mproj=[ xyz1 ]=[ x y z n+ f n −f z n ]→[ nx z ny z n+ f− fn z 1 ] Universidade Federal da Paraíba Centro de Informática Canonical Space for Perspective Projections z y q n f n = distance of the near plane. f = distance of the far plane. p After Homogenization ● The view frustum becomes a rectangle (not yet in canonic space). ● Now we can use the same procedure used for the orthogonal projection in order to obtain the canonical volume. The transformed points must be multiplied by the matrix bellow: Mcan=[ 2 r−l 0 0 − r+l r−l 0 2 t−b 0 − t+b t−b 0 0 2 n− f − n+ f n− f 0 0 0 1 ] Universidade Federal da Paraíba Centro de Informática From Canonical to Screen Space z y x p1 = (1, 1, 1) p2 = (-1, -1, -1) x y Width = W pixels Height = H pixels Universidade Federal da Paraíba Centro de Informática From Canonical to Screen Space [ xyz1 ][ 1 0 0 0 0 −1 0 0 0 0 1 0 0 0 0 1][ w 2 0 0 0 0 h 2 0 0 0 0 1 0 0 0 0 1 ][1 0 0 w−1 2 0 1 0 h−1 2 0 0 1 0 0 0 0 1 ][ x 'y 'z '1 ]= Point p in canonical space Invert Y axis direction Scale along X and Y acis. Transtale.Point p' in Screen space. y c x c (-1, -1) (1, 1) Canonical Space p y s x sScreen Space w = width in pixels. h = heigth in pixels.p' Slide 1 Slide 2 Slide 3 Slide 4 Slide 5 Slide 6 Slide 7 Slide 8 Slide 9 Slide 10 Slide 11 Slide 12 Slide 13