Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 7. Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.

Similar presentations

Presentation on theme: "Chapter 7. Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s."— Presentation transcript:

1 Chapter 7. Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s

2 중간고사 풀이 1. Vector displayer 와 raster displayer 에 대해 각 각 간략히 설명하고, 왜 현재에는 vector displayer 를 사용하지 않고 raster displayer 만 사 용하는 지 그 이유를 설명하라. (10 점 ) 2. 두 점을 연결하는 라인에 대한 Scan Conversion 알고리즘 중 Bresenham Line Drawing 의 방법에 대해 간략히 기술하고, 이 방법 이 계산 효율성 측면에서 이점을 갖는 이유를 설 명하라. (10 점 )

3 중간고사 풀이 3. Callback 함수의 의미에 대해 설명하고, GLUT 에서 제공하는 수업시간에 다룬 3 가지 callback 함수를 나열하고 각각에 대해 간략히 설명하라. 4. 5 개 점 (p 1,p 2,p 3,p 4,p 5 ) 로 정의된 별 모양의 다 각형 내부를 다음 그림과 같이 색칠하고 싶다. 이 때 주어진 임의의 점에서의 다각형에 대한 내 ∙ 외 부 결정 방법에 대해 간략히 설명하라. (10 점 )

4 중간고사 풀이 5. Flood filling 방법에 대해 설명하고, 이때 stack 의 역할에 대해 간략히 쓰라. (10 점 ) 6. antialiasing 방법 중 supersampling 방법에 대 해 간략히 설명하라. (10 점 )

5 중간고사 풀이 7. 3x3 행렬이 주어 졌을 때 이 행렬이 3 차원 회전 을 의미하는 행렬인지 아닌지 구분하는 방법에 대 해 설명하라. (10 점 ) 8. Euler angle 에 대해 간략히 설명하라. (10 점 ) 9. Affine Combination 에 대해 설명하되 결과값이 의미를 갖는 2 가지 경우에 대해 각각 설명하라. (10 점 )

6 중간고사 풀이 10. 어떤 물체를 두 점 P 1 (x 1,y 1,z 1 ), P 2 (x 2,y 2,z 2 ) 로 이루어진 임의의 축을 중심으로 (theta) 만큼 회전 시키는 4x4 변형행렬을 계산하려 한다. 그 과정에 대해 단계를 나누어 설명하라. (10 점 )

7 Viewing Pipeline

8 Virtual Camera Model Viewing Transformation –The camera position and orientation is determined Projection Transformation –The selected view of a 3D scene is projected onto a view plane

9 General 3D Viewing Pipeline Modeling coordinates (MC) World coordinates (WC) Viewing coordinates (VC) Projection coordinates (PC) Normalized coordinates (NC) Device coordinates (DC)

10 OpenGL 3D Viewing Functions Viewing-transformation function –glMatrixMode(GL_MODELVIEW); –gluLookAt(x0,y0,z0,xref,yref,zref,vx,vy,vz); –Default: gluLookAt(0,0,0, 0,0,-1, 0,1,0); OpenGL orthogonal-projection function –glMatrixMode(GL_PROJECTION); –gluOrtho(xwmin,xwmax, ywmin,ywmax, dnear,dfar); –Default: gluOrtho(-1,1, -1,1, -1,1); –Note that dnear and dfar must be assigned positive values z near =-dnear and z far =-dfar The near clipping plane is the view plane

11 OpenGL 3D Viewing Functions OpenGL perspective-projection function –The projection reference point is the viewing-coordinate origin –The near clipping plane is the view plane –Symmetric: gluPerspective(theta,aspect,dnear,dfar) –General: glFrustum(xwmin,xwmax,ywmin,ywmax,dnear,dfar)

12 Chapter 9 Visible-Surface Detection Sang Il Park Sejong University

13 Visible-Surface Detection Methods Determine what is visible within a scene from a chosen viewing position Two approaches –Object-space methods: Decide which object, as a whole, is visible –Image-space methods: The visibility is decided point- by-point Most visible-surface algorithms use image- space methods Sometimes, these methods are referred to as hidden-surface elimination

14 Approaches Back-Face Removal Depth Buffer A-Buffer Scanline Depth Sorting BSP Tree Area Subdivision Octree Raycasting

15 Back-Face Removal (Culling) Used to remove unseen polygons from convex, closed polyhedron Does not completely solve hidden surface problem since one polyhedron may obscure another

16 Back-Face Removal (Culling) Compute the equation of the plane for each polygon –A point (x,y,z) is behind a polygon surface if Determine back-face –In projection coordinates, we need to consider only the z component of the normal vector N

17 Depth-Buffer (Z-Buffer) Z-Buffer has memory corresponding to each pixel location –Usually, 16 to 20 bits/location.

18 Review: Normalizing Transformation Transform an arbitrary perspective-projection view volume into the canonical view volume Step 1: from frustum to parallelepiped

19 Review: Normalizing Transformation Transform an arbitrary perspective-projection view volume into the canonical view volume Step 2: from parallelepiped to normalized

20 Depth-Buffer (Z-Buffer) Initialize –Each z-buffer location  Max z value –Each frame buffer location  background color For each polygon: –Compute z(x,y), polygon depth at the pixel (x,y) –If z(x,y) < z-buffer value at pixel (x,y), then z buffer(x,y)  z(x,y) pixel(x,y)  color of polygon at (x,y)

21 Depth Calculation Calculate the z-value on the plane Incremental calculation

22 Depth-Buffer (Z-Buffer) Advantages/Disadvantages –Lots of memory –Linear performance –Polygons may be processed in any order Modifications needed to implement antialiasing, transparency, translucency effects –Commonly implemented in hardware  very fast

23 Depth-Buffer (Z-Buffer) Backface cullingZ-buffer algorithm

24 OPENGL Backface culling Using back face culling: –glEnable (GL_CULL_FACE); Selecting culling mode: –glCullFace (mode); –mode: GL_BACK, GL_FRONT, GL_FRONT_AND_BACK

25 OPENGL Depth Buffer Initialize (empty) depth buffer: –glClear (GL_DEPTH_BUFFER_BIT); Using depth buffer: –glEnable (GL_DEPTH_TEST); Not using depth buffer glDisable (GL_DEPTH_TEST);

26 Accumulation Buffer (A-Buffer) An extension of the depth-buffer for dealing with anti-aliasing, area-averaging, transparency, and translucency The depth-buffer method identifies only one visible surface at each pixel position –Cannot accumulate color values for more than one transparent and translucent surfaces Even more memory intensive Widely used for high quality rendering

27 Accumulation Buffer (A-Buffer) Each position in the A-buffer has two fields –Depth field: Stores a depth value –Surface data field RGB intensity components Opacity parameter (percent of transparency) Depth Percent of area coverage Surface identifier

28 Scan Line Method Intersect each polygon with a particular scanline and solve hidden surface problem for just that scan line –Requires a depth buffer equal to only one scan line –Requires the entire scene data at the time of scan conversion Maintain an active polygon and active edge list Can implement antialiasing as part of the algorithm

29 Depth Sorting Painter’s algorithm –Draw polygons as an oil painters might do Sort polygons by depth and draw them from back to front Depth sorting is NOT simple

30 Depth Sorting We need a partial ordering (not a total ordering) of polygons –The ordering indicates which polygon obscures which polygon –Some polygons may not obscure each other Simple cases

31 Depth Sorting We make the following tests for each polygon that has a depth overlap with S If any one of these tests is true, no reordering is necessary for S and the polygon being tested –Polygon S is completely behind the overlapping surface relative to the viewing position –The overlapping polygon is completely in front of S relative to the viewing position –The boundary-edge projections of the two polygons onto the view plane do not overlap

32 Depth Sorting Example

33 Depth Sorting Cyclically overlapping surfaces that alternately obscure one another We can divide the surfaces to eliminate the cyclic overlaps

34 BSP Trees Binary space partitioning is an efficient method for determining object visibility Paint surfaces into the frame buffer from back to front Particularly useful when the view reference point changes, but the objects are at fixed positions

35 BSP Tree Construction 1.Choose a polygon T and compute the equation of the plane it defines 2.Test all the vertices of all the other polygons to determine if they are in front of, behind, or in the same plane as T. 3.If the plane intersects a polygon, divide the polygon at the plane 4.Polygons are placed into a binary search three with T as the root 5.Call the procedure recursively on the left and right subtree

36 Traversing BSP Trees EYE 1 +X-X C B A D E1 +Z F2 E2 F1 EYE 2 A C F1D E2 F2 B E1

37 BSP Trees BST tree construction requires a number of polygons to be fractured It is possible for the number of triangles to increase exponentially but, in practice, it is found that the increase may be as small as two fold A heuristic to help minimize the number of fractures is to enter the polygons into the tree in order from largest to smallest

38 Area Subdivision Image-space method taking advantage of area coherence in a scene Recursively subdivide a square area into equal- sized quadrants if the area is too complex to analyze easily

39 Area Subdivision Four possible relationships between polygon surfaces and a rectangular section of the viewing plane Terminating criteria –Case 1: An area has no inside, overlapping, or surrounding surfaces (all surfaces are ourside the area) –Case 2: An area has only one inside, overlapping or surrounding surfaces –Case 3: An area has one surrounding surface that obscures all other surfaces within the area boundaries

40 Octrees Visible-surface identification is accomplished by searching octree nodes in a front-to-back order

41 Ray Casting We consider the line of sight from the a pixel position through the scene Useful for volume data Ray casting is a special case of ray tracing that we will study later

42 Ray Casting Examples

Download ppt "Chapter 7. Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s."

Similar presentations

Ads by Google