16
Computer Graphic Creator: Mohsen Asghari Session 6 Fall 2014

Computer Graphic

Embed Size (px)

DESCRIPTION

Computer Graphic. Creator: Mohsen Asghari Session 6 Fall 2014. Matrixes. World - PowerPoint PPT Presentation

Citation preview

Page 1: Computer Graphic

Computer Graphic

Creator: Mohsen Asghari

Session 6

Fall 2014

Page 2: Computer Graphic

Agenda Projection Matrix Perspective Projection Matrix Ortho Calculate Parameters of Perspective Model View matrix Camera (LookAt)

Page 3: Computer Graphic

Projection Matrix (Perspective)

Page 4: Computer Graphic

Projection Matrix (Perspective)

𝐴𝐡=𝑛𝐷𝐸=βˆ’π‘ƒ 𝑧 𝐸𝐹=𝑃 𝑦

𝐡𝐢=𝑃 𝑠𝑦𝑃𝑠𝑦=

𝑃 π‘¦βˆ—π‘›βˆ’π‘ƒ 𝑧

𝑃𝑠 π‘₯=𝑃π‘₯βˆ—π‘›βˆ’π‘ƒ 𝑧

Page 5: Computer Graphic

Unit Cube

Page 6: Computer Graphic

Projection Matrix (Perspective)𝑙≀ 𝑃𝑠π‘₯ β‰€π‘Ÿ 0≀𝑃 𝑠π‘₯βˆ’π‘™β‰€π‘Ÿ βˆ’π‘™

0≀𝑃𝑠π‘₯βˆ’ π‘™π‘Ÿ βˆ’π‘™  

≀1 0≀2βˆ—π‘ƒπ‘ π‘₯βˆ’π‘™π‘Ÿ βˆ’ 𝑙  

≀2

βˆ’1≀2βˆ—π‘ƒπ‘ π‘₯βˆ’ π‘™π‘Ÿ βˆ’π‘™  

βˆ’1≀1

βˆ’1≀2βˆ—π‘ƒπ‘ π‘₯

π‘Ÿ βˆ’π‘™  βˆ’π‘Ÿ+ π‘™π‘Ÿ βˆ’π‘™

≀1

βˆ’1≀2π‘›βˆ—π‘ƒπ‘₯

βˆ’ 𝑃𝑧¿ ΒΏ

𝑃𝑠 π‘₯=𝑃π‘₯βˆ—π‘›βˆ’π‘ƒ 𝑧

Page 7: Computer Graphic

Projection Matrix (Perspective)

[ 2π‘›π‘Ÿ βˆ’ 𝑙 0π‘Ÿ+ π‘™π‘Ÿβˆ’ 𝑙

0

… … … ……0

…0

β€¦βˆ’1

…0

]βˆ’1≀

2π‘›βˆ—π‘ƒπ‘¦

βˆ’π‘ƒπ‘§ ΒΏΒΏ [2π‘›π‘Ÿ βˆ’ 𝑙

0π‘Ÿ+π‘™π‘Ÿ βˆ’ 𝑙

0

02π‘›π‘‘βˆ’π‘

𝑑+π‘π‘‘βˆ’π‘

0

00

00

π΄βˆ’1

𝐡0

]

Page 8: Computer Graphic

Projection Matrix (Perspective)

𝑃𝑠𝑧=𝐴𝑃 𝑧+𝐡𝑃 𝑠𝑀=βˆ’π‘ƒ 𝑧

βˆ’1=𝐴 𝑃𝑧+𝐡𝑃𝑠𝑀=βˆ’π‘ƒ 𝑧

1=𝐴𝑃 𝑧+𝐡𝑃 𝑠𝑀=βˆ’π‘ƒ 𝑧

𝑀h𝑒𝑛𝑃 𝑧=𝑛

𝑀h𝑒𝑛𝑃 𝑧= 𝑓{βˆ’π‘›π΄+𝐡=βˆ’π‘›  βˆ’ 𝑓𝐴+𝐡=βˆ’ 𝑓  

Page 9: Computer Graphic

Projection Matrix (Perspective)

A=βˆ’π‘“ +𝑛𝑓 βˆ’π‘›

B=βˆ’2 𝑓𝑛𝑓 βˆ’π‘›

[2π‘›π‘Ÿ βˆ’ 𝑙

0π‘Ÿ+π‘™π‘Ÿ βˆ’ 𝑙

0

02π‘›π‘‘βˆ’π‘

𝑑+π‘π‘‘βˆ’π‘

0

00

00

βˆ’π‘“ +𝑛𝑓 βˆ’π‘›βˆ’1

βˆ’2 𝑓𝑛𝑓 βˆ’π‘›0

]

Page 10: Computer Graphic

Question?All the matrix is related to Left = l right = rBottom = bTop = tNear = nFar = f

π‘€π‘Žπ‘‘π‘Ÿπ‘–π‘₯ 4 .π‘ͺπ’“π’†π’‚π’•π’†π‘·π’†π’“π’”π’‘π’†π’„π’•π’Šπ’—π’† (𝐹𝑂𝑉 ,𝐴𝑠𝑝𝑒𝑐𝑑 βˆ’π‘…π‘Žπ‘‘π‘–π‘œπ‘› ,π‘π‘’π‘Žπ‘Ÿ ,πΉπ‘Žπ‘Ÿ )

Page 11: Computer Graphic

Calculate l,r,b,t BY (FOV) – (asp-r)

tan( 𝐹𝑂𝑉2 )βˆ—π‘›π‘’π‘Žπ‘Ÿ=π‘‘π‘œπ‘

π‘Žπ‘ π‘π‘’π‘π‘‘ βˆ’π‘Ÿπ‘Žπ‘‘π‘–π‘œπ‘›=𝑀𝑖𝑑𝑑 hh𝑒𝑖𝑔h 𝑑

tan( 𝐹𝑂𝑉2 )βˆ—π‘›π‘’π‘Žπ‘Ÿ βˆ—π‘Žπ‘ π‘βˆ’π‘Ÿ=π‘Ÿπ‘–π‘”h 𝑑

Page 12: Computer Graphic
Page 13: Computer Graphic

ProjectionMatrix Projection Matrix (GL_PROJECTION)

GL_PROJECTION matrix is used to define the frustum. This frustum determines which objects or portions of objects will be clipped out. Also, it determines how the 3D scene is projected onto the screen. (Please see more details

Ortho Perspective

Page 14: Computer Graphic

Model View Matrix"World Matrix" and a "View Matrix", they are both transformation matrices.

Page 15: Computer Graphic

View LookAt() Eye Target Up

Page 16: Computer Graphic

END OF SESSION 5

ANY QUESTION?