Hidden surface removal, shading and rendering notes — Unit 4
Free unit-wise study notes on hidden surface removal, shading and rendering for Computer Graphics and Multimedia, Semester 6 of B.Tech — Computer Science & Engineering — key concepts, examples, important questions and a revision checklist for semester exams.
Hidden surface removal, shading and rendering
Notebook — 14 pages
Page 1
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
1. Visible Surface Detection
When projecting 3D objects onto a 2D screen, we must determine which surfaces are visible and which are hidden by other surfaces. This is also known as Hidden Surface Removal.
⇒1.1 The Two Approaches
Object-Space Methods: Compare physical objects and parts of objects to each other within the 3D coordinate system to determine which surfaces are in front.
Image-Space Methods: Determine visibility point-by-point (pixel-by-pixel) across the 2D projection plane. These are generally much faster and are the standard in modern hardware.
Page 2
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
2. Back-Face Culling
A fast object-space method. A solid 3D object (like a cube) is composed of polygons. Roughly half of these polygons face away from the camera at any given time. We can instantly discard them without further processing.
⇒2.1 The Math
Every polygon has a 'Normal Vector' (a mathematical arrow pointing exactly perpendicular to its surface).
We calculate the dot product between the polygon's normal vector `N` and the camera's viewing vector `V`. If `V • N > 0`, the polygon is pointing away from the camera (a back-face) and is culled. If `< 0`, it is a front-face and must be processed.
Page 3
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
3. The Z-Buffer Algorithm
Also called the Depth-Buffer method. It is the most widely used image-space method for visible surface detection.
⇒3.1 Memory Requirements
It requires two massive arrays in the graphics hardware, both equal to the resolution of the screen:
Frame Buffer: Stores the final RGB color values for each pixel.
Z-Buffer (Depth Buffer): Stores the Z-coordinate (distance from the camera) for each pixel. Initialized to the maximum possible depth (infinity).
Page 4
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
4. Z-Buffer: The Process
The algorithm processes polygons one by one, pixel by pixel.
⇒4.1 The Comparison
When rasterizing a polygon, the hardware calculates the Z-depth for a specific pixel `(x,y)`. It compares this new depth to the depth currently stored in the Z-Buffer at `(x,y)`.
If the new depth is less (meaning the surface is closer to the camera), it overwrites the Z-Buffer with the new depth, and overwrites the Frame Buffer with the polygon's color.
If the new depth is greater (meaning the surface is behind whatever is already drawn there), it ignores the pixel.
Page 5
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
5. The Painter's Algorithm
Also known as the Depth-Sorting method. It mimics an oil painter painting a landscape: draw the distant sky first, then the mountains over it, then the trees over the mountains.
⇒5.1 The Logic
1. Sort all polygons in the scene by their Z-depth, from furthest away to closest.
2. Render the polygons to the screen in that exact order (back-to-front).
Closer polygons will naturally overwrite the pixels of polygons drawn behind them.
Page 6
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
6. Failures of the Painter's Algorithm
While conceptually simple, sorting polygons purely by depth fails in several edge cases.
⇒6.1 Cyclic Overlap
Imagine three long polygons arranged in a triangle. Polygon A overlaps B, B overlaps C, and C overlaps A. There is no mathematical 'furthest' polygon. The algorithm gets stuck in a loop.
⇒6.2 Intersecting Polygons
If two polygons pierce through each other, neither is strictly 'in front' or 'in back'. The Painter's Algorithm fails here. The only solution is to computationally slice the polygons into smaller pieces where the intersection occurs, which is very expensive.
Page 7
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
7. The Scan-Line Method
An extension of the polygon fill algorithm. Instead of filling one polygon, it processes all polygons simultaneously, scan-line by scan-line.
⇒7.1 Active Edge Table
As a horizontal line sweeps down the screen, the algorithm maintains a list of all polygon edges that intersect the current scan-line. Between intersections, it calculates the depth (Z) of each polygon that occupies that segment to determine which one is visible.
It exploits 'scan-line coherence': the visible surface from one pixel to the next on the same scan-line rarely changes, saving massive amounts of computation.
Page 8
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
8. Illumination Models
Once we know a pixel is visible, we must determine its color. An illumination model (or lighting model) calculates the intensity of light reflected at a given point on a surface.
⇒8.1 The Standard Model
Real-world light physics (like ray tracing) is too slow for real-time graphics. We use an empirical model that approximates light using three components: Ambient, Diffuse, and Specular.
Page 9
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
9. Ambient and Diffuse Reflection
⇒9.1 Ambient Light
In the real world, light bounces off walls and fills a room, so shadows are rarely pitch black. Ambient light is a constant, uniform base level of illumination applied to all objects equally to simulate this scattered background light.
⇒9.2 Diffuse Reflection
Simulates dull, matte surfaces (like chalk or rough plastic). Light hits the surface and scatters equally in all directions. The brightness of a point depends purely on the angle between the light source and the surface normal (Lambert's Cosine Law), NOT the camera angle.
Page 10
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
10. Specular Reflection
Simulates the bright, focused highlight you see on shiny surfaces (like polished metal, glass, or an apple).
⇒10.1 The Phong Model
Unlike diffuse light, specular light does not scatter equally. It bounces off mostly in a single reflection angle (like a mirror).
The brightness of the specular highlight depends entirely on the camera angle. If the viewer's eye is aligned exactly with the reflection vector, the highlight is intensely bright. If the viewer moves slightly, the highlight vanishes.
Page 11
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
11. Polygon Shading
Most 3D objects are modeled as meshes composed of thousands of flat triangles (polygons). How do we apply our illumination equations to these flat surfaces?
⇒11.1 Flat Shading (Constant Shading)
The illumination equation is calculated exactly once for the entire polygon (using the center point). The entire triangle is filled with that single, uniform color.
It is incredibly fast, but the object looks faceted and blocky, like a disco ball. The human eye easily detects the hard edges between triangles (Mach Band effect).
Page 12
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
12. Gouraud Shading
Also known as Intensity Interpolation shading. Developed by Henri Gouraud, it smooths out the blocky edges of flat shading.
⇒12.1 The Method
1. Calculate the vertex normal (the average of the normals of all polygons sharing that vertex).
2. Calculate the illumination equation at the three vertices.
3. Smoothly interpolate (blend) the calculated colors across the surface of the polygon during rasterization.
It creates smooth objects efficiently, but it completely misses specular highlights that fall in the center of a triangle, as it only calculates lighting at the corners.
Page 13
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
13. Phong Shading
Also known as Normal-Vector Interpolation shading. Developed by Bui Tuong Phong, it is the standard for high-quality real-time rendering.
⇒13.1 The Method
Instead of interpolating the color across the triangle, Phong shading interpolates the surface normals across the triangle. The full illumination equation is then calculated independently for every single pixel.
This results in perfectly smooth specular highlights, regardless of the size of the underlying triangles. However, calculating lighting per-pixel is computationally intensive.
Page 14
Wink Notes
B.Tech CSE — 6th Semester
Computer Graphics and Multimedia
— Unit - 4 —
14. Introduction to Ray Tracing
While rasterization (Z-Buffer, Shaders) is the standard for fast, real-time graphics, Ray Tracing is the standard for photorealistic rendering (movies).
⇒14.1 The Concept
Instead of projecting objects onto a screen, Ray Tracing simulates physics backwards. It shoots a mathematical 'ray' of light from the camera (your eye), through a pixel on the screen, out into the 3D world.
When the ray hits an object, it calculates the color. Crucially, the ray then bounces off the object, generating reflection and refraction rays that bounce around the scene, perfectly simulating mirrors, glass, and highly accurate shadows.