8 Visible Surface Detection

Computer Graphics · Unit 8

Visible Surface Detection

Exam-focused notes for Visible Surface Detection (Computer Graphics, BIT304): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.

Visible Surface Detection in short

When many surfaces overlap on the screen, only the nearest one should be seen. Visible surface detection (hidden surface removal) decides which parts of which surfaces are visible from the viewpoint.

Visible Surface Detection: notes

Z-buffer method and limitations

The Z-buffer (depth buffer) method is an image-space method. It uses two buffers of the screen size:

  • Frame (refresh) buffer: stores the colour of each pixel.
  • Depth (Z) buffer: stores the depth $z$ of the nearest surface found so far at each pixel.

Algorithm:

  • Set every depth value to the far limit (for example 1.0) and every colour to the background.
  • For each polygon, for each pixel $(x,y)$ it covers, calculate the depth $z$.
  • If $z$ is nearer than the stored depth, store the new depth and write the polygon colour to the frame buffer.
  • Otherwise leave the pixel as it is.

Depth along a scan line. For a plane $Ax + By + Cz + D = 0$, $z = (-D - Ax - By)/C$. When $x$ moves by 1 to the next pixel on the same row:

$$z' = z - \frac{A}{C}$$

So only one subtraction is needed per pixel. Example: with $A = 2$ and $C = 4$, the step is $-0.5$. Starting at $z = 10$ at one pixel, the next pixels have $z = 9.5$ and $z = 9.0$.

Small example: a pixel has stored depth $0.8$ (far wall). A red polygon at this pixel has depth $0.6$. Since $0.6 < 0.8$ the pixel becomes red and depth $0.6$. A blue polygon with depth $0.9$ comes next. It is behind, so no change.

Advantages:

  • Simple and easy to put into hardware.
  • Polygons can be drawn in any order.
  • Works for any surface for which depth can be found.

Limitations:

  • Needs extra memory for the depth buffer, in addition to the frame buffer.
  • Cannot handle transparent surfaces well, because only one depth per pixel is kept.
  • Limited depth precision can cause surfaces that are very close to flicker (z-fighting).
  • Wastes time computing hidden pixels that are overwritten later.
  • Aliasing at edges, since each pixel holds only one surface.

What this unit covers

  • Z-buffer method and limitations
  • Scan-line method for visible surface detection
  • Object space techniques
  • Image space techniques
  • Line method for visible surface detection
  • Area subdivision method

Object space techniques

2082 · 5 marks

What are object space techniques in visible surface detection? Explain how these techniques are used in 3D graphics. [5]

Show solved answer

Object Space Techniques in Visible Surface Detection

Definition

Object space techniques are methods for determining which surfaces are visible in a 3D scene by performing visibility calculations in the original coordinate system of the 3D objects (object space), before projection to the screen.

Key Characteristics

Object space techniques work directly with 3D geometric data and determine visibility relationships between objects and surfaces in their native 3D coordinates.

Main Object Space Techniques

1. Depth Sorting (Painter's Algorithm)

  • Sorts all surfaces by their depth (distance from viewer)
  • Renders surfaces from back to front
  • Surfaces rendered last appear on top
  • Simple but can fail with intersecting or cyclic depth relationships

2. Binary Space Partition (BSP) Trees

  • Recursively divides 3D space using planes
  • Organizes surfaces into a tree structure
  • Allows efficient visibility determination by traversing the tree from viewer's position
  • Particularly useful for static scenes

3. Back-Face Culling

  • Eliminates surfaces facing away from the viewer
  • Uses surface normal vectors to determine orientation
  • Reduces number of surfaces requiring visibility testing
  • Efficient preprocessing step

Application in 3D Graphics

Advantages:

  • Works with exact geometric data before rasterization
  • Can handle complex spatial relationships precisely
  • Useful for scenes with many overlapping objects
  • Enables efficient culling of invisible geometry

Disadvantages:

  • Computationally expensive for large scenes
  • Difficult to handle intersecting surfaces
  • Less efficient than image space methods for complex scenes

Usage: Object space techniques are commonly used in game engines and CAD systems for preprocessing and organizing scene geometry before rendering.

Open this answer on its own page →

Scan-line method for visible surface detection

2082 · 5 marks

Describe the Scan-Line method for visible surface detection. Write its advantages and limitations. [5]

The Scan-Line method is an image-space algorithm that determines visible surfaces by processing the scene one horizontal line (scan line) at a time across the viewport. Working Principle: 1. Scan Line Processing: The image plane is divided into horizontal scan lines. For each scan line, the algor...

Open this answer on its own page →

Area subdivision method

2082 · 5 marks

Write short notes on: a) Area subdivision method Write short notes on: b) OpenGL viewing [2.5+2.5]

Show solved answer

Model Answer: Area Subdivision Method & OpenGL Viewing

a) Area Subdivision Method (2.5 marks)

Definition: Area subdivision method is a visible surface determination algorithm that recursively subdivides the projection plane (viewing area) into smaller rectangular regions until each region contains a simple case that can be easily resolved.

Basic Principle:

  • Divide the display area into quadrants
  • For each quadrant, test whether it is simple (can be easily classified)
  • If not simple, subdivide further recursively
  • Continue until all regions are resolved

Algorithm Steps:

  1. Start with the entire viewing area
  2. Classify the area based on object relationships:
    • Trivial Accept: All surfaces are in front (visible)
    • Trivial Reject: All surfaces are behind (invisible)
    • Ambiguous: Surfaces overlap - requires subdivision
  3. If ambiguous, divide into 4 equal quadrants
  4. Recursively apply the same process to each quadrant
  5. Stop when reaching pixel level or trivial case

Advantages:

  • Efficient for complex scenes with many overlapping surfaces
  • Naturally handles antialiasing
  • Works well with hierarchical data structures

Disadvantages:

  • Can be computationally expensive for simple scenes
  • Requires careful implementation of classification tests

b) OpenGL Viewing (2.5 marks)

Definition: OpenGL viewing defines how 3D scene objects are transformed and projected onto a 2D display surface through a series of coordinate transformations.

Viewing Pipeline (Transformation Sequence):

  1. Model Transformation: Positions objects in world coordinates
  2. View Transformation: Positions camera/viewer in the scene
  3. Projection Transformation: Defines viewing volume (perspective or orthographic)
  4. Viewport Transformation: Maps to screen coordinates

Key Components:

ComponentPurpose
Camera PositionEye/viewpoint location in world space
Look-at PointTarget point the camera views
Up VectorDefines camera orientation
Projection TypeOrthographic (parallel) or Perspective
Clipping PlanesNear and far planes defining visible depth range

Common OpenGL Functions:

  • gluLookAt(): Sets camera position, target, and up vector
  • glOrtho(): Defines orthographic projection
  • glPerspective(): Defines perspective projection
  • glViewport(): Sets viewport dimensions

Viewing Volume:

  • Orthographic: Rectangular box (parallel projection)
  • Perspective: Frustum/pyramid shape (converges to eye point)
Open this answer on its own page →

Z-buffer method and limitations

2081

Z-Buffer Method for Visible Surface Detection

The Z-Buffer (Depth Buffer) method is an image-space visible surface detection algorithm that determines which surface is closest to the viewer at each pixel position on the projection plane. It maintains two buffers: - Frame Buffer: stores color/intensity values for each pixel - Depth Buffer (Z-...

Open this answer on its own page →

2080 · 5 marks

Write short notes a. Z-Buffer b. Polygon Table [5]

Definition: Z-Buffer (also called Depth Buffer) is a hidden surface removal technique that stores the depth (z-coordinate) value of each pixel on the screen. Working Principle: - Maintains a 2D array of depth values corresponding to each pixel in the frame buffer - For each pixel, stores the z-co...

Open this answer on its own page →

Line method for visible surface detection

2079 · 5 marks

Explain how can line method detects the visible surface with example. [5]

The line method (also called the scan-line algorithm) is a visible surface detection technique that processes the scene line by line (usually horizontally across the screen) to determine which surfaces are visible at each pixel position. 1. Scan horizontally across the screen, one line (row of pi...

Open this answer on its own page →