Presentation is loading. Please wait.

Presentation is loading. Please wait.

Learning Objectives Classification of Visible Surface Detection Algorithms Classification of Visible Surface Detection Algorithms Back-Face Detection Back-Face.

Similar presentations


Presentation on theme: "Learning Objectives Classification of Visible Surface Detection Algorithms Classification of Visible Surface Detection Algorithms Back-Face Detection Back-Face."— Presentation transcript:

1 Learning Objectives Classification of Visible Surface Detection Algorithms Classification of Visible Surface Detection Algorithms Back-Face Detection Back-Face Detection Depth-Buffer Method Depth-Buffer Method Scan-Line Method Scan-Line Method Depth-Sorting Method Depth-Sorting Method Wire-Frame Visibility Methods Wire-Frame Visibility Methods OpenGL Visibility Detection Functions OpenGL Visibility Detection Functions

2 Visible Surface Detection A major consideration in the generatation of realistic graphics is determining what is visible within a scene from a chosen viewing position A major consideration in the generatation of realistic graphics is determining what is visible within a scene from a chosen viewing position Algorithms to detect visible objects are referred to as visible-surface detection methods Algorithms to detect visible objects are referred to as visible-surface detection methods

3 Classification of Visible Surface Detection Algorithms Object-space methods Object-space methods Compares objects and parts of object to each other within the scene definition to determine which surfaces should be marked as visible Compares objects and parts of object to each other within the scene definition to determine which surfaces should be marked as visible Image-space methods Image-space methods Visibility is decided point by point at each pixel position Visibility is decided point by point at each pixel position

4 Back-Face Detection A fast and simple object-space method for locating back faces A fast and simple object-space method for locating back faces A point (x,y,z) is “inside” a polygon surface with plane parameters A, B, C, D if : A point (x,y,z) is “inside” a polygon surface with plane parameters A, B, C, D if : Ax + By + Cz + D < 0 When an inside point is along the line of sight to the surface, the polygon must be a back face and so cannot be seen When an inside point is along the line of sight to the surface, the polygon must be a back face and so cannot be seen

5 Back-Face Detection The test is simplified by considering the normal vector N to the polygon and the viewing vector V The test is simplified by considering the normal vector N to the polygon and the viewing vector V This is back face if This is back face if V · N > 0

6 Depth Buffer Method A commonly used image-space approach A commonly used image-space approach Each surface is processed separately, one point at a time Each surface is processed separately, one point at a time Also called the z-buffer method Also called the z-buffer method It is generally hardware implemented It is generally hardware implemented

7 Depth Buffer Method 3 surfaces overlap at (x,y). S 1 has the smallest depth value 3 surfaces overlap at (x,y). S 1 has the smallest depth value

8 Depth Buffer Method Two buffers are needed Two buffers are needed Depth buffer (distance information) Depth buffer (distance information) Frame buffer (intensity/color information) Frame buffer (intensity/color information)

9 Depth Buffer Method Depth-Buffer Algorithm Depth-Buffer Algorithm for all (x,y) depthBuff(x,y) = 1.0, frameBuff(x,y)=backgndcolor for each polygon P for each position (x,y) on polygon P calculate depth z if z < depthBuff(x,y) then depthBuff(x,y) =z frameBuff(x,y)=surfColor(x,y) frameBuff(x,y)=surfColor(x,y)

10 Scan-Line Method Image space method Image space method Extension of scan-line algorithm for polygon filling Extension of scan-line algorithm for polygon filling As each scan line is processed, all polygon surface projections intersecting that line are examined to determine which are visible As each scan line is processed, all polygon surface projections intersecting that line are examined to determine which are visible

11 Scan-Line Method Example Example

12 Depth-Sorting Method Both image-space and object-space operations Both image-space and object-space operations Also called painter’s algorithm Also called painter’s algorithm Surfaces sorted in order of increasing depth Surfaces sorted in order of increasing depth Surfaces scan-converted in order, starting with the surface of greatest depth Surfaces scan-converted in order, starting with the surface of greatest depth B behind A as seen by viewer Fill B then A

13 Display all object edges – difficult to determine front and back Display all object edges – difficult to determine front and back Depth cueing – displayed intensity of a line is a function of its distance from the viewer Depth cueing – displayed intensity of a line is a function of its distance from the viewer Wire-Frame Visibility Methods

14 Detect hidden lines and display them differently Detect hidden lines and display them differently

15 Wire-Frame Surface-Visibility Compare edge positions with surface positions Compare edge positions with surface positions Similar to line clipping, but we need to compare depths as well Similar to line clipping, but we need to compare depths as well

16 Wire-Frame Depth Cueing Vary the brightness of objects in a scene as a function of distance from the viewing position Vary the brightness of objects in a scene as a function of distance from the viewing position Multiply each pixel color by: Where d is the distance of a point from the viewing position

17 OpenGL Visibility Detection Functions Back-face removal: Back-face removal: glEnable(GL_CULL_FACE); glCullFace(mode); GL_BACK, GL_FRONT, GL_FRONT_AND_BACK glDisable(GL_CULL_FACE); default GL_BACK is default. Sometimes we want to see the back faces, for example if we are in a room we can use GL_FRONT GL_BACK is default. Sometimes we want to see the back faces, for example if we are in a room we can use GL_FRONT

18 OpenGL Visibility Detection Functions Depth-buffer functions: Request depth buffer when initializing: Request depth buffer when initializing:glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH); Clear depth buffer each time a new frame is displayed: Clear depth buffer each time a new frame is displayed: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); OpenGL depth-buffer visibility-detection routines can be activated with OpenGL depth-buffer visibility-detection routines can be activated with glEnable(GL_DEPTH_TEST); and deactivated with and deactivated with glDisable(GL_DEPTH_TEST);

19 OpenGL Visibility Detection Functions Wire-frame surface visibility: Wire-frame surface visibility: glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

20 OpenGL Visibility Detection Functions Depth cueing: Depth cueing:glEnable(GL_FOG); glFogi(GL_FOG_MODE, GL_LINEAR); This applies the linear depth function to object colors using d min =0.0 and d max =1.0. We can set different values for d min and d max with the following function calls This applies the linear depth function to object colors using d min =0.0 and d max =1.0. We can set different values for d min and d max with the following function calls glFogf(GL_FOG_START, minDepth); glFogf(GL_FOG_END, maxDepth);


Download ppt "Learning Objectives Classification of Visible Surface Detection Algorithms Classification of Visible Surface Detection Algorithms Back-Face Detection Back-Face."

Similar presentations


Ads by Google