Skip to content

Latest commit

ย 

History

History
204 lines (150 loc) ยท 8.07 KB

File metadata and controls

204 lines (150 loc) ยท 8.07 KB

๊ธฐํƒ€

์˜ค๋ฅธ์† / ์™ผ์† ์ขŒํ‘œ๊ณ„

์†๊ฐ€๋ฝ ๋งจ๋‚  ํ–‡๊ฐˆ๋ฆผ ์ด์ผ€ ์™ธ์šฐ์ž.
X : ์—„์ง€(์—„์ง€๋Š” ํ•ญ์ƒ ์˜ค๋ฅธ์ชฝ๋ฐฉํ–ฅ์œผ๋กœ)
Y : ๊ฒ€์ง€(๊ฒ€์ง€๋Š” ํ•ญ์ƒ ์œ„์ชฝ)
Z : ์ค‘์ง€

X x Z = Y : ์˜ค๋ฅธ์† ์ขŒํ‘œ๊ณ„ - OpenGL(since 1992) '์˜ค'ํ”ˆ ์ง€์—˜์ด๋‹ˆ(or ๋จผ์ €๋‚˜์™”์œผ๋‹ˆ) ์˜ค๋ฅธ์ชฝ.
  /Z
 /
+---- X
|
|
Y

  Y
  |
  |
  +---- X
 /
/
Z

X x Z = Y : ์™ผ์† ์ขŒํ‘œ๊ณ„ - DirectX(since 1995) ๋‚˜์ค‘์— ๋‚˜์™”์œผ๋‹ˆ ์™ผ์ชฝ.

Y
| /Z
|/
+---- X

Column Major vs Row Major

Row_and_column_major_order


N x 1 matrix : column vector
1 x N matrix : row vector

๊ทธ๋Ÿฌ๋‚˜ D3DX ๋Š” row-major ํ–‰๋ ฌ์„ ์‚ฌ์šฉํ•˜๊ณ  OpenGL์€ column-major

https://docs.microsoft.com/en-us/windows/win32/dxmath/pg-xnamath-getting-started?redirectedfrom=MSDN#matrix_convention
Direct3D has historically used left-handed coordinate system, row-major matrices, row vectors

HLSL shaders default to consuming column-major matrices


https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-per-component-math
Matrix packing order for uniform parameters is set to column-major by default
 #pragmapack_matrix directive, or with the row_major or the column_major keyword.

Row-Major
mul(v, TranslateMatrix) = float4
            | 1 0 0 0 |
| 1 2 3 1 | | 0 1 0 0 | = | (1 + 5) 2 3 1 |
            | 0 0 1 0 |
            | 5 0 0 1 |


Colum-Major
mul(TranslateMatrix, v) = float4
| 1 0 0 5 | | 1 |   | 1 + 5 |
| 0 1 0 0 | | 2 | = | 2     |
| 0 0 1 0 | | 3 |   | 3     |
| 0 0 0 1 | | 1 |   | 1     |

mul(v, TranslateMatrix) = float4
            | 1 0 0 5 |
| 1 2 3 1 | | 0 1 0 0 | = | 1 2 3 (5 + 1) |
            | 0 0 1 0 |
            | 0 0 0 1 |

mul(TranslateMatrix, v) = float4

| 1 0 0 5 | | 1 |   | 1 + 5 |
| 0 1 0 0 | | 2 | = | 2     |
| 0 0 1 0 | | 3 |   | 3     |
| 0 0 0 1 | | 1 |   | 1     |


๋™์ผํ•œ float4์ด๋ผ๋„ ๊ณฑํ•˜๋Š” ์ˆœ์„œ์— ๋”ฐ๋ผ ๊ฐ’์ด ๋‹ค๋ฅด๋‹ค.

DXT

๋…ธ๋ฉ€๋งต ๊ฐ™์€ ๊ฒฝ์šฐ์—๋Š” red์ฑ„๋„์˜ ๋ณ€ํ™”๊ฐ€ ์‹ฌํ•˜๊ธฐ ๋•Œ๋ฌธ์—,
R์ฑ„๋„์„ A์ฑ„๋„๋กœ ๋ฐ”๊พธ๊ณ  DXT5๋กœ ์ €์žฅํ•œ ํ›„,
shader์—์„œ AGB๋กœ ์ ‘๊ทผํ•˜์—ฌ ์ƒ˜ํ”Œ๋งํ•˜๋ฉด ์ƒ๋‹นํžˆ ๊ดœ์ฐฎ์€ ๊ฒฐ๊ณผ๋ฅผ ์–ป์–ด๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
- https://gpgstudy.com/forum/viewtopic.php?t=24598

DXT5nm ํฌ๋งท์„ ์ด์šฉ(ํ€„๋ฆฌํ‹ฐ ์—…)

V color channel bit
X R a0, a1 16
alpha indices 48
Y G color0,1 32
color indices 32
Z B x 0
  • xyzw, wy => _g_r => rg => xyn // r์ด ๋’ค๋กœ ์žˆ์œผ๋ฏ€๋กœ, ํ•œ๋ฐ”ํ€ด ๋Œ๋ ค์ค˜์•ผํ•จ.
  • normal.xy = packednormal.wy * 2 - 1; (0 ~ 1 => -1 ~ 1)
  • Z๋Š” ์‰์ด๋”์—์„œ ๊ณ„์‚ฐ. ๋‹จ์œ„ ๋ฒกํ„ฐ์˜ ํฌ๊ธฐ๋Š” 1์ธ๊ฒƒ์„ ์ด์šฉ.(sqrt(x^2 + y^2 + z^2) = 1)

DXT1, (RGB 5:6:5), (RGBA 5:5:5:1)

color0 16
color1 16
color indices 4 * 4 * 2 = 32
    (RGB)24 * 16 = 384
    384 / 64 = 6
    6๋ฐฐ๋ฅผ ์•„๋‚„ ์ˆ˜ ์žˆ๋‹ค.

DXT3

alpha 64
color0 16
color1 16
color indices 4 * 4 * 2 = 32
    (RGBA)32 * 16 = 512
    512 / 128 = 4
    4๋ฐฐ๋ฅผ ์•„๋‚„ ์ˆ˜ ์žˆ๋‹ค.

DXT5

a0 8
a1 8
alpha indices 48
color0 16
color1 16
color indices 4 * 4 * 2 = 32
    R4G4B4A4
    R4G4B4A4 (์ถœ๋ ฅ์‹œ ๋ณด๊ฐ„ A8)

์™ธ๊ณฝ์„ 

๊ธ€์“ด์ด: ๊ทธ๋ ˆ์ด์˜ค๊ฑฐ ยป 2007-12-12 10:54

์™ธ๊ณฝ์„  ์ฒ˜๋ฆฌ ๋ฐฉ์‹์„ ํฌ๊ฒŒ ๋‚˜๋ˆ„๋ฉด,

1. ๋ฒ„ํ…์Šค์™€ ๋…ธ๋ฉ€์„ ๊ฐ€์ง€๊ณ  ๋…ธ๋Š”๊ฑฐ(VS)
2. ์ผ๋‹จ ๋ Œ๋”๋ง ๊ฑด๋‹ค์Œ ์ด๋ฏธ์ง€ ํ”„๋กœ์„ธ์‹ฑ์œผ๋กœ ์™ธ๊ณฝ์„ ์„ ๋”ฐ์ฃผ๋Š”๊ฑฐ(PS)
3. ๋”ฐ๋กœ ์„ ๋งŒ ๊ทธ๋ ค์ฃผ๋Š”๊ฑฐ

๊ฑฐ์˜ ์š” ์„ธ๊ฐ€์ง€์— ์†ํ•˜๋”๊ตฐ์š”.

1๋ฒˆ์˜ ๊ฒฝ์šฐ ๋น„๊ต์  ๊ณ„์‚ฐ๋น„์šฉ์ด ์ž‘์Šต๋‹ˆ๋‹ค. ๋ผ์ดํŠธ๋ฒกํ„ฐ์™€์˜ ๋‚ด์ ์„ ์ด์šฉํ•œ ๋ฐฉ์‹์€ ์†๋„ ์ง€์กด์ž…๋‹ˆ๋‹ค๋งŒ ๋กœ์šฐํด๋ฆฌ๊ณค์ด๋‚˜ ๋””์ž์ด๋„ˆ๊ฐ€ ์™€์ด์–ดํ”„๋ ˆ์ž„ ๊ฐ๊ฐ์ด ์—†๋Š” ๊ฒฝ์šฐ ์•ˆํ•˜๋Š๋‹ˆ๋งŒ ๋ชปํ•œ ํ€„๋ฆฌํ‹ฐ๊ฐ€ ๋‚˜์˜ค๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์šฉ์ด ์ข€ ํ•œ์ •์ ์ž…๋‹ˆ๋‹ค. ์™ธ๊ณฝ์„ ์— ํด๋ฆฌ๊ณค์œผ๋กœ ๋ผ์ธ์„ ์ƒ์„ฑํ•ด ์ฃผ๋Š” ๋ฐฉ์‹๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ€์žฅ ํ”ํ•œ๊ฒŒ ๋…ธ๋ง ๋’ค์ง‘์–ด ํ™•๋Œ€ํ•ด ์ฐ์–ด์ฃผ๋Š”๊ฑฐ์ฃ . GPU์˜ ์  2Pass์ด๊ธด ํ•˜์ง€๋งŒ ๊ฐœ์ธ์ ์œผ๋กœ๋Š” ๊ฐ€๊ฒฉ๋Œ€ ํ€„๋ฆฌํ‹ฐ๋ฉด์—์„œ ๊ฐ€์žฅ ์ข‹๋‹ค๊ณ  ๋ด…๋‹ˆ๋‹ค. ๊ฑ ์„  ์ž์ฒด๋„ ํด๋ฆฌ๊ณค์ด๋‹ค ๋ณด๋‹ˆ ๊ฑฐ๋ฆฌ์— ๋”ฐ๋ผ ์ž๋™์œผ๋กœ ์™ธ๊ณฝ์„  ๋‘๊ป˜๊ฐ€ ๋น„๋ก€์— ๋งž๊ฒŒ ์กฐ์ ˆ๋ฉ๋‹ˆ๋‹ค. ํŠนํžˆ ์ด๊ฑด ๋งŒ์•ฝ ํ”„๋กœ๊ทธ๋ž˜๋จธ๊ฐ€ ์‰์ด๋”๋ฅผ ๋ชฐ๋ผ๋„ ๋งฅ์Šค์—์„œ ๋งŒ๋“ค์–ด ์ค„ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค๋งŒ ์œ„์—ฃ๋ถ„๋“ค์ด ๋ง์Šดํ•˜์…จ๋“ฏ, ์ค‘๋ณต ๋…ธ๋ฉ€์„ ๊ฐ€์ง€๊ณ  ์žˆ์„ ๊ฒฝ์šฐ ๋ณ„๋„์ฒ˜๋ฆฌ๋ฅผ ํ•ด์•ผ ํ•˜๋Š” ๊ท€์ฐฎ์Œ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

2๋ฒˆ์˜ ๊ฒฝ์šฐ ์™ธ๊ณฝ์„  ๋‘๊ป˜๊ฐ€ ๊ท ์ผํ•˜๊ณ  ํ€„๋ฆฌํ‹ฐ ๋ฉด์—์„œ๋„ ๊ฐ€์žฅ ์ข‹์Šต๋‹ˆ๋‹ค. ๊นŠ์ด๊ฐ์ด ์žˆ๋Š” ์™ธ๊ณฝ์„  ๋ฌ˜์‚ฌ๋„ ๊ฐ€๋Šฅํ•˜๊ณ ์š”(์–ผ๊ตด ์™ธ๊ณฝ๋ผ์ธ์„ ๋ฌ˜์‚ฌํ• ๋•Œ ํ„ฑ์„ ์€ ์„œ์„œํžˆ ์˜…์–ด์ง€๊ฒŒ๋„ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. gooch shading๊ณผ ํ•จ๊ป˜ ์“ฐ๋‹ˆ ์บ๋ฆญํ„ฐ ์–ผ๊ตด ์ง„์งœ ์ด์˜๊ฒŒ ๋‚˜์˜ค๋”๋ผ๊ณ ์š”! >o<b), ๊นŠ์ด, ์ปฌ๋Ÿฌ, ๋…ธ๋ง๊ฐ’ ๋“ฑ๋“ฑ ์ค‘์—์„œ ์–ด๋Š๊ฑธ ๊ธฐ์ค€์œผ๋กœ ํ•˜๋Š๋ƒ์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์ง€์ง€๋งŒ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ด๋ฏธ์ง€ ํ”„๋กœ์„ธ์‹ฑ์„ ์“ฐ๋‹ค๋ณด๋‹ˆ ๋‹ค์ฑ„๋กœ์šด ํšจ๊ณผ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ๋…ธ๋ฉ€๋ฌธ์ œ, ์•ŒํŒŒ๋ฌธ์ œ, ์Šคํ‚ค๋‹๋„ ์ž๋™ํ•ด๊ฒฐ๋ฉ๋‹ˆ๋‹ค. ์•ˆํ‹ฐ์•Œ๋ฆฌ์–ด์‹ฑ๋„ ๋””ํดํŠธ๋กœ ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค. ๋‹ค๋งŒ PS์— ๋‹ค์ค‘์ƒ˜ํ”Œ๋ง์ด ํ•„์ˆ˜์ธ๋ฐ๋‹ค, ๊ฐ๊ฐ์˜ ๋ฐฉ์‹์ด ๋…์ž์ ์œผ๋กœ๋Š” ์™„์ „ํ•˜์ง€ ๋ชปํ•ด ๋ณด์™„์ ์œผ๋กœ ์„ž์–ด์ฃผ์–ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํผํฌ๋จผ์Šค ์ข€(...์‚ฌ์‹ค์€ ๋งŽ์ด) ๋จน์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ €๋Š” ๊ฒฐ๊ตญ ๋นผ๋ฒ„๋ฆฌ๊ณ  ๋…ธ๋ง๋’ค์ง‘๊ธฐ๋กœ ๊ฐ”์Šต๋‹ˆ๋‹ค(์ง€๋ชป๋ฏธ... ใ… _ใ… );;

3. ๋ณดํ†ต ๋ฉด๋‹จ์œ„๋กœ ๋…ธ๋ฉ€์„ ๊ณ„์‚ฐํ•ด ๊ฒฝ๊ณ„์„ ์œผ๋กœ ํŒ๋‹จ๋˜๋Š” ๊ฒฝ์šฐ ๋ผ์ธ์ด๋‚˜ ํด๋ฆฌ๊ณค ๋ ๋ฅผ ๋”ฐ๋กœ ์ƒ์„ฑํ•ด ๊ทธ๋ ค์ฃผ๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค. 1๋ฒˆ ๋ฐฉ์‹๊ณผ ํก์‚ฌํ•˜์ง€๋งŒ ์„  ๋‘๊ป˜๊ฐ€ ์˜ค๋ธŒ์ ํŠธ์˜ ํฌ๊ธฐ๋‚˜ ๊ฑฐ๋ฆฌ์— ์ƒ๊ด€ ์—†์ด ๊ท ์ผํ•˜๊ฒŒ ์œ ์ง€๋ฉ๋‹ˆ๋‹ค. ์•„๋งˆ๋„ ์ œ์‹œํ•˜์‹  ์Šค์ƒท์—์„œ๋Š” ์ด ๋ฐฉ์‹์œผ๋กœ ์ถ”์ธก๋ฉ๋‹ˆ๋‹ค.

๋†’์€ ํ€„๋ฆฌํ‹ฐ๋ณด๋‹ค๋Š” ๋‹ค์ˆ˜์˜ ์˜ค๋ธŒ์ ํŠธ ์ฒ˜๋ฆฌ๊ฐ€ ์ค‘์š”ํ•œ ๊ฒฝ์šฐ 1๋ฒˆ์„, ์†Œ์ˆ˜์ง€๋งŒ ํ€„๋ฆฌํ‹ฐ๊ฐ€ ์ค‘์š”ํ•  ๊ฒฝ์šฐ 2๋ฒˆ์„, ์ ์ ˆํ•œ ๋ถ€ํ•˜์™€ ๊ท ์ผํ•œ ์„  ๋‘๊ป˜์„ ์›ํ•  ๊ฒฝ์šฐ 3๋ฒˆ์„ ํƒํ•˜๋Š” ๊ฒƒ ๊ฐ™๋”๊ตฐ์š”.

๊ฐ ์ ์œผ๋ก  gooch + depth ๊ธฐ๋ฐ˜ PS์„ ๋”ฐ๊ธฐ ์›์ธ„! ใ…ก_ใ…กb

TODO

mipmap