Computer Graphics - Visible Surface Detection
Computer Graphics - Visible Surface Detection
At (x,y): Ax+By+Cz+D=0
z=(-Ax-By-D)/C
xv Edge table:
• coordinate endpoints of each line
• inverse slope of each line
• pointers to surface table
Image space method Surface table:
• plane coefficients (A,B,C)
• surface material properties
• pointers to edge table
Scan-Line Method
Algorithm:
yv
fdepth(d) = (dmax-d)/(dmax-dmin)
glEnable (GL_FOG)
glFogi (GL_FOG_MODE, GL_LINEAR)
• generates fog effect. Uses depth cueing.
glEnable (GL_CULL_FACE)
glDisable (GL_CULL_FACE)
glCullFace (mode)
• used for backface removal
• GL_BACK (default), GL_FRONT (if inside a building),
GL_FRONT_AND_BACK
OpenGL
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
• initializes GLUT, requests a depth buffer and a frame buffer
glClear (GL_DEPTH_BUFFER_BIT)
• initially depth buffer has the background color. It must be cleared every time
before displaying a new frame.
glEnable (GL_DEPTH_TEST)
glDisable (GL_DEPTH_TEST)
• to activate depth buffer routines
glClearDepth (maxDept)
• to set maxDepth to another value (0.0 – 1.0)
glDepthRange (nearNormDept, farNormDept)
• to adjust normalization values (defaults: near- 0.0, far- 1.0)
OpenGL
glDepthFunction (testCondition)
• to specify a test condition for depth-buffer routines
• GL_LESS (default), GL_GREATER, GL_EQUAL,
GL_NOTEQUAL, GL_LEQUAL, GL_GEQUAL, GL_NEVER,
GL_ALWAYS
glDepthMask (writeStatus)
• to set the status of depth-buffer routines
• TRUE: read/write
• FALSE: read only