Depth



     





Depth Cues

"Hints" that suggest three-dimensionality - shape or distance

Based on physics, and workings of human vision






Summary






Occlusion / Interposition


Limbourg. Tres Riches Heures: January. 1412-16





Occlusion / Interposition


Hiroshige. Plum Estate, Kameido. 1857





Occlusion / Interposition


Diablo





Perspective






Linear Perspective


van Gogh. Corridor in the Asylum. 1889





Linear Perspective


Dali. The First Days of Spring 1932





Linear Perspective


Tempest





Relative Size


Durer. The Adoration of the Magi. 1504





Relative Size


Monet. Wheatstacks (End of Summer), 1890-91





Relative Size


Wolfenstein 3D





Relative Height


Limbourg. Tres Riches Heures: February. 1412-16





Relative Height


Constable. Chain Pier, Brighton. 1827





Relative Height


Marble Madness





Texture Gradient


Botticelli. The Birth of Venus. c. 1485-86





Texture Gradient


Hockney. A Lawn Being Sprinkled. 1967





Texture Gradient


Hockney. A Lawn Being Sprinkled (detail)





Texture Gradient






Lighting & Shadows


Michelangelo. David. 1504





Lighting & Shadows


Michelangelo. The Holy Family with the infant St. John the Baptist (the Doni Tondo). c. 1503-05





Lighting & Shadows


Monet. Rouen Cathedral, the West Portal and Saint-Romain Tower, Full Sunlight, Harmony in Blue and Gold) / Rouen Cathedral: Full Sunlight. 1894





Lighting & Shadows

    
Mario 64      /      Doom 3





Aerial Perspective


Friedrich. Riesengebirge. 1835





Aerial Perspective


Monet. The Thames at Westminster (Westminster Bridge). 1871





Aerial Perspective


Grand Theft Auto 3





Accomodation (Focus)


Vermeer. The Lacemaker. 1669-70





Accomodation (Focus)


Wyler. The Little Foxes. 1941





Accomodation (Focus)






Motion Parallax


Disner. The Old Mill. 1937





Motion Parallax


Shadow of the Beast





Stereo Parallax






Stereo Parallax






Stereo Parallax


Virtual Boy - Mario's Tennis





OpenGL

occlusion
depth-buffering (glEnable(GL_DEPTH_TEST))

linear perspective
relative size
relative height
perspective projection (gluPerspective)

texture gradient
perspective, texture mapping (glTexImage2D, etc)

shading, shadows
lighting (glLight, glMaterial, glNormal)

aerial perspective
fog (glFog)

accomodation
accumulation buffer (glAccum)

stereo parallax
quad-buffering, color-masking

motion parallax
transformations





Hidden Surfaces

Hidden surfaces provide occlusion depth cue






Hidden Surface Algorithms

Many different algorithms developed over the years






Ray Tracing






Depth Buffering

Rendering a polygon means filling pixels

Color buffer contains RGB color of each pixel drawn

Depth buffer contains depth of each pixel drawn

ColorDepth





Depth Buffer






Depth Buffer

When drawing a new pixel, compare new depth to what's stored in depth buffer

ColorDepth

Polygons can be drawn in any order
Polygons can intersect






OpenGL Depth Buffering

Space must be allocated for the depth buffer:

glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH)

Depth buffering must be enabled:

glEnable(GL_DEPTH_TEST)

Depth buffer must be cleared each frame:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)





Depth Fighting

Depth values have limited resolution

i.e. the numbers are not infinitely precise

Rounding errors occur when polygons are filled

Polygon overlap can cause "depth-fighting"






Perspective Projection

Perspective effects are created by a perspective projection transformation


Perspective + movement also yields motion parallax






Orthographic Projection

Orthographic projection : projects rectilinear box onto display
Objects will not appear to change size with distance






Perspective Projection

Perspective projection : projects frustum (truncated pyramid) onto disp lay
Near objects appear larger, distant objects appear smaller






Perspective Projection

GL's perspective projection is, conceptually, a pin-hole camera, located at origin, looking down -Z axis


Camera has a field-of-view - angle representing (horizontal) extent of region viewed

Small angle = narrow field-of-view = telephoto lens
Large angle = wide field-of-view = wide-angle lens






OpenGL Perspective

    gluPerspective( fovy, aspect, zNear, zFar )

fovy = field of view, in Y direction, in degrees

aspect = aspect ratio (X:Y) of window

zNear = distance to near clipping plane

zFar = distance to far clipping plane

The "eye-point" of the perspective projection is at (0,0,0)


Example:

    gluPerspective(45, 1.333, 0.1, 100)


Creative Commons License
This document is by Dave Pape, and is released under a Creative Commons License.