Unit 4: 3D graphics and rendering
Computer Graphics notes · PTU syllabus (PGCA1919)
On this page
- Unit summary
- 3D transformations
- Viewing pipeline and coordinates
- Parallel and perspective projections
- Perspective projection mathematics
- Visible-surface determination
- Illumination models: ambient, diffuse and specular reflection
- Shading models: flat, Gouraud and Phong
- Ray tracing
- Key terms
- Quick revision
- 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
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
Topic 1
3D 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
- 1
Translate the axis to pass through the origin
- 2
Rotate about x so the axis lies in the xz-plane
- 3
Rotate about y so the axis coincides with z
- 4
Rotate by θ about z
- 5
Apply the inverse rotations
- 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.
Topic 2
Viewing pipeline and coordinates
- 1Modelling transformation
Object to world coordinates
- 2Viewing transformation
World to camera (viewing) coordinates using view reference point, view-plane normal and view-up vector
- 3Projection transformation
Parallel or perspective to projection coordinates
- 4Normalisation and clipping
To a canonical view volume
- 5Viewport transformation
To device coordinates for display
Topic 3
Parallel and perspective projections
- Projection maps 3D points onto a 2D projection plane along projectors from a centre of projection.
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
Topic 4
Perspective projection mathematics
- With the centre of projection at the origin and the projection plane at z = d:
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.
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
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).
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
- 1Initialise depth buffer to the farthest value and frame buffer to the background
- 2For each polygon and each pixel it covers, compute depth z
- 3If z is nearer than depth[x][y], store z and the polygon's colour
- 4After all polygons, the frame buffer holds the visible image
Topic 6
Illumination models: ambient, diffuse and specular reflection
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.
Topic 7
Shading models: flat, Gouraud and Phong
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
Topic 8
Ray tracing
- 1For each pixel, cast a ray from the eye through the pixel
- 2Find the nearest object the ray hits
- 3Compute local illumination; send shadow rays to lights
- 4Spawn reflected and refracted rays recursively
- 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
- Q1.What is back-face removal?
- Q2.How does the z-buffer algorithm decide visibility?
- Q3.What is the painter's algorithm?
- Q4.Write the diffuse reflection equation.
- Q5.Distinguish Gouraud and Phong shading.
- Q6.What does ray tracing compute well?
Long-answer questions
- Q1.Explain 3D transformations and the viewing pipeline.
- Q2.Explain parallel and perspective projections.
- Q3.Compare visible-surface determination methods.
- 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.
