Unit 4 of 4 · M.Sc IT Sem 3

Unit 4: 3D graphics and rendering

Computer Graphics notes · PTU syllabus (PGCA1919)

3 min read8 topics10 exam questions
On this page
  1. Unit summary
  2. 3D transformations
  3. Viewing pipeline and coordinates
  4. Parallel and perspective projections
  5. Perspective projection mathematics
  6. Visible-surface determination
  7. Illumination models: ambient, diffuse and specular reflection
  8. Shading models: flat, Gouraud and Phong
  9. Ray tracing
  10. Key terms
  11. Quick revision
  12. Important questions

Unit summary

Realistic 3D images need transformations, projections, hidden-surface removal and lighting. This unit covers 3D transformations, the viewing pipeline and coordinates, parallel and perspective projections, visible-surface determination — back-face removal, z-buffer, scan-line, painter's and area subdivision methods — illumination and shading models, ray tracing, ambient, diffuse and specular reflection, Phong's model and Gouraud shading.

After this unit you can

  • Apply 3D transformations and projections
  • Explain the 3D viewing pipeline
  • Compare visible-surface determination methods
  • Explain illumination models and shading methods

PTU syllabus topics

  • 3D transformations
  • viewing pipeline and coordinates
  • parallel and perspective projections
  • visible-surface determination (back-face removal, z-buffer, scan-line, painter's algorithm, area subdivision)
  • illumination and shading models
  • ray tracing
  • ambient/specular/diffuse reflection
  • Phong's model
  • Gouraud shading
ComparisonVisible-surface algorithms
How
Trade-off

Back-face removal

Drop faces pointing away

Fast; convex objects only

Z-buffer

Keep nearest depth per pixel

Simple; needs depth memory

Painter's algorithm

Draw far to near

Fails on cyclic overlaps

Ray tracing

Trace rays from the eye

Realistic but slow

1

Topic 1

3D transformations

Key formulas3D transformations
  • Translation

    x′ = x + tx, y′ = y + ty, z′ = z + tz

  • Scaling

    x′ = sx·x, y′ = sy·y, z′ = sz·z

  • Rotation about the z-axis

    x′ = x cos θ − y sin θ; y′ = x sin θ + y cos θ; z′ = z

  • Rotation about the x-axis

    y′ = y cos θ − z sin θ; z′ = y sin θ + z cos θ; x′ = x

  • Rotation about the y-axis

    z′ = z cos θ − x sin θ; x′ = z sin θ + x cos θ; y′ = y

ProcessRotation about an arbitrary axis
  1. 1

    Translate the axis to pass through the origin

  2. 2

    Rotate about x so the axis lies in the xz-plane

  3. 3

    Rotate about y so the axis coincides with z

  4. 4

    Rotate by θ about z

  5. 5

    Apply the inverse rotations

  6. 6

    Apply the inverse translation

  • Reflection in 3D is about a plane (e.g., xy-plane: z′ = −z); shear shifts coordinates in proportion to another coordinate.
2

Topic 2

Viewing pipeline and coordinates

Process3D viewing pipeline
  1. 1Modelling transformation

    Object to world coordinates

  2. 2Viewing transformation

    World to camera (viewing) coordinates using view reference point, view-plane normal and view-up vector

  3. 3Projection transformation

    Parallel or perspective to projection coordinates

  4. 4Normalisation and clipping

    To a canonical view volume

  5. 5Viewport transformation

    To device coordinates for display

3

Topic 3

Parallel and perspective projections

  • Projection maps 3D points onto a 2D projection plane along projectors from a centre of projection.
ClassificationTypes of projection
Projections
  • Parallel

    Projectors parallel; centre at infinity

  • Orthographic

    Projectors perpendicular to the plane — front, top, side views; axonometric (isometric)

  • Oblique

    Projectors at an angle — cavalier, cabinet

  • Perspective

    Projectors meet at a centre; one-, two- and three-point perspective

4

Topic 4

Perspective projection mathematics

  • With the centre of projection at the origin and the projection plane at z = d:
Key formulasPerspective projection
  • Projected x

    xp = x·d ÷ z

  • Projected y

    yp = y·d ÷ z

  • Homogeneous form

    (x, y, z, z ÷ d) then divide by the fourth coordinate

Example

d = 2: point (4, 6, 8) projects to (4 × 2 ÷ 8, 6 × 2 ÷ 8) = (1, 1.5); the farther point (4, 6, 16) projects to (0.5, 0.75) — distant objects look smaller.

  • Properties: foreshortening (size decreases with distance), vanishing points where parallel lines appear to meet; realistic but does not preserve true measurements.
ComparisonParallel and perspective projection
Parallel
Perspective

Centre of projection

At infinity

At a finite point

Size with distance

Unchanged

Decreases

Parallel lines

Remain parallel

Converge at vanishing points

Use

Engineering drawings, CAD

Games, architecture renderings, films

5

Topic 5

Visible-surface determination

  • Hidden surfaces must be removed so that only surfaces facing and nearest to the viewer are drawn. Methods work in object space (compare objects) or image space (decide per pixel).
ComparisonVisible-surface methods
How it works
Notes

Back-face removal

Discard polygons whose normal points away from the viewer (N · V > 0 in a right-handed view looking along −z)

Object space; removes about half of polygons; enough only for single convex objects

Z-buffer (depth buffer)

For each pixel keep the nearest depth; draw a polygon's pixel only if it is nearer than the stored depth

Image space; simple and hardware-supported; needs a depth buffer

Scan-line method

Process one scan line at a time with active edge and polygon lists; determine the nearest surface along spans

Image space; uses coherence

Painter's (depth-sort) algorithm

Sort polygons by depth and paint from farthest to nearest

Object and image space; cyclic overlaps need splitting

Area subdivision (Warnock)

Subdivide the screen until each area is simple — empty, one polygon, or one polygon in front

Image space; recursive

ProcessZ-buffer algorithm
  1. 1Initialise depth buffer to the farthest value and frame buffer to the background
  2. 2For each polygon and each pixel it covers, compute depth z
  3. 3If z is nearer than depth[x][y], store z and the polygon's colour
  4. 4After all polygons, the frame buffer holds the visible image
6

Topic 6

Illumination models: ambient, diffuse and specular reflection

Key formulasPhong illumination model
  • Ambient

    Ia = ka × Iamb — uniform background light

  • Diffuse (Lambertian)

    Id = kd × Il × (N · L) — depends on the angle between surface normal and light

  • Specular

    Is = ks × Il × (R · V)ⁿ — shiny highlights; larger n gives smaller, sharper highlights

  • Total intensity

    I = Ia + Id + Is (summed over lights), optionally attenuated with distance

  • ka, kd, ks are the material's ambient, diffuse and specular coefficients (0–1); N is the unit normal, L the direction to the light, R the reflection direction and V the direction to the viewer. This combined formula is Phong's illumination (reflection) model.
7

Topic 7

Shading models: flat, Gouraud and Phong

ComparisonShading methods
How it works
Quality

Flat (constant) shading

One intensity per polygon

Fast; faceted look

Gouraud shading

Compute intensity at vertices (using averaged normals) and interpolate intensities across the polygon

Smooth; may miss or smear specular highlights; Mach bands

Phong shading

Interpolate normals across the polygon and apply the illumination model at each pixel

Realistic highlights; more computation

8

Topic 8

Ray tracing

ProcessRay tracing
  1. 1For each pixel, cast a ray from the eye through the pixel
  2. 2Find the nearest object the ray hits
  3. 3Compute local illumination; send shadow rays to lights
  4. 4Spawn reflected and refracted rays recursively
  5. 5Combine contributions for the pixel colour
  • Produces shadows, reflections and transparency naturally; computationally expensive, but real-time ray tracing is now supported by modern GPUs.

Key terms

Z-buffer
Per-pixel depth memory for hidden-surface removal
Back-face
Polygon facing away from the viewer
Diffuse reflection
Light scattered equally in all directions
Specular reflection
Mirror-like highlight depending on viewing angle
Gouraud shading
Interpolating vertex intensities across a polygon

Quick revision

  • 3D translation, scaling, rotation; viewing pipeline; parallel and perspective projections.
  • Object-space vs image-space methods.
  • Back-face, z-buffer, scan-line, painter's, area subdivision.
  • Ambient, diffuse, specular; Phong illumination model.
  • Flat, Gouraud, Phong shading; ray tracing.

Important exam questions

Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).

Short-answer questions

  1. Q1.What is back-face removal?
  2. Q2.How does the z-buffer algorithm decide visibility?
  3. Q3.What is the painter's algorithm?
  4. Q4.Write the diffuse reflection equation.
  5. Q5.Distinguish Gouraud and Phong shading.
  6. Q6.What does ray tracing compute well?

Long-answer questions

  1. Q1.Explain 3D transformations and the viewing pipeline.
  2. Q2.Explain parallel and perspective projections.
  3. Q3.Compare visible-surface determination methods.
  4. Q4.Explain illumination models and shading methods.

Stuck on this unit?

Message SBS on WhatsApp for help with Computer Graphics, or to ask about studying M.Sc IT at Synetic.

WhatsApp us