๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
ํ”„๋กœ๊ทธ๋ž˜๋ฐ

[tbd] ๋ณ€ํ™˜ํ–‰๋ ฌ Transformation Matrix

by ๐“ƒ๐’ถ๐“ƒ๐’ถ๏ฝก 2015. 3. 23.

https://open.gl/transformations

 

 

Translation

Scaling

Rotation

โ€“ rotation about y-axis is heading/yaw
โ€“ rotation about x-axis is pitch/elevation
โ€“ rotation about z-axis is roll/bank

 

 

Combining transformations is demonstrated by the multiplication of matrices.

ex) Mtranslate * Mscale

 

 

Transformations in OpenGL

 

 

 

Model Matrix

Ojbect coordinates (position in model) -> World coordinates (position in world)

์œ„์น˜, ํฌ๊ธฐ, ํšŒ์ „์˜ ๋‹จ์ˆœ ๋ณ‘ํ•ฉ

์• ์ดˆ์— world coordinates์œผ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋‹ค๋ฉด ์ด ๋งคํŠธ๋ฆญ์Šค๋Š” ๊ฐ„๋‹จํžˆ identity matrix๋กœ ์„ธํŒ…๋œ๋‹ค.

 

 

View Matrix

OpenGL์—์„œ์˜ ์นด๋ฉ”๋ผ๋Š” ์›€์ง์ผ ์ˆ˜ ์—†์œผ๋ฉฐ, (0, 0, 0)์— ๊ณ ์ •๋˜์–ด -Z ๋ฐฉํ–ฅ์„ ๋ฐ”๋ผ๋ณด๊ณ  ์žˆ๋‹ค.

๋”ฐ๋ผ์„œ ๋ชจ๋“  ์›€์ง์ž„์€ ์นด๋ฉ”๋ผ๊ฐ€ ์›€์ง์ด๋Š” ๋Œ€์‹  world๊ฐ€ ๋ฐ˜๋Œ€๋กœ ์›€์ง์—ฌ ๊ฐ™์€ ํšจ๊ณผ๋ฅผ ๋‚ธ๋‹ค. (inverse transformation)

 

 

Projection Matrix

Clip coordinates ์œผ๋กœ ๋ณ€ํ™˜ํ•ด์ฃผ๋Š” ๊ณผ์ •.

Perspective projection์˜ ๊ฒฝ์šฐ DCN(Device Coordinates Normalization)์ด ํ•„์š”ํ•˜๋‹ค.

์œ„ ๊ณผ์ •์—์„œ ํˆฌ์˜ ํ–‰๋ ฌ์˜ 4ํ–‰์— 1์ด ์•„๋‹Œ ๊ฐ’์„ ๊ฐ–๋Š” w๊ฐ€ ๋ฐ˜๋“œ์‹œ ํ•„์š”ํ•˜๋‹ค.

w ๊ฐ’์€ ์นด๋ฉ”๋ผ์—์„œ ์–ผ๋งˆ๋‚˜ ๋–จ์–ด์ ธ ์žˆ๋Š”์ง€๋ฅผ ๊ฐ€๋Š ํ•œ๋‹ค.

xclip / wclip, yclip/wclip ์œผ๋กœ normalized๋œ ๊ฐ’์€ -1~1์˜ range๋ฅผ ๊ฐ–๋Š”๋‹ค. zclip/wclip์€ depth ๊ฐ’์ด ๋œ๋‹ค.

 

 

์œ„์˜ ๊ณผ์ •์ด ๋ชจ๋‘ ํ•ฉ์ณ์„œ ์•„๋ž˜์™€ ๊ฐ™์€ ์—ฐ์‚ฐ์„ ์ˆ˜ํ–‰ํ•œ๋‹ค.

 

 

์ผ๋ฐ˜์ ์œผ๋กœ vertex shader์—์„œ ์ˆ˜ํ–‰๋˜๋ฉฐ gl_Position์œผ๋กœ ์„ ์–ธ๋˜์–ด clipping coordinates ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.