《計(jì)算機(jī)圖形學(xué):基于3D圖形開(kāi)發(fā)技術(shù)》詳細(xì)闡述了與計(jì)算機(jī)游戲設(shè)計(jì)相關(guān)的基本解決方案及相應(yīng)的數(shù)據(jù)結(jié)構(gòu)和算法,主要包括游戲模型、頂點(diǎn)處理機(jī)制、光柵化操作、片元處理和輸出合并、光照和著色、參數(shù)曲線和表面、著色器模型、圖像紋理、凹凸貼圖、高級(jí)紋理操作、角色動(dòng)畫以及物理模擬等內(nèi)容。此外,《計(jì)算機(jī)圖形學(xué):基于3D圖形開(kāi)發(fā)技術(shù)》還提供了相應(yīng)代碼以及偽代碼,以幫助讀者進(jìn)一步理解相關(guān)方案的實(shí)現(xiàn)過(guò)程。
目錄: 目 錄 第1章 游戲模型............................................................................................................1 1.1 游戲制作流程...................................................................................................1 1.2 多邊形網(wǎng)格......................................................................................................4 1.2.1 創(chuàng)建多邊形網(wǎng)格*....................................................................................6 1.2.2 多邊形網(wǎng)格的表達(dá)方式......................................................................................9 1.2.3 表面法線............................................................................................................13 1.3 模型導(dǎo)出和導(dǎo)入...........................................................................................................15 1.4 坐標(biāo)系統(tǒng)....... ................................................................................................................17 本章練習(xí)...............................................................................................................................19 第2章 頂點(diǎn)處理機(jī)制...................................................................................................20 2.1 世界轉(zhuǎn)換.......................................................................................................................21 2.1.1 仿射轉(zhuǎn)換以及齊次坐標(biāo)....................................................................................21 2.1.2 世界矩陣...........................................................................................................24 2.1.3 歐拉轉(zhuǎn)換................................................................................. ..........................28 2.1.4 表面法線的轉(zhuǎn)換................................................................................................29 2.2 視見(jiàn)轉(zhuǎn)換.......................................................................................................................31 2.2.1 相機(jī)空間...........................................................................................................31 2.2.2 空間轉(zhuǎn)換和視見(jiàn)矩陣........................................................................................32 2.3 逐頂點(diǎn)光照.................................................................................................................37 2.4 投影轉(zhuǎn)換......................................................................................................................38 2.4.1 視見(jiàn)體................................................................................................................38 2.4.2 投影矩陣...........................................................................................................40 2.4.3 投影矩陣的推導(dǎo)過(guò)程*......................................................................................44 本章練習(xí).......................................................................................................... ......................47 ·VI· 計(jì)算機(jī)圖形學(xué)——基于3D圖形開(kāi)發(fā)技術(shù) 第3章 光柵化操作.......................................................................................................49 3.1 剪裁操作......................................................................................................................49 3.2 透視除法......................................................................................................................50 3.3 背面剔除操作...............................................................................................................51 3.4 再訪坐標(biāo)系統(tǒng)*.............................................................................................................55 3.4.1 3ds Max至OpenGL——翻轉(zhuǎn)坐標(biāo)軸................................................................55 3.4.2 OpenGL至Direct3D——反射..........................................................................57 3.4.3 OpenGL至Direct3D——頂點(diǎn)重排列...............................................................61 3.5 視口轉(zhuǎn)換......................................................................................................................62 3.6 掃描轉(zhuǎn)換......................................................................................................................65 3.7 應(yīng)用:對(duì)象拾取操作...............................................................................................70 3.7.1 計(jì)算世界空間中的光線....................................................................................70 3.7.2 光線-對(duì)象相交測(cè)試...........................................................................................76 本章練習(xí)...............................................................................................................................82 第4章 片元處理和輸出合并.........................................................................................83 4.1 紋理操作......................................................................................................................83 4.1.1 紋理坐標(biāo)............................................................................................................84 4.1.2 表面參數(shù)化操作................................................................................................86 4.1.3 紋理坐標(biāo)與紋素地址........................................................................................87 4.2 輸出合并......................................................................................................................89 4.2.1 z緩沖區(qū)機(jī)制.......................................................................................................89 4.2.2 Alpha混合...........................................................................................................91 4.3 z剔除操作......................................................................................................................93 4.3.1 單元(tile)剔除...............................................................................................93 4.3.2 預(yù)寫Z值..............................................................................................................96 本章練習(xí)...............................................................................................................................96 第5章 光照和著色.......................................................................................................98 5.1 Phong光照模型.............................................................................................................98 5.1.1 漫反射................................................................................................................99 5.1.2 鏡面反射..........................................................................................................101 目 錄·VII· 5.1.3 環(huán)境反射..........................................................................................................103 5.1.4 發(fā)射光..............................................................................................................104 5.2 著色和著色語(yǔ)言........................................................................................................104 5.2.1 頂點(diǎn)和片元著色器........................... ...............................................................104 5.2.2 高級(jí)著色語(yǔ)言*.................................................................................................105 5.3 管線中的光照機(jī)制....................................................................................................107 5.3.1 HLSL中的逐頂點(diǎn)光照機(jī)制*...........................................................................107 5.3.2 逐頂點(diǎn)光照與逐片元光照..............................................................................109 5.3.3 HLSL中的逐片元光照*...................................................................................111 5.4 全局光照.....................................................................................................................113 5.4.1 光線跟蹤..........................................................................................................113 5.4.2 輻射度..............................................................................................................117 本章練習(xí)..............................................................................................................................119 第6章 參數(shù)曲線和表面....................................................................................121 6.1 參數(shù)曲線.....................................................................................................................121 6.1.1 Bezier曲線......................................................................................................121 6.1.2 Hermite曲線和Catmull-Rom樣條...................................................................126 6.2 應(yīng)用:相機(jī)路徑.........................................................................................................127 6.3 Bezier表面..................................................................................................................130 6.3.1 雙線性面片......................................................................................................130 6.3.2 雙二次Bezier面片............................................................................... .............134 6.3.3 雙三次Bezier面片............................................................................................138 6.3.4 Bezier三角形...............................................................................................140 本章練習(xí)..............................................................................................................................144 第7章 著色器模型...........................................................................................146 7.1 著色器模型4和幾何體著色器...................................................................................146 7.2 應(yīng)用:動(dòng)態(tài)粒子系統(tǒng).................................................................................................147 7.2.1 粒子的物理模擬..............................................................................................148 7.2.2 焰火模擬..........................................................................................................150 7.2.3 渲染焰火..........................................................................................................153 ·VIII· 計(jì)算機(jī)圖形學(xué)——基于3D圖形開(kāi)發(fā)技術(shù) 7.3 著色器模型5和拼接操作...........................................................................................155 7.4 應(yīng)用:PN三角形........................................................................................................156 7.4.1 計(jì)算控制點(diǎn)......................................................................................................157 7.4.2 計(jì)算控制法線..................................................................................................160 7.4.3 PN三角形拼接操作.........................................................................................163 本章練習(xí)..............................................................................................................................165 第8章 圖像紋理........................................................................................................166 8.1 紋理尋址模式............................................................................................................166 8.2 紋理過(guò)濾機(jī)制.............................................................................................................168 8.2.1 放大操作..........................................................................................................169 8.2.2 縮小操作..........................................................................................................170 8.3 紋理鏈........................................................................................................................171 8.3.1 紋理鏈的構(gòu)建過(guò)程..........................................................................................172 8.3.2 紋理鏈過(guò)濾機(jī)制..............................................................................................173 8.3.3 紋理鏈過(guò)濾的選取方案..................................................................................175 8.4 各向異性過(guò)濾機(jī)制.....................................................................................................179 本章練習(xí)............................................................................................................................184 第9章 凹凸貼圖........................................................................................................186 9.1 高度場(chǎng).........................................................................................................................187 9.2 法線貼圖原理.............................................................................................................188 9.2.1 法線貼圖..........................................................................................................188 9.2.2 法線貼圖算法..................................................................................................190 9.3 切空間法線貼圖.........................................................................................................194 9.3.1 切空間法線貼圖算法.............................................................................. ........194 9.3.2 切空間計(jì)算......................................................................................................198 9.4 法線貼圖應(yīng)用.............................................................................................................200 9.5 視差貼圖....................................................................................................................203 9.6 偏置貼圖....................................................................................................................206 本章練習(xí)............................................................................................................................210 第10章 高級(jí)紋理操作...............................................................................................211 10.1 環(huán)境貼圖...................................................................................................................211 目 錄·IX· 10.1.1 立方體貼圖....................................................................................................211 10.1.2 立方體貼圖訪問(wèn)機(jī)制*...................................................................................214 10.1.3 動(dòng)態(tài)立方體貼圖............................................................................................216 10.2 光照貼圖...................................................................................................................217 10.2.1 漫反射光照貼圖............................................................................................217 10.2.2 輻射度法線貼圖*...........................................................................................218 10.3 陰影貼圖...................................................................................................................222 10.3.1 陰影貼圖算法................................................................................................224 10.3.2 基于陰影貼圖的著色器代碼........................................................................228 10.3.3 陰影貼圖過(guò)濾機(jī)制........................................................................................231 10.4 環(huán)境遮擋...................................................................................................................234 10.5 延遲著色...................................................................................................................238 本章練習(xí)..............................................................................................................................240 第11章 角色動(dòng)畫.......................................................................................................241 11.1 關(guān)鍵幀動(dòng)畫...............................................................................................................241 11.2 旋轉(zhuǎn)...........................................................................................................................244 11.2.1 歐拉角插值....................................................................................................244 11.2.2 四元數(shù)表達(dá)方式............................................................................................245 11.2.3 基于四元數(shù)的旋轉(zhuǎn)........................................................................................246 11.2.4 四元數(shù)插值....................................................................................................250 11.3 層次結(jié)構(gòu)建模以及空間變換...................................................................................252 11.3.1 層次結(jié)構(gòu)模型................................................................................................252 11.3.2 骨骼間的空間變換........................................................................................256 11.3.3 世界空間至骨骼空間的轉(zhuǎn)換........................................................................258 11.4 前向運(yùn)動(dòng)學(xué)...............................................................................................................260 11.5 蒙皮和關(guān)鍵幀動(dòng)畫...................................................................................................263 11.5.1 蒙皮................................................................................................................263 11.5.2 關(guān)鍵幀動(dòng)畫中的蒙皮....................................................................................265 11.6 逆向運(yùn)動(dòng)學(xué)...............................................................................................................268 11.6.1 解析法............................................................................................................269 11.6.2 循環(huán)坐標(biāo)下降法............................................................................................270 ·X· 計(jì)算機(jī)圖形學(xué)——基于3D圖形開(kāi)發(fā)技術(shù) 本章練習(xí)..............................................................................................................................272 第12章 物理模擬......................................................................................................274 12.1 懲罰方案...................................................................................................................274 12.2 沖量方案...................................................................................................................276 12.2.1 沖量................................................................................................................277 12.2.2 基于沖量的碰撞求解方案............................................................................278 12.3 碰撞檢測(cè)...................................................................................................................282 12.3.1 色圍體及其層次結(jié)構(gòu)....................................................................................283 12.3.2 三角形-三角形相交測(cè)試...............................................................................286 本章練習(xí)..............................................................................................................................288 參考文獻(xiàn)........................................................................................................................289
|