880 likes | 1.01k Views
傳統的多邊形著色方式. 6.1 座標空間與傳統繪圖管線的幾何操作 6.2 瀏覽空間的操作 6.3 繪圖管線的演算 6.4 著色的範例. Introduction. 三維繪圖管線. 物件座標 場景座標 瀏覽座標 三維螢幕座標 顯示平面. 6.1 座標空間與傳統繪圖管線的幾何操作. 區域 物件 建模座標系統 世界 場景座標系統 相機 眼睛 瀏覽座標系統. 6.1.1 區域 物件 建模座標系統. 以物件之某個部份為參考點 用於物件之建模
E N D
傳統的多邊形著色方式 6.1 座標空間與傳統繪圖管線的幾何操作 6.2 瀏覽空間的操作 6.3 繪圖管線的演算 6.4 著色的範例
Introduction • 三維繪圖管線 物件座標 場景座標 瀏覽座標 三維螢幕座標 顯示平面
6.1座標空間與傳統繪圖管線的幾何操作 • 區域\物件\建模座標系統 • 世界\場景座標系統 • 相機\眼睛\瀏覽座標系統
6.1.1 區域\物件\建模座標系統 • 以物件之某個部份為參考點 • 用於物件之建模 • 保有物件之對稱性 • 有利於形變之處理
6.1.2世界\場景座標系統 • 用來描述一個世界或場景之座標系統 • 物件: • 運用Modelling transformations來放置 • 物件 • Camera/light source • Surface attributes are specified in this space (texture, colour and so on)
6.1.3 相機\眼睛\瀏覽座標系統 • 用於 建立瀏覽參數(視點, 瀏覽方向) 與瀏覽區域(view volume).
Virtual camera analogy • External camera parameters • Position • Orientation • Internal camera parameters • Those that affect the nature and size of the image on the film plane. • Lens type • Film size/ position/orientation
Simplest or minimum viewing system • This system consist of the following: • A view pointC • the view’s positions in world space • either the origin of the view coordinate system • or the centerof projection together with a view direction normal N • A view coordinate system defined with respect to the viewpoint • A view plane onto which the 2D image of the scene is projected • A view frustum or volume which defines the field of view
Transformation • Camera that can be positioned anywhere in world coordinate space, pointed in any direction and rotated about the viewing direction N. • Two components of the change coordinate transform of a point P in world coordinate (xw,yw,zw) to view coordinate (xv,yv,zv) • Translation: T • Rotational: R. where
View coordinates system • Three viewing parameters required for setting up view space axes • C :view point • A world space coordinate of the view point • N :view orientation • Can be specified by spherical coordinate system • V' : up vector • A world space vector used to calculate V axis, then U axis
View coordinates system (N view orientation) • Specifying the orientation of a vector N
View coordinates system (up vector) • The up vector V can be calculated from an indication given by V' • V = V'– (V‧N)N • U = N V
View coordinates system • In many APIs the following notation is used for the above UVN terminology • V = VUP (view-up vector) • N = VPN (view plane normal) • C = VRP (view reference point) • In OpenGL, for example, the viewing utility uses a camera point, a look at point and an up vector and in this case we have • gluLookAt(eyeX,eyeY,eyeZ, centreX,centreY,centerZ, upX,upY,upZ) • U = N (upX,upY,upZ) • V = (upX,upY,upZ) • N = (centreX,centreY,centerZ) – (eyeX,eyeY,eyeZ) • C = (eyeX,eyeY,eyeZ)
View coordinates system • Example
View coordinates system • A flight simulator, here the camera would remain fixed to the local coordinate system of the aircraft and would take the same transformations –translation and three rotations specifying roll, pitch and yaw • Rotate roll degrees about the z axis • Rotate pitch degrees about the x axis • Rotate yaw degrees about the y axis
6.2 Operations carried out in view space 6.2.1 Culling or back-face elimination 6.2.2 The view volume 6.2.3 Three-dimensional screen space 6.2.4 view volume and depth
6.2.1 Culling or back-face elimination • Culling or back-face elimination is an operation that compare the polygon normal Np of a complete polygon with the vieworientation vector N to determine the visibility of the polygon. • Visibility = Np • N >0 • Np is the polygon normal • N the line of sight vector
6.2.2 The view volume • A semi-infinite pyramid which can be further constrained to a more general view volume defined by • A view plane window • A near clip plane • A far clip plane • Objects and polygons outside the view volume are culled in whole or partially clipped
6.2.3 Three-dimensional screen space • The final 3D space in our pipeline • Operations carry out in this space • Clipping against the view volume • Rendering • Hidden surface removal (HSR) • Z-buffer • Perspective divide: projection from 3D view volume to 2D view plane window • Parallel/orthographic • perspective
Perspective projection • A perspective projection is the more popular or common choice in computer graphics because it incorporates foreshortening. • In a perspective projection relative dimensions are not preserved, and a distant line is displayed smaller than a nearer line of the same length.
Deriving a perspective transformation • 由相似三角型得 • In homogeneous coordinates
6.2.4 View volume and depth • 為能執行 HSR 計算(特別是在 Z-buffer 演算法), 必須能計算出多邊形內任一點的深度資訊 • 實際方法:給定一直線與一平面, 首先計算出兩者交接點的位置(參數位置), 再以內差方式由兩頂點的深度計算出該交接點的深度
Depth calculation • Zs = A+B/Zv • Where A and B are constants. These constants are determined from the following constraints • Choosing B < 0 so that as Zv increases then so does Zs • An important practical consideration concerning depth is the accuracy to which we store its value. To ensure this is as high as possible we normalise the range of Zs values so that the range Zv [d,f] maps into range Zs [0,1]
Full perspective transform • Considering the view volume in Figure 6.9 the full perspective transformation is given by • Where the additional constant h appearing in the transformation for xs and ys, ensure that these values fall in the range [-1,1] over the square screen
Full perspective transform • Adopting a similar manipulation to section 6.2.3 we have • The overall transformation from world space to screen space
Distortion in 3D screen space • Interpolating along a line in eye space is not the same as interpolating this line in screen.
Transformation from view space to screen space • The transformation of a box with one side parallel to theimage plane.
Transformation of the view volume into a canonical view volume Tpers1 Tpers2
6.3 Algorithm operations in the graphics pipeline 6.3.1 Basic view frustum culling and clipping 6.3.2 Shading pixels 6.3.3 interpolative shading techniques 6.3.4 Hidden surface removal
Introduction • We will describe a particular, but common, approach. • Hidden surface removal : Z-buffer algorithm • Shading : Interpolative shading • Advantage & Disadvantage • Advantage • There is no upwards limit on scene complexity • Disadvantage • Inefficiency: polygon rendered may be overwritten subsequently by other nearer polygons
6.3.1 Basic view frustum culling and clipping • The two common approaches to avoiding detailed low-level testing • Scene management • Bounding volumes
A simple bounding volume – the sphere • Information required • Radius of the bounding sphere • can be pre-calculated and stored as part of the database • Center of object • Usually be the local coordinate origin. • can be transformed by the pipeline
Completely inside Retained in list Completely outside Discarded A simple bounding volume – the sphere
Sutherland-Hodgman • A polygon is tested against a clip boundary by testing each polygon edge against a single infinite clip boundary
Dot product test • To calculate whether a point or vertex is inside, outside or on the clip boundary we use a dot product test • C : clip boundary • Nc : outward normal • S,F : endpoints of line • The line parametrically as • P(t) = S + (F-S)t • 0 ≤ t ≤ 1
6.3.2 Shading pixels • Local reflection models • Local reflection models – practical points • Local reflection models – light source considerations
Two separate considerations • There are two separate considerations to shading the pixels onto which a polygon projects. • Local reflection models • Shading algorithm
Local reflection models • The physical reflection phenomena that the model simulates are • Perfect specular reflection • Imperfect specular reflection • Perfect diffuse reflection