1 / 39

第七章 Hidden Surface Removal

第七章 Hidden Surface Removal. Hidden-Line Removal Hidden-Surface Removal. 方法: 1. Back-Face Removal 2. Depth-Buffer Z-Buffer 3. Scan-Line Method 4. Depth Sorting 5. Area Subdivision 6. Octree Method. Hidden-Line

Download Presentation

第七章 Hidden Surface Removal

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第七章 Hidden Surface Removal

  2. Hidden-Line Removal Hidden-Surface Removal 方法: 1. Back-Face Removal 2. Depth-Buffer Z-Buffer 3. Scan-Line Method 4. Depth Sorting 5. Area Subdivision 6. Octree Method

  3. Hidden-Line Hidden-Surface Removal Object Space 用物體的幾何定義來計算。 物體 → 幾何定義 → 點、線、面 → 決定哪部分物體是看得到的 → 畫出看得到的部分物體 → 畫素畫出 Image Space 用畫出物體的畫素(pixels)來計算。 物體 → 物體畫出來的畫素 → 畫素 → 決定哪些畫素是看得到的 → 畫出看得到的畫素 → 畫素畫出

  4. Back-Face Removal 利用平面程式來決定 哪些平面在後面,即看不到的平面 Plane Equation 在Right-Handed Coordinate System 如果 則 在“Inside” of plan 點與面的關係

  5. <0 >0 Y N(A,B,C) X view Direction 平面 Plane 看不到 Invisible, hidden Z view point Identify all hidden surfaces 特點: 1. 快速決定 Completely Visible Completely Hidden 因為在幾何運算較簡單 2. Partially Hidden Need more test 再處理 可先處理大部分的面 fast

  6. 假設 為viewing position。 向一平面 看去。 ● 如果 true Back Face Cannot see from

  7. Normal Vector of Plane N(A,B,C) Z Normal Vector 的 Component C 是平行 Viewing Direction ● 如果C<0 Normal Vector points away from viewing position 指向離開 Back Face C

  8. Plane Equation 3 points on the plane (not colinear)

  9. Two Planes Plane 1: Plane 2: Plane 1 Plane 1 Plane 1 Plane 1 相同

  10. Depth - Buffer Algorithm Z – Buffer Algorithm Image Space ●Test Visibility one pixel at a time ● For each (x,y) pixel, the surface with the smallest Z at that position is visible

  11. ● ● ● Viewing Direction 遠→Z 大 近→Z 小 的Z值最小, 有最小Z值,只顯示畫出 亮度 Intensity of S3 (Z3) Saved for position (x,y)

  12. 2 buffers Depth Buffer:Store Z-value for each (x,y) position, 儲存所有(x,y)位置的 Refresh Buffer:Store Intensity Value for each (x,y) position 儲存所有(x,y)位置的 Z值 亮度

  13. 步驟: 0. Depth Normalized 0~1 Initially, all positions Depth Buffer 1 (Maximum) Refresh Buffer Background 1. 處理每一Surface,轉成畫素,計算每一個(x,y)位置 的Z-value 2. 比較相同(x,y)位置的Z-value 3. 如果新的Z比較小,儲存新的Z改變Intensity

  14. Depth – Buffer Algorithm (Z - Buffer) 1. Initialize Depth Buffer and Refresh Buffer。 初始值 所有的(x,y)位置 Depth (x,y)=1 Refresh (x,y)=Background 2. 計算Surface上每一(x,y)點的Z值。 設Z(x,y) =z 為其Z值。 I (x,y) =i 為其亮度 Intensity。

  15. 3. If Z (x,y)<Depth (x,y) Z在前面 Then set Depth (x,y) = Z (x,y) Refresh (x,y) = I (x,y) If z < 目前 Depth (x,y)不在前 Not Vision 4. 重複處理所有Surfaces的所有(x,y)位置。

  16. Depth-Buffer(Z-Buffer)方法 相當於是尋找最小的zi以表現(x,y)畫出的亮度 Depth–Buffer Refresh–Buffer 最小Z值,表現其亮度及畫出 z1最小 (x,y)位置只畫出 的亮度顏色

  17. 從左進入(outside→inside)→給ON 從右離開(outside→inside)→給OFF outside outside inside X+ Scan Line ON OFF Scan - Line Method Image-Space ● one scan line at a time 一次處理一條掃描線 ● 所有與Scan line有intersection交點的edges邊線, 將被用來判斷一Surface面是否Visible 1. 所有的面的邊緣列出並sorted in order of increasing x。 2. 一條一條Scan line從左到右掃描通過所有Surface。 3. Scan line與Surface交點給一flag。

  18. B E S2 S1 Scan line1 1 F A 2 2 3 3 C H D G Line 1 通過AB, BC, HE, EF Line 1 AB → BC 只有S1 flag ON Intensity for S1 ON 只畫S1 HE → EF 只有S2 flag ON Line 2 通過DA, HE, BC, FG DA →HES1 ON HE →BCBOTH ON BC →FGS1 OFF S2 ON FG → S2 OFF

  19. ● 只有一個Surface ON 只畫一個Surface ●Both Surface ON 計算depth,詳細比較 例如depth of S1< S2 則顯示S1 ,直到通過BC S2 S1 OFF→Background ON 1 ON OFF ON OFF OFF ON 2 3 ON ON OFF ON OFF

  20. Image-Space Object-Space ● 在Object-Space比較深度 在Image-Space做Scan-conversion由遠到近畫出 ●Both 1. Surfaces 做Depth Z由大到小的排列 • Object Space • Largest Z-value of each surface P, Q,R, S, T Surfaces Z小 Z大 Depth – Sorting Method

  21. 2. Resolve ambiguities。解決不清楚處 Reordering。重排 Z大 → Z小 3. Surfaces 以Depth Z大到小的順序,做Scan-Conversion 畫出。 • 由遠而近,Z大 → Z小 • Image Space 主要方法 Sorting in Object Space Scan-Conversion in Image Space also call painter’s Algorithm

  22. 假設有P,Q,R,… Surface • 由大Z到小z排列 • 假如在Depth上沒有重疊 → 依序做Scan-convert • 假如在Depth上有重疊 → Test

  23. 假設有Q與P重疊 • 以下Test Q與P,4項Test • 2個Surfaces投影到X-Y plane,在X-Y plane上2個Surfaces的Bounding Rectangle沒有重疊,在X-extent,Y-extent都無重疊。 • Surface P is on outside of Q. • Surface Q is on inside of P. • 2個Surface在X-Y平面plane上的投影沒有重疊。 (同一側) (Zpmax>ZQmax) outside 遠 inside 近 相對於view plane, (同一側) (Zpmax<ZQmax) outside 遠 inside 近

  24. Zv Zv P P Q Q Xv Yv No Depth Overlap Zv 有Depth overlap No overlap P X Y Q in Direction Xv 1.

  25. Zv P outside Q View Direction inside Xv Zv outside P inside Q Xv 2. P is “outside” Q P is “outside” Q

  26. Zv P Q Xv Zv P Q Xv 3. P is “inside” Q P is “inside” Q

  27. 計算方法 Test 1: 比較Bounding Rectangles的X-extent,Y-extent之座標。 Test 2: Q plane Equation EX + FY + GZ + H = 0 Vertices of P 代入 Q plane e.q. Ex + Fy + Gz + H > 0 P outside Q (x,y,z)

  28. Test 3: P plane equation AX + BY + GZ + D = 0 Vertices of Q代入P plane equation Ax’ + By’ + Cz’ + D < 0 Q inside P (x’,y’,z’)

  29. y y x x Test 4: 1.計算是否有intersection。 2.Surfaces在X-Y平面上的投影projection是否有 intersection。

  30. Q Q1 Q2 交疊交切複雜時,先分割小的單純面。

  31. 以上4 Test • 如果至少1個正確成立 保持原來order • 如果全部不成立 • Interchange P,Q(交換P,Q) • 將P,Q在sorted order list中之位置交換 (Z大到Z小) Z大 R Q P Z小 原來 Z大→Z小 P Q R view 1.不成立 2.P代入R equation<0 3.R代入P equation>0 4.不成立 • P,Q,R原來Z大→Z小 • Swap P,Q • Swap R,Q • 結果 Q R P

  32. Area Subdivision Method Image Space • 一直連續分割一個區域成數個小方塊。 • 直到每小方塊都是單純的Visible or Hidden or No Surface • Subdivision • Single visible surface or No surface • If NOT → subdivision → (1) • Smallest division → a pixel

  33. Subdivided Area小方塊 與 Surface 的關係 比較 Surface S Surface Area Area Area Area S Area Subdivision Warnock’s Algorithm Surrounding Surface Surface完全包含Area Inside Surface Surface完全在Area內 Outside Surface Surface完全在Area外 Overlapping Surface Surface 部分在內 部分在外

  34. 結果 • Surfaces都在Area outside → Background color displayed in the area • 只有一個Surface且是inside or overlapping → 先填area為Background color,在畫Surface在area 內的部分 • 只有一個Surface且是Surrounding → area全畫Surrounding Surface的顏色 • 超過1個Surfaces是inside,overlapping,or surrounding,但有一Surrounding為最小Z → area畫此最小Z(最近)的Surrounding Surface

  35. X Z outside inside intersection View Dir. surrounding Area X 如果以下有1個成立,就不必再做Subdivision。 • 全部Surfaces都是outside the area。 • 在area內只有1個inside,overlapping,or surrounding的surface。 • 一個Surrounding surface的Z值最小,蓋過其他surface。

  36. pixel position 先畫 Surface S1 Surface S2 Final Image Hidden Area(S2)

  37. S A1 A2 如果Subdivision一直到area小的為1個pixel →compare depth →類似 Z-buffer 變化的area分割法,以具有 min Z的surface來subdivide a area,沿著surface boundary做subdivision

  38. 2 1 0 3 Quadtree 四分樹 • area分成四份 • 比較每一份中surface與area的關係 • Visible • Hidden • Inside • Outside • 關係清楚著色畫出 • 不清楚者再做Quadtree division

  39. view 6 5 0 1 1 4 3 2 0 2 3 7 view Octree 八分樹 for viewing volume project octree nodes onto viewing surfaces 0,1,2,3 → front octants → visible 4,5,6,7 → back octants → hidden → removed

More Related