天天看點

圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12

文章目錄

  • charpter1
    • 圖形學的基本應用(C1,E33)
    • 光栅圖形,相關定義(如像素、真彩色、幀緩存等)與計算(C4,E35)
    • 圖形學的曆史(CG01)
    • 人類視覺系統(C16)(如光譜(C13)、顔色模型(C49, E98))
    • 三維圖形的處理流程(如頂點、裁剪、光栅化、片元等)(C25,E65)
  • chapter2
    • OpenGL 與 WebGL簡介
    • OpenGL 與WebGL函數的使用
      • opengl基本函數分類
      • 指定OpenGL視窗的顯示模式的函數是什麼?并給出互斥參數的比較分析。
      • WebGL的繪制流水線
    • 顔色索引(C51)
  • chapter3
    • 雙緩存 C75
    • 實體裝置(C7)(多種類型)與邏輯裝置(C9)(6種基本類型)
    • 三種基本的輸入模式(請求、采樣、事件)C10
    • GLUT的基本回調函數(顯示、滑鼠、形變、鍵盤、空閑等)C57,72
  • chapter4
    • 标量、向量、點的概念 C82
    • 仿射空間
    • 點積和叉積(圖形學意義)C88
    • 維數、基、坐标系與标架 C91
    • Homogeneous Coordinates C95
    • 三種基本變換:平移、旋轉、縮放(2D與3D)C111
    • 組合變換(順序問題)C117
    • 多邊形網格、多面體、歐拉公式(CG14) 、四元數(C132,CG13)
  • chapter5
    • 平面幾何投影的分類(平行與透視)C139
    • 不同領域的經典視圖 C139
    • 滅點的概念 C142
    • 建立觀察标架 C143、CG16
      • 照相機标架的定位 C144
    • 其它視圖API(如Yaw、Pitch、Roll,方位角、仰角)C150
    • 投影規範化 C153 C162 CG17
  • chapter 6
    • Phong光照模型三個分量:環境光、漫反射光、鏡面反射光 C186、 CG18
    • 反射系數與高光系數 C188
    • 中值向量與改進Phong光照模型 C189、CG19
    • Gouraud模型與Phong模型的明暗處理對比 C193、CG19
      • 均勻着色
      • 平滑着色
      • Phong着色
  • Chapter 8
    • 面向圖像與面向對象的方法C214、CG21
      • 隐藏面消除 的對象空間和圖像空間消隐算法 C235
    • 線段的裁剪:Cohen-Sutherland法(區域編碼)、Liang-Barsky法(參數順序) C218、CG21
    • 多邊形的裁剪:Sutherland-Hodgeman算法(裁剪與重構的4種情況)C222、CG22
    • 文本裁剪的方法(字元串、字元、矢量)C225、CG22
    • 畫家算法(C241)與深度緩存算法(C238)(Z-Buffer)CG22
    • 線段的掃描轉換:DDA、Bresenham(中點畫線算法)C229、CG23
    • 多邊形的掃描轉換:ET、AET、奇偶規則(C232)、特殊情況處理(C234) CG23
    • 走樣(若幹現象)與反走樣(兩種方法)C243、CG23
  • chapter11
    • 曲線曲面的表達方式:顯示、隐式、參數 C355
    • 三次曲線: Hermite(C363)、Bezier(C366)、B-spline (C368)
  • chapter12
    • 光線跟蹤(Ray tracing)概念 C391 CG40
    • 輻射度(Radiosity)概念 C398 CG41

說明:标題後面括号内容表示頁碼,

如 C1表示中文版第1頁,E33表示英文版第33頁, CG09-1表示PPTCG09第1頁

charpter1

圖形學的基本應用(C1,E33)

  • Display of information
  • Design
  • Simulation and animation

VR & AR

• 虛拟現實(VR),也稱靈境技術或人工環境。綜合利用計算機圖形系統和各種現實及控制等接口裝置,在計算機上生成的、可互動的三維環境中提供沉浸感覺的技術。其中,計算機生成的、可互動的三維環境成為虛拟環境(即Virtual Environment,簡稱VE)。

• 增強現實(AR,Augmented Reality),也稱之為混合現實。它通過電腦技術,将虛拟的資訊應用到真實世界,真實的環境和虛拟的物體實時地疊加到了同一個畫面或空間同時存在。增強現實不僅展現了真實世界的資訊,而且将虛拟的資訊同時顯示出來,兩種資訊互相補充、疊加。

  • User interfaces

光栅圖形,相關定義(如像素、真彩色、幀緩存等)與計算(C4,E35)

  • Raster 光栅

    Array of pixels

  • 光栅圖形:光栅圖也叫做位圖、點陣圖、像素圖,簡單的說,就是最小機關由像素構成的圖,隻有點的資訊,縮放時會失真。每個像素有自己的顔色,類似電腦裡的圖檔都是像素圖,把它放很大就會看到點變成小色塊了。
  • Pixel 象素Picture element
  • Resolution 分辨率Number of pixels in frame buffer
  • Frame Buffer 幀緩存

    Memory where pixels stored由像素組成的二維數組,每一個存儲單元對應螢幕上的一個像素,整個幀緩存對應一幀圖像。其中的分辨率表示像素數,深度(或精度)表示每個像素所用的比特數,深度為n bit的幀緩存可以表示2n種顔色。

  • true-color 真彩色,RGB每種原色配置設定8bit,進而每個像素24bit
  • Depth 深度 of Frame Buffer

    Number of bits that are used for each pixel (ex. 8-bit-depth 28(=256) colors, 24 or more bits per pixel RGB-color)

  • Rasterization 光栅化 (Scan Conversion掃描轉換)

    Converting of geometric entities (such as lines, circles, and polygons) to pixel assignment in frame buffer 從幾何實體到幀緩存中像素的顔色和位置的轉化

    圖形與圖像:

    圖形是矢量圖(Vector Drawn),它是根據幾何特性來繪制的。圖形的元素是一些點、直線、弧線等。矢量圖常用于架構結構的圖形處理,應用非常廣泛,如計算機輔助設計(CAD)系統中常用矢量圖來描述十分複雜的幾何圖形,适用于直線以及其它可以用角度、坐标和距離來表示的圖。圖形任意放大或者縮小後,清晰依舊。

    圖像是位圖(Bitmap), 它所包含的資訊是用像素來度量的。就像細胞是組成人體的最小單元一樣,像素是組成一幅圖像的最小單元。對圖像的描述與分辨率和色彩的顔色種數有關,分辨率與色彩位數越高,占用存儲空間就越大,圖像越清晰。

    圖形是人們根據客觀事物制作生成的,它不是客觀存在的;圖像是可以直接通過照相、掃描、攝像得到,也可以通過繪制得到。

圖形學的曆史(CG01)

人類視覺系統(C16)(如光譜(C13)、顔色模型(C49, E98))

  • RGB:加色模型(additive color model)
  • CMY(Cyan, Megenta, Yellow) : 減色模型(subtractive color model),C,M,Y分别是R,G,B的互補色(complementary color), 即白色減去R就是C。應用于商業列印和繪圖中。
  • color gamut 色域, 一個裝置可以生成的顔色集
  • color solid 顔色立方體

三維圖形的處理流程(如頂點、裁剪、光栅化、片元等)(C25,E65)

圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  1. Vertex Processing
  • 頂點包含了拓撲資訊(Topology):鄰接和次序關系。幾何資訊(Geometry): 點的位置坐标
  • The two major functions of this block are to carry out coordinate transformation and to compute a color for each vertex.

Projection:

- Perspective透視 projections: all projectors投影線 meet at the center of projection投影中心

- Parallel平行 projection: projectors投影線 are parallel, center of projection is replaced by a direction of projection投影方向

  1. Clipping and Primitive Assembly 裁減 與 圖元組裝
  • Clipping must be done on a primitive-by-primitive basis. Thus, within the stage of the pipline, we must assemble sets of vertices into primitives, such as line segments and polygons, before clipping can take place. The output of this stage is a set of primitives whose projections can appear in the iamge.
  • 透視投影和平行投影都有一個對應的裁剪體,Objects that are not within this volume are said to be clipped out of the scene
  1. Rasterization光栅化

The output of the rasterizer is a set of fragments for each object. A fragment can be thought as a pixel the carryies with its information, including

  • Have a location in frame buffer位置資訊
  • Color attributes顔色屬性
  • Depth information深度資訊
  1. Fragment Processing 片元處理

包括光照和明暗繪制(lighting and shading),紋理映射(texture mapping),凹凸映射(bump mapping),消隐(Hidden-surface removal)等。

chapter2

OpenGL 與 WebGL簡介

  • OpenGL(英語:Open Graphics Library,譯名:開放圖形庫或者“開放式圖形庫”)是用于渲染2D、3D矢量圖形的跨語言、跨平台的應用程式程式設計接口(API)。這個接口由近350個不同的函數調用組成,用來從簡單的圖形比特繪制複雜的三維景象
  • WebGL(全寫Web Graphics Library)是一種3D繪圖協定,這種繪圖技術标準允許把JavaScript和OpenGL ES 2.0結合在一起,通過增加OpenGL ES 2.0的一個JavaScript綁定,WebGL可以為HTML5 Canvas提供硬體3D加速渲染,這樣Web開發人員就可以借助系統顯示卡來在浏覽器裡更流暢地展示3D場景和模型了,還能建立複雜的導航和資料視覺化。顯然,WebGL技術标準免去了開發網頁專用渲染插件的麻煩,可被用于建立具有複雜3D結構的網站頁面,甚至可以用來設計3D網頁遊戲等等。

OpenGL 與WebGL函數的使用

  1. OpenGL Libraries
  • OpenGL core Library
  • OpenGL utility Library(GLU) :Provides functionality in OpenGL core but avoids having to rewrite code
  • Links with window system
    • GLX for X window systems (X window視窗擴充庫)
    • WGL for Windows (PC window視窗擴充庫)
    • AGL for Macintosh (蘋果window視窗擴充庫)
  • OpenGL Utility Toolkit (GLUT) 實用程式工具包: Provides functionality common to all window systems,Code is portable移植 but GLUT lacks the functionality of a good toolkit for a specific platform
  • glew : OpenGL擴充庫
    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  1. features(function format, etc.)
  • on the whole
    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  • OpenGL Functions format
圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12

opengl基本函數分類

函數 說明
圖元函數 控制繪制圖元 glPolygonMode(),glDrawArray()1
屬性函數 顔色屬性、填充模式 glClearColor()2, glEnable()13
觀察函數
變換函數 生成變換矩陣
輸入函數 接收輸入裝置的輸入,回調函數
控制函數 初始化程式、與視窗通信 glutInit()3,glutCreateWindow()4, glViewPort()5,…6
查詢函數 查詢裝置參數等
幀緩存 - glGenBuffers()7, glBbindBuffer()8,glBufferData()9
着色器輸入 - glGetAtrribLocation()10, glEnableVertexArray(), glVertexAttrib()11, glVertexAttribPointer()12
  1. glDrawArray
void glDrawArrays(	GLenum mode,
 	GLint first,
 	GLsizei count);
           
  • mode: Symbolic constants GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_LINE_STRIP_ADJACENCY, GL_LINES_ADJACENCY, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLES, GL_TRIANGLE_STRIP_ADJACENCY, GL_TRIANGLES_ADJACENCY and GL_PATCHES are accepted.
  • first

    Specifies the starting index in the enabled arrays.

  • count

    Specifies the number of indices to be rendered.

  1. glClearColor(): specify clear values for the color buffers
void glClearColor(	GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
           
  1. glutInit(int *agrc, char**argv);
  2. glutCreateWindow(char *title);
  3. void glViewport( GLint x, GLint y, GLsizei width, GLsizei height);

    左下角為原點

  4. glutMainLoop()

    void glutDisplayFunc(void (*func)(void)) 顯示回調函數

  5. void glGenBuffers( GLsizei n, GLuint * buffers);
  6. void glBindBuffer( GLenum target, GLuint buffer);
    • target: Specifies the target to which the buffer object is bound, which must be one of the buffer binding targets in the following table:
圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  1. void glBufferData(GLenum target, GLsizeiptr size, const void * data, GLenum usage);
  • example: flBufferData(GL_ARRAY_BUFFER, sizeof(points), points, GL_STATIC_DRAW);
  • usage: Specifies the expected usage pattern of the data store. The symbolic constant must be GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY, GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY, GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY.
  1. GLint glGetAttribLocation( GLuint program, const GLchar *name);

    Returns the location of an attribute variable

  2. glVertexAttrib — Specifies the value of a generic vertex attribute. including a group of functions. e.g

    void glVertexAttrib1f( GLuint index, GLfloat v0);

  3. void glVertexAttribPointer( GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer);

    define an array of generic vertex attribute data
  4. void glEnable( GLenum cap);
  • cap: Specifies a symbolic constant indicating a GL capability.
value explanlation
GL_BLEND If enabled, blend the computed fragment color values with the values in the color buffers. See glBlendFunc.
GL_CULL_FACE If enabled, cull polygons based on their winding in window coordinates. See glCullFace.
GL_DEBUG_OUTPUT If enabled, debug messages are produced by a debug context. When disabled, the debug message log is silenced. Note that in a non-debug context, very few, if any messages might be produced, even when GL_DEBUG_OUTPUT is enabled.
GL_DEPTH_TEST If enabled, do depth comparisons and update the depth buffer. Note that even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled. See glDepthFunc and glDepthRange.
GL_DITHER If enabled, dither color components or indices before they are written to the color buffer
GL_LINE_SMOOTH If enabled, draw lines with correct filtering. Otherwise, draw aliased lines. See glLineWidth
GL_POLYGON_SMOOTH If enabled, draw polygons with proper filtering. Otherwise, draw aliased polygons. For correct antialiased polygons, an alpha buffer is needed and the polygons must be sorted front to back.
GL_SAMPLE_ALPHA_TO_ONE If enabled, each sample alpha value is replaced by the maximum representable alpha value.
GL_STENCIL_TEST If enabled, do stencil testing and update the stencil buffer. See glStencilFunc and glStencilOp.
https://www.khronos.org/registry/OpenGL-Refpages/gl4//

指定OpenGL視窗的顯示模式的函數是什麼?并給出互斥參數的比較分析。

  • glutInitDisplayMode()

參數:

  • 顔色模式:GLUT_RGBA,GLUT_RGB 和 GLUT_INDEX(顔色索引)
  • 緩沖區類:GLUT_DOUBLE,GLUT_SINGLE
  • 深度緩存:GLUT_DEPTH
  • 模闆緩存:GLUT_STENCIL

WebGL的繪制流水線

圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  • 如上圖所示,主要分為4個步驟,第1步是頂點着色器的處理,主要是一組矩陣變換操作,用來把3D模型(頂點和原型)投影到Viewport上,輸出是一個個多邊形(比如三角形),第2步是光栅化,也就是把三角形連接配接區域按一定的粒度逐行轉化成片段(fragement),我們可以把這些片段看做是3D空間的像素點,第3步是片段着色器的處理,為每個像素添加顔色,第4步把3D空間的片段合并輸出為2D像素數組輸出到幀緩存然後顯示在螢幕上。

顔色索引(C51)

chapter3

雙緩存 C75

實體裝置(C7)(多種類型)與邏輯裝置(C9)(6種基本類型)

  • 實體裝置:

    定位裝置,鍵盤裝置,滑鼠,操縱杆,空間球等eg. mouse, trackball, light pen, data tablet, joy stick, space ball

  • 邏輯輸入裝置:

    Locator(定位裝置): 傳回一個位置(滑鼠)

    Pick(邏輯拾取裝置): 傳回對象的辨別ID(滑鼠)

    Keyboard: 傳回字元串(鍵盤)

    Stroke:傳回一系列位置

    Valuator(定值裝置): 傳回浮點數(滑杆)

    Choice(選擇裝置): 傳回n項中的一項(菜單)

  • 實體裝置與邏輯裝置差別?

    為使應用程式獨立于具體使用的實體裝置,引入邏輯裝置和實體裝置兩個概念,在應用程式中,用來請求I/O服務而使用的是邏輯裝置,系統在實際執行時使用的是實體裝置,系統為了實作從邏輯裝置到實體裝置的映射,設定了一張邏輯裝置表。每個表目包括邏輯裝置名、實體裝置名、裝置驅動程式入口。這樣做實作了裝置獨立性,帶來兩個好處:使裝置配置設定時具有靈活性和易于實作I/O重定向。

三種基本的輸入模式(請求、采樣、事件)C10

  • 請求模式(request mode):除非裝置被觸發,否則裝置的測量資料不會傳回給程式
  • 采樣模式(sample mode):輸入時即時的,隻要在使用者程式中遇到了函數調用,就把測量資料傳回給程式,是以不需要觸發器
  • 事件模式(event mode):有多個裝置的輸入時,每個輸入裝置都有它自己的觸發器并運作一個測量過程。每當一個裝置被觸發,就産生了一個事件。裝置的測量資料(包括該裝置的标志符)被放入一個事件隊列中。

    之後應用程式處理事件的方式:1、使用者程式檢查事件隊列中排在前面的事件,或如果隊列為空則等待,直到有事件發生檢查事件的類型然後決定做什麼。2、對每一種特定類型的事件關聯一個叫做回調的函數,作業系統定期檢查事件隊列中的事件,并且針對事件的類型執行相應的回調函數。

GLUT的基本回調函數(顯示、滑鼠、形變、鍵盤、空閑等)C57,72

  • GlutDisplayFunc(mydisplay) //顯示回調

    glutMouseFunc(mymouse) //滑鼠左右鍵和中鍵摁下的事件

    glutReshapeFunc //形狀改變~

    glutKeyboardFunc //鍵盤~

    glutIdleFunc //空閑~

    glutMotionFunc //當滑鼠鍵摁下時,滑鼠拖動的事件。當滑鼠拖動時,将每一幀都調用一次這個函數。

    glutPassiveMotionFunc //當沒有滑鼠鍵摁下時,滑鼠拖動的事件。當滑鼠拖動時,…(同上)

  • 調用過程:事件循環語句glutMainLoop();使程式進入一個無窮的事件循環,每經過事件循環一次,GLUT即檢視事件隊列中的事件,如果定義了相應的回調函數即執行,否則忽略該事件。
  • 顯示回調函數:隻要GLUT确定需要重新整理視窗(當第一次打開視窗,改變了視窗形狀,重新露出視窗,當使用者程式決定需要改變顯示内容的時候),那麼就會執行顯示回調函數。(每個GLUT程式都必須有一個顯示回調函數,必要時可以設定為空函數)。許多事件都會導緻調用顯示回調函數,避免一次事件循環過程中多次執行:glutPostRedisplay();(通過設定标志—檢查是否設定标志決定是否執行顯示回調函數)。

chapter4

标量、向量、點的概念 C82

  • point:三維空間中,點是空間中一個位置
  • Scalar:服從一組規則的對象,這些規則是從普通的算數運算中抽象出來的。
  • Vectors

    • Physical definition: a vector is a quantity with two attributes

    Direction方向

    Magnitude長度

仿射空間

  • 定義:仿射空間是點和向量的集合 [1] ,它的定義是:
    • (1)設A為一個點集,A中任意兩個有序點P、Q對應于n維矢量空間中的一個矢量a;
    • (2)設P、Q、R為A中任意三點,P、Q對應于矢量a,Q、R對應于矢量b,則P、R對應于矢量a+b。

      具有上面兩個性質的點集A就叫做一個仿射空間。

  • 運算:定義了兩種運算
    • 點加上向量得到點
    • 點點做差得到向量(點與點之間沒有加法運算)
  • 仿射空間是沒有起點隻有方向與大小的向量所構成的向量空間。
  • 線性變換的幾何意義是圖像的旋轉和變形,而仿射變換的幾何意義是旋轉和變性再加上位移,是以仿射變換也可以表示為線性變換再加上位移。用矩陣表示的話,線性變換是 y = Ax,而仿射變換是 y = Ax + b。

點積和叉積(圖形學意義)C88

維數、基、坐标系與标架 C91

  • 維數:In a vector space, the maximum number of linearly independent vectors is fixed and is called the dimension of the space
  • 基:In an n-dimensional space, any set of n linearly independent vectors form a basis for the space
  • 坐标系:在n維坐标系中,任意n個線性無關的向量v1、v2…vn可定義一個坐标系。
  • 标架:原點和基向量決定了一個标架

    Within this frame, every vector can be written as

    v = a 1 v 1 + a 2 v 2 + … . + a n v n v=a1v1+ a2v2 +….+anvn v=a1v1+a2v2+….+anvnand every point can be written as

    P = P 0 + b 1 v 1 + b 2 v 2 + … . + b n v n P = P0 + b1v1+ b2v2 +….+bnvn P=P0+b1v1+b2v2+….+bnvn

    Consider the point and the vector.They appear to have the similar representations

    p = [ b 1   b 2   b 3 ]          v = [ a 1   a 2   a 3 ] p=[b1\ b2\ b3] \ \ \ \ \ \ \ \ v=[a1\ a2\ a3] p=[b1 b2 b3]        v=[a1 a2 a3]

    which confuses the point with the vector

Homogeneous Coordinates C95

齊次坐标定義:将一個原本是n維的向量用一個n+1維向量來表示,是指一個用于投影幾何裡的坐标系統。

  • definition of Homogeneous Coordinates
    • A Single Representation

      We can write a vector v and a point P as( where P0 is the origin)

        v = a 1 v 1 + a 2 v 2 + a 3 v 3 = [ a 1   a 2   a 3   0 ] [ v 1   v 2   v 3   P 0 ] T \ v=a1v1+ a2v2 +a3v3 = [a1\ a2\ a3\ 0 ] [v1\ v2\ v3\ P0]^T  v=a1v1+a2v2+a3v3=[a1 a2 a3 0][v1 v2 v3 P0]T P = P 0 + b 1 v 1 + b 2 v 2 + b 3 v 3 = [ b 1   b 2   b 3   1 ] [ v 1   v 2   v 3   P 0 ] T P = P0 + b1v1+ b2v2 +b3v3= [b1\ b2\ b3\ 1 ] [v1\ v2\ v3\ P0]^T P=P0+b1v1+b2v2+b3v3=[b1 b2 b3 1][v1 v2 v3 P0]T

      Thus we obtain the four-dimensional homogeneous coordinate representation

      v = [ a 1   a 2   a 3   0 ] T v = [a1\ a2\ a3\ 0 ] T v=[a1 a2 a3 0]T p = [ b 1   b 2   b 3   1 ] T p = [b1\ b2\ b3\ 1 ] T p=[b1 b2 b3 1]T

    • If w=0, the representation is that of a vector

      p =[x’ y’ z’ w] T =[wx wy wz w] T

    • For w=1, the representation of a point is [x y z 1]
    • The homogeneous coordinates form for a three dimensional point [x y z] is given as

      p = [ x ’   y ’   z ’   w ] T = [ w x   w y   w z   w ] T p =[x’\ y’\ z’\ w] T =[wx\ wy\ wz\ w] T p=[x’ y’ z’ w]T=[wx wy wz w]TWe return to a three dimensional point (for w¹0) by

      x = x ’ / w x=x’/w x=x’/w y = y ’ / w y=y’/w y=y’/w z = z ’ / w z=z’/w z=z’/w

  • use of Homogeneous Coordinates
    • All standard transformations (rotation, translation, scaling) can be implemented with matrix multiplications using 4 x 4 matrices
    • Hardware pipeline works with 4 dimensional representations

三種基本變換:平移、旋轉、縮放(2D與3D)C111

  • translation平移: T − 1 ( d x , d y , d z ) = T ( − d x , − d y , − d z ) T^{-1}(dx, dy, dz) = T(-dx, -dy, -dz) T−1(dx,dy,dz)=T(−dx,−dy,−dz)
    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  • rotation: R − 1 ( q ) = R ( − q ) R^{-1}(q) = R(-q) R−1(q)=R(−q)
    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  • Scaling

    S − 1 ( s x , s y , s z ) = S ( 1 / s x , 1 / s y , 1 / s z ) S^{-1}(sx, sy, sz) = S(1/sx, 1/sy, 1/sz) S−1(sx,sy,sz)=S(1/sx,1/sy,1/sz)

    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12

組合變換(順序問題)C117

坐标系的變換是幾何變換的一個工具。

通常我們要在原坐标系 C0 執行一種變換 M0,但在原坐标系中難以通過基本的旋轉平移來計算。是以我們使用一個輔助坐标系 C1,先将C0中的坐标變換到C1中,變換矩陣為Ma。然後把C0中的變換M0等價為C1中的變換M1,最後C1中的坐标還原回C0。得到組合變換矩陣 M α − 1 M 1 M α M_\alpha^{-1}M_1M_\alpha Mα−1​M1​Mα​

以下面的例子為例,在原坐标系中有兩次變換。第一次相對y=x做變換,可以構造一個以y=x為軸的坐标系。第二次相對x=1變換,可以構造一個以 x=1為軸的坐标系。
  • 已知三角形ABC各頂點的坐标A(1,2)、B(5,2)、C(3,5),相對先直線y=x做對稱變換再相對于直線x=1做對稱變換,最終得到三角形A’B’C’,請給出變換方法,寫出相應的組合變換矩陣,并計算三角形A’B’C’的坐标
  • 注意,若向量用列向量表示,級聯的順序是從右到左
  • 坐标變換原理

    設 { v 1 , v 2 , v 3 } \{\textbf{v}_1, \textbf{v}_2, \textbf{v}_3\} {v1​,v2​,v3​} 和 { u 1 , u 2 , u 3 } \{\textbf{u}_1, \textbf{u}_2, \textbf{u}_3\} {u1​,u2​,u3​} 是兩組基。

    定義一個矩陣

    M = [ γ 11 γ 12 γ 13 γ 21 γ 22 γ 23 γ 31 γ 32 γ 33 ] \textbf{M}=\begin{bmatrix}\gamma_{11} &\gamma_{12} & \gamma_{13} \\ \gamma_{21} &\gamma_{22} & \gamma_{23} \\ \gamma_{31} &\gamma_{32} & \gamma_{33} \\ \end{bmatrix} M=⎣⎡​γ11​γ21​γ31​​γ12​γ22​γ32​​γ13​γ23​γ33​​⎦⎤​

    有, [ u 1 u 2   u 3 ] = M [ v 1 v 2 v 3 ] \begin{bmatrix} \textbf{u}_1 \\ \textbf{u}_2 \\ \textbf{ u}_3 \end{bmatrix} = \textbf{M} \begin{bmatrix} \textbf{v}_1 \\ \textbf{v}_2 \\ \textbf{v}_3 \end{bmatrix} ⎣⎡​u1​u2​ u3​​⎦⎤​=M⎣⎡​v1​v2​v3​​⎦⎤​

    令 T = M − 1 \textbf{T} = \textbf{M}^{-1} T=M−1

    則對于一個坐标(或者向量) w = β 1 v 1 + β 2 v 2 + β 3 v 3 \textbf{w}=\beta_1\textbf{v}_1+\beta_2\textbf{v}_2+\beta_3\textbf{v}_3 w=β1​v1​+β2​v2​+β3​v3​,

    用第二組基表示 w ‘ = α 1 u 1 + α 2 u 2 + α 3 u 3 \textbf{w}`=\alpha_1\textbf{u}_1+\alpha_2\textbf{u}_2+\alpha_3\textbf{u}_3 w‘=α1​u1​+α2​u2​+α3​u3​,

則 [ α 1 α 2 α 3 ] = T [ β 1 β 2 β 3 ] \begin{bmatrix}\alpha_1 \\ \alpha_2 \\ \alpha_3 \end{bmatrix} = \textbf{T} \begin{bmatrix} \beta_1 \\ \beta_2 \\ \beta_3 \end{bmatrix} ⎣⎡​α1​α2​α3​​⎦⎤​=T⎣⎡​β1​β2​β3​​⎦⎤​

多邊形網格、多面體、歐拉公式(CG14) 、四元數(C132,CG13)

  • 多邊形網格

    由多邊形彼此相接構成的網格,多邊形稱為網格的面,多邊形的頂點也稱為網格的頂點。一般要求兩張相鄰面的公共邊完全相同,即不能出現某一面的一個頂點在另一面的邊中間

  • 多邊形網格的類型
    • 實體,多邊形網格形成一個 封閉的空間區域
    • 表面,不形成空間封閉區域,表示一個 無限薄的曲面

      兩者都稱為多邊形網格(polygonal mesh),有時簡稱為網格

  • 網格組成的對象的可能的性質
    • 實體:如果網格形成一個封閉的有界區域
    • 連通性:如果任兩個頂點間存在着由邊構造的連續路徑
    • 簡單性:表示一個實體,而且沒有洞,即可以(沒有粘貼)變形到球面
    • 平面性: 如果所有面都是平面多邊形
  • 多面體是由簡單表面(平面)構造的連通網格,其形成一個有限體積的封閉實體
    • 多面體的每邊都有兩個面共享
    • 每個頂點至少有三條邊
    • 兩個面之間要麼無交,要麼隻在公共邊或頂點處相交
    • 四面體為多面體,環面為多面體當且僅當各面為平面
  • 歐拉公式

    在任何一個規則球面地圖上(簡單多面體),用 F記區域個 數 ,V記頂點個數 ,E記邊界個數 ,則

    F + V − E = 2 F + V- E= 2 F+V−E=2

  • 擴充的Euler公式

    如果多面體不是簡單的,在面上有H個洞,通過多面體的洞有G個,那麼

    V + F – E = 2 + H – 2 G V + F – E = 2 + H – 2G V+F–E=2+H–2G

    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  • 四元數

    Quaternions can express rotations on sphere smoothly and efficiently.

    Process:

    • Model-view matrix -> quaternion
    • Carry out operations with quaternions
    • Quaternion -> Model-view matrix
  • 旋轉
    • 點:p = (0, Q)
    • 定義四元數:r = (cosθ/2, sin θ/2 v), 其中v為一個機關向量
    • rpr−1得到點Q繞方向v旋轉θ角後的位置

chapter5

平面幾何投影的分類(平行與透視)C139

  • 平面幾何投影:投影到平面上的标準投影。投影線為直線,這些直線彙聚于投影中心,或者彼 此平行。這種投影保持共線性,但不一定保角。
  • 平行投影:投影中心與投影面之間的距離為無限,是以,隻需給出投影方向即可。平行投 影是透視投影的極限狀态。

    優勢與不足:1)保持了距離與角度 2)不能看到對象真正的全局形狀,因為許多面在視點中不可見。

  • 透視投影:投影線回聚于投影中心(COP)

    優勢與不足:1)同樣大小的對象,離視點越遠,投影結果就越小,但是看起來 更真實。 2)在一條直線等距離的幾點投影後不一定等距(非均勻收縮)。 3)隻有在平行于投影面的平面上角度被保持。 4)相對于平行投影而言,更難用手工進行繪制(但對計算機而言, 沒有增加更多的困難。)

  • 平行投影和透視投影相似點:
    • 觀察的基本元素相同,包括對象、觀察者、投影線、投影平面
圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12

不同領域的經典視圖 C139

  • 主面:在經典觀察中有一個基本的概念叫主面,對象的表面往往由一些平面組成,每個平面都可以看成是一個主面。
    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12

滅點的概念 C142

Parallel lines (not parallel to the projection plan) on the object converge at a single point in the projection (the vanishing point)

圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  • 主滅點:平行于坐标軸的平行線的滅點。

    主滅點的個數決定

    • 一點透視
    • 兩點透視
    • 三點透視

例:三點透視

圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12

建立觀察标架 C143、CG16

There are three aspects of the viewing process, all of which are implemented in the pipeline

  • Positioning the camera定位照相機
    • Setting the model-view matrix設定模型-視圖矩陣
  • Selecting a lens設定鏡頭
    • Setting the projection matrix設定投影矩陣
  • Clipping裁剪
    • Setting the view volume設定視景體
      圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12

照相機标架的定位 C144

本質上是把照相機放在原點上考慮如何移動物體。隻不過我們先考慮怎麼移動相機,再把相機移動等效成物體移動。

如下面這個圖是為了得到物體的側視圖。

圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  • 首先需要照相機繞y軸旋轉90°,相應的物體旋轉-90°。對應的變換矩陣R=Ry(-90)
  • 然後然後将相機移動,注意這個時候在對象标架中相機是向x方向移動,但實際考慮的是如何在照相機标架中移動物品,是以要沿z軸負方向移動。對應的變換矩陣 T=Tz(-d)
  • 最後得到組合變換 model_view=TR

(1)通過一系列旋轉平移來改變模-視變換矩陣,進而間接的指定照相機方位。(如上面的舉例)

(2)通過API來指定照相機的方位,首先在對象标架下面描述照相機的方位,第二步驟指定想要獲得的投影的類型(規範化變換),接下來指定照相機的方向,指定觀察平面的法向量(VPN),指定觀察的正向向量(VUP),VUP向量投影到觀察平面上面得到方向向上的向量v,向量v和向量n(vpn)正交得到第三個向量u,這個坐标系就被成為觀察坐标系,加上VRP(觀察參考點 第五版p186)就是觀察标架

其它視圖API(如Yaw、Pitch、Roll,方位角、仰角)C150

圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  • Elevation仰角, azimuth方位角, twist扭轉
    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12

投影規範化 C153 C162 CG17

  • All other views are converted to the default view by transformations that determine the projection matrix 由投影矩陣确定的變換把所有其它的視圖轉化為預設視圖
  • Allows use of the same pipeline for all views 進而可以對所有的視圖采用同樣的流水線體系
  • Normalization allows for a single pipeline for both perspective and orthogonal viewing規範化使得隻需要一個流水線體系就可以進行透視投影和正交投影
  • We stay in four dimensional homogeneous coordinates as long as possible to retain three-dimensional information needed for hidden-surface removal and shading盡可能位于四維齊次空間中,以便保持隐藏面消除和明暗處理所需要的三維資訊
  • We simplify clipping簡化了裁剪的操作
無論是平行投影還是透視投影,先進行投影規範化,将視見體轉化為标準視見體,然後執行透視除法,便可以統一使用正交投影得到最終結果。
  • 規範化過後使用的正交投影矩陣
    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  • 正投影變換矩陣(投影規範化)
    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  • 透視投影變換矩陣(投影規範化)
    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12

chapter 6

Phong光照模型三個分量:環境光、漫反射光、鏡面反射光 C186、 CG18

  • Uses four vectors四個向量

    • To source光源方向 I

    • To viewer視點方向 v

    • Normal法向n

    • Perfect reflector理想反射方向r

  • Ambient環境光:環境内均勻的照明,環境光強度在物體表面所有點都是相同的,但由于材質的差異,反射系數不同。

    I a = k a L a I_a = k_aL_a Ia​=ka​La​

  • Diffuse漫反射光:入射光線向各個方向散射,理想漫反射表面向各個方向散射的光線強度相同,是以不同位置的觀察者看到的反射光線一樣,被稱之為Lambert 表面。同時,更加Lambert定律,隻有入射光線的垂直分量才對照明起作用(中午地面反射的光比下午強)。

    I d = k d a + b d + c d 2 m a x ( ( l ⋅ n ) L d , 0 ) I_d=\frac{k_d}{a+bd+cd^2}max((\textbf{l}\cdot\textbf{n})L_d,0) Id​=a+bd+cd2kd​​max((l⋅n)Ld​,0) l \textbf{l} l是光源方向, n \textbf{n} n是法向量,d是距離,a、b、c是衰減系數,k是反射系數,Ld是漫反射光強度

  • Specular鏡面反射光:反射的光線集中在反射角附近,是以看起來有光澤。理想的鏡面反射所有光都沿反射角反向。

    I s = k s a + b d + c d 2 m a x ( ( r ⋅ v ) α L d , 0 ) I_s=\frac{k_s}{a+bd+cd^2}max((\textbf{r}\cdot\textbf{v})^\alpha L_d,0) Is​=a+bd+cd2ks​​max((r⋅v)αLd​,0) r \textbf{r} r是反射角方向, v \textbf{v} v是觀察者, α \alpha α是高光系數(shininess)。

反射系數與高光系數 C188

中值向量與改進Phong光照模型 C189、CG19

Gouraud模型與Phong模型的明暗處理對比 C193、CG19

  • 相同點:
    • 二者都是明暗處理技術
    • 都要先應用多邊形的法線算出其公共頂點的法線
    • 都應用局部反射模型計算多邊形頂點處的光強,算式為:
      圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
      即 反射光 = 環境光 + 漫反射 + 鏡面反射。
    • d) 都不考慮物體間的互相作用,
  • 不同點:
    • Gouraud明暗處理隻在多邊形頂點處采用Phong局部反射模型計算光強,而在多邊形内的其他點采用雙向線性插值,這樣做的優點是高效,但是無法很好的處理鏡面高光問題,依賴于其所在多面形的相對位置;

      而Phong明暗處理,通過內插補點計算每個頂點的法向量3次內插補點(在x,y,z三個方向分别進行內插補點計算),然後計算每個點上的光強值,這樣效果好,但計算複雜,需要付出比Gouraud 4-5 倍的時間。

    • 繪制方法

    Gouraud Shading:

    1. Find average normal at each vertex (vertex normals)

    2. Apply modified Phong model at each vertex

    3. Interpolate vertex shades across each polygon

    Phong Shading

    5. Find vertex normals

    6. Interpolate vertex normals across edges

    7. Interpolate edge normals across polygon

    8. Apply modified Phong model at each fragment片元

通常,在一個比較複雜的場景中,當物體鏡面發射很微弱時,我們對其采用Gouraud明暗處理,而對于一些鏡面高光的物體,采用Phong明暗處理,這樣既保證品質,又保證速度。
  • If the polygon mesh approximates surfaces with a high curvatures, Phong shading may look smooth while Gouraud shading may show edges. 如果用多邊形網格逼近大曲率曲面,Phong方法的結果可能看起來光滑一些,而Gouraud方法就會使邊有些明顯
  • Phong shading requires much more work than Gouraud shading Phong.Until recently not available in real time systems。Phong方法比Gouraud方法的複雜度高,直到現在,在實時系統中還不可用

    可以用片段處理器實作

  • Now can be done using fragment shaders (see Chapter 9)可以用片元處理器實作
  • Both need data structures to represent meshes so we can obtain vertex normals 兩種方法都需要特定資料結構表示網格,進而可以擷取頂點法向量

均勻着色

在同一多邊形上法向n為常向量

視點在無窮遠,視點方向v是常向量

光源在無窮遠,入射方向l也是常向量

進而對于每個多邊形,隻需要計算其上一點的顔色,其它點的顔色與它相同

OpenGL裡,下面函數定義平面明暗處理效果 glShadeModel(GL_FLAT);

平滑着色

  • 在網格中每個頂點處有幾個多邊形交于該點,每個多邊形有一個法向,取這幾個法向的平均化得到該點的法向
    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
  • 然後利用簡單光照模型計算出頂點的顔色
  • 對于多邊形内的點,采用線性插值确定顔色
  • OpenGL中設定光滑明暗處理

    glShadeModel(GL_SMOOTH);

Phong着色

  • 與Gouraud方法不同,Phong方法是根據每個頂點的法向,插值出多邊形内部各點的法向,然後基于光照模型計算出各點的顔色

Chapter 8

面向圖像與面向對象的方法C214、CG21

  • 面向圖像(image-oriented)的方法,面向對象(object-oriented)的方法也分别稱為, 先排序(sort-first),後排序(sort-last)方法,基于隐藏面消除發生的地方進行命名的
  • 面向對象方法優缺點:

    • 優點:處理速度快,運作成本低

    • 缺點:

    • 過去需要占用大量記憶體,每個對象單獨處理的代價較大。由于低價大容量記憶體,以及專用硬體晶片的出現,已不再是問題
    • 不能得到大多數全局效果,例如涉及多個對象的複雜光照

      • 隐藏面消除例外,Z buffer全局深度資訊

  • 面向圖像方法優缺點:

    • 優點:

    • 任何時刻隻需有限的顯示記憶體,且可以按顯示器的重新整理速度和次序生成像素
    • 利用相鄰像素間的連貫性可設計增量式算法
    • 适合處理全局效果
    • 缺點:
    • 需要複雜的幾何對象的資料結構
    • 必須确定哪些圖元影響哪些像素
    • 繪制過程中需要随時通路所有的幾何資料

隐藏面消除 的對象空間和圖像空間消隐算法 C235

線段的裁剪:Cohen-Sutherland法(區域編碼)、Liang-Barsky法(參數順序) C218、CG21

  • Cohen-Sutherland Algorithm

    • Idea: eliminate as many cases as possible without computing intersections

    • Start with four lines that determine the sides of the clipping window從

多邊形的裁剪:Sutherland-Hodgeman算法(裁剪與重構的4種情況)C222、CG22

圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12

文本裁剪的方法(字元串、字元、矢量)C225、CG22

畫家算法(C241)與深度緩存算法(C238)(Z-Buffer)CG22

畫家算法就是一種對象空間消隐算法,需要對對象進行深度排序,有個缺點——難以直接處理嵌套重疊等複雜情況。

Z-buffer算法是一種圖像空間消隐算法

線段的掃描轉換:DDA、Bresenham(中點畫線算法)C229、CG23

多邊形的掃描轉換:ET、AET、奇偶規則(C232)、特殊情況處理(C234) CG23

走樣(若幹現象)與反走樣(兩種方法)C243、CG23

圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12

chapter11

曲線曲面的表達方式:顯示、隐式、參數 C355

  • 顯示:z=f(x, y)
  • 隐式:f(x, y, z)=0
  • 參數

    p ( u ) = [ p x ( u ) p y ( u ) p z ( u ) ] = c 0 + c 1 u + c 2 u 2 + c 3 u 3 = ∑ k = 0 3 c k u k = u T c \textbf{p}(u)=\begin{bmatrix}p_x(u)&p_y(u)&p_z(u)\end{bmatrix}=\textbf{c}_0+\textbf{c}_1u+\textbf{c}_2u^2+\textbf{c}_3u^3=\sum^3_{k=0}{\textbf{c}_ku^k}=\textbf{u}^T\textbf{c} p(u)=[px​(u)​py​(u)​pz​(u)​]=c0​+c1​u+c2​u2+c3​u3=k=0∑3​ck​uk=uTc其中

    c = [ c 0 c 1 c 2 c 3 ]     u = [ 1 u u 2 u 3 ]      c k = [ c k x c k y c k z ] \textbf{c}=\begin{bmatrix}\textbf{c}_0\\\textbf{c}_1\\ \textbf{c}_2 \\\textbf{c}_3\end{bmatrix}\ \ \ \textbf{u}=\begin{bmatrix}1 \\u \\u^2\\u^3\end{bmatrix}\ \ \ \ \textbf{c}_k=\begin{bmatrix}c_{kx}\\ c_{ky}\\ c_{kz}\end{bmatrix} c=⎣⎢⎢⎡​c0​c1​c2​c3​​⎦⎥⎥⎤​   u=⎣⎢⎢⎡​1uu2u3​⎦⎥⎥⎤​    ck​=⎣⎡​ckx​cky​ckz​​⎦⎤​

    寫成分量形式等價為:

    p x ( u ) = c 0 x + c 1 x u + c 2 x u 2 + c 3 x u 3 p y ( u ) = c 0 y + c 1 y u + c 2 y u 2 + c 3 y u 3 p z ( u ) = c 0 z + c 1 z u + c 2 z u 2 + c 3 z u 3 p_x(u)=c_{0x}+c_{1x}u+c_{2x}u^2+c_{3x}u^3\\p_y(u)=c_{0y}+c_{1y}u+c_{2y}u^2+c_{3y}u^3\\p_z(u)=c_{0z}+c_{1z}u+c_{2z}u^2+c_{3z}u^3 px​(u)=c0x​+c1x​u+c2x​u2+c3x​u3py​(u)=c0y​+c1y​u+c2y​u2+c3y​u3pz​(u)=c0z​+c1z​u+c2z​u2+c3z​u3

三次曲線: Hermite(C363)、Bezier(C366)、B-spline (C368)

  • 參數連續性
    • C 0 \textbf{C}^0 C0參數連續性:連接配接處值相等
    • C 1 \textbf{C}^1 C1參數連續性:連接配接處值相等且導數相等,可推廣得到 C n \textbf{C}^n Cn參數連續性
    • G 1 \textbf{G}^1 G1幾何連續性:連接配接處值相等且切向向量成比例,可推廣得到 G n \textbf{G}^n Gn幾何連續性
  • Hermite

    通過兩個斷點(u=0,u=1)及端點處的導數來計算曲線的參數方程。Bezier相當于是Hermite的一種具體的實作算法。

  • Bezier

    有4個控制點 p 0 , p 1 , p 2 , p 3 \textbf{p}_0,\textbf{p}_1,\textbf{p}_2,\textbf{p}_3 p0​,p1​,p2​,p3​。使用 p 0 , p 3 \textbf{p}_0,\textbf{p}_3 p0​,p3​作為u=0,1時曲線上的點,即 p ( 0 ) , p ( 1 ) \textbf{p}(0),\textbf{p}(1) p(0),p(1)。使用如下近似公式拟合曲線在u=0,1的切線。

    p ′ ( 0 ) ≈ p 1 − p 0 1 / 3 p ′ ( 1 ) ≈ p 3 − p 2 1 / 3 \textbf{p}'(0) \approx \frac{\textbf{p}_1-\textbf{p}_0}{1/3}\\\textbf{p}'(1) \approx \frac{\textbf{p}_3-\textbf{p}_2}{1/3} p′(0)≈1/3p1​−p0​​p′(1)≈1/3p3​−p2​​

    通過這4個點求得參數 c \textbf{c} c。

    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12
局限在于隻有C0連續性
  • B-spline
    圖形學複習charpter1chapter2chapter3chapter4chapter5chapter 6Chapter 8chapter11chapter12

chapter12

光線跟蹤(Ray tracing)概念 C391 CG40

  • 光線跟蹤是一種渲染算法,該算法模拟燈光穿過場景的方式:從光源發出,經具有特定材質屬性的幾何對象反射或折射,最終顯示在觀察者的眼中,通常是在攝影機的膠片上。為了最大限度地減少計算成本并隻渲染場景的可見部分,該算法采用向後計算:它從攝影機處開始,沿着目前視圖方向發送光線。如果該光線遇到某個對象,則将對其材質求值,然後傳回并存儲最終的顔色資訊。如果材質能夠進行反射或折射,則會将光線進一步發送到場景中以計算對最終顔色的貢獻。此過程會遞歸重複,直到達到特定周遊深度。
  • 應用
    • 計算反射和折射。
    • 通過對點和光源之間是否存在任何對象進行求值計算非常精确的陰影。也可以通過其他方法計算陰影;這些方法雖然速度更快,但精确度較低。
    • 光線跟蹤能夠建立半透明陰影(例如,彩色玻璃的陰影投射)。

輻射度(Radiosity)概念 C398 CG41

Radiosity solves rendering equation for perfectly diffuse surfaces

  • 輻射度算法(Radiosity)是一種全局光照算法,用于三維計算機圖形學繪制。和傾向于隻在一個表面上模拟一次光的反射的直接光照算法(例如光線跟蹤)不同,像輻射度算法這樣的全局光照算法模拟光在一個場景裡的多次反射,通常會導緻更柔和更自然的影子和反射。
  • Consider objects to be broken up into flat patches (which may correspond to the polygons in the model)
  • Assume that patches are perfectly diffuse reflectors
  • Radiosity = flux = energy/unit area/ unit time leaving patch

繼續閱讀