Computer Graphics Core Concepts: Display, Rendering, Algorithms
Display Technologies: Beam Penetration vs. Shadow Mask
Beam Penetration | Shadow Mask |
---|---|
Used in older color CRTs. | Used in modern color CRTs/LCDs. |
Two layers of phosphor (red & green); beam depth controls color. | Three separate phosphors (R, G, B) and a mask to direct beams. |
Limited color range (4–7 colors). | Millions of colors possible. |
Cheaper. | Higher cost. |
Lower image quality. | High image quality. |
Graphics Rendering: Raster Scan vs. Vector Scan
Raster Scan | Vector Scan |
---|---|
Displays image as a matrix of pixels. | Draws image directly as a set of lines. |
Refreshes entire screen sequentially. | Refreshes only the lines needed. |
Used in TVs, modern monitors. | Used in oscilloscopes, plotters. |
Produces jagged edges for curves. | Produces smooth lines. |
Requires frame buffer. | Requires display list (vector memory). |
Object Space vs. Image Space in Computer Graphics
Aspect | Object Space | Image Space |
---|---|---|
Working Domain | 3D coordinates (world/view space) | 2D coordinates (screen space) |
Data Type | Vertices, edges, polygons | Pixels/fragments |
Visibility Tests | Per object/polygon | Per pixel |
Example Algorithm | Back-face removal, bounding volume tests | Z-buffer, scan-line |
Speed | Often faster for culling large objects | Slower if many unnecessary pixels |
Accuracy | High for geometry | High for final pixel colors |
Computer Graphics Fundamentals
What is a Computer?
A computer is an electronic device that accepts data as input, processes it according to instructions, and produces output.
Advantages of Computer Graphics
- Visual representation of data.
- Easy understanding of complex concepts.
- Interactive communication.
- Realistic image generation.
Application Areas of Computer Graphics
- CAD (Computer-Aided Design)
- Animation & Gaming
- Scientific Visualization
- Virtual Reality & Simulation
- Education & Training
Z-Buffer Algorithm
The Z-Buffer algorithm is a common technique for hidden surface removal in 3D computer graphics.
Step 1: Initialize
- Depth buffer: Set all values to
Zmax
(farthest possible depth). - Frame buffer: Set all pixels to background color.
Step 2: Process Each Polygon
For each polygon in the scene:
- Project it onto the screen.
- For each pixel inside the polygon:
- Calculate the polygon’s depth (Z) at that pixel.
- Compare it with the depth buffer value at that pixel.
- If closer:
- Update the depth buffer with the new Z.
- Update the frame buffer with the polygon’s color.
Step 3: Final Image
The frame buffer now contains the final visible image.
The Painter’s Algorithm
The Painter’s Algorithm is a simple hidden surface removal algorithm that renders polygons from back to front.
Step 1: Sort Polygons
Sort polygons based on their depth (e.g., average Z or farthest vertex Z).
Step 2: Render Polygons
For each polygon in sorted order:
- Project to the 2D screen.
- Fill the pixels in the frame buffer (overwriting previous colors if needed).
Step 3: Complete Image
The visible image is complete.
Scan-Line Algorithm
The Scan-Line algorithm is used for rendering polygons by processing them scan line by scan line.
Step 1: Sort Edges
Sort all polygon edges by their Y-coordinates.
Step 2: Process Each Scan Line
For each scan line (horizontal row of pixels):
- Find all polygon edges intersecting this scan line (Active Edge Table – AET).
- Determine intersection points with the scan line.
- Sort intersection points by X-coordinate.
- Fill the pixels between pairs of intersections with the polygon’s color.
- Update edges in the Active Edge Table for the next scan line.
Step 3: Repeat
Repeat until all scan lines are processed.
Back-Face Removal
Back-Face Removal is an object-space hidden surface removal technique.
Purpose
To skip rendering polygons that face away from the camera, because they can never be visible.
Mathematical Test
- Let:
N
= surface normal vector of polygon (in view space)V
= view vector from the eye (camera) to the polygon
- Compute the dot product:
D = N . V
- If:
D > 0
→ Polygon is facing the viewer → keep it.D ≤ 0
→ Polygon is facing away → discard it.
Light, Color, and Color Models
Light & Color Basics
- Light: Visible electromagnetic waves (380–780 nm).
- Color: Perception from light wavelengths reflected/emitted by objects.
Color Models
RGB (Additive)
- Components: Red, Green, Blue.
- Mix light: Black =
(0,0,0)
, White =(255,255,255)
. - Used in: Monitors, TVs, cameras.
CMY (Subtractive)
- Components: Cyan, Magenta, Yellow.
- Mechanism: Inks subtract light colors.
- Conversion:
C=1−R
,M=1−G
,Y=1−B
. - Used in: Printing.
YIQ
- Components: Y (brightness), I (orange–cyan), Q (purple–green).
- Application: Y for B/W TVs, I & Q for color information.
- Used in: NTSC TV broadcast.
The 2D Graphics Pipeline
Modeling Transformation
- Convert objects from model coordinates (local space) to world coordinates.
- Example: Move a square from its local origin to a position in the scene.
World to Viewing Transformation
- Map world coordinates to view coordinates (camera space).
- Positions objects relative to the viewer’s window.
Clipping
- Remove (clip) portions of objects outside the view window (viewport in world coordinates).
- Saves processing by ignoring unseen parts.
- Example: If part of a line lies outside the drawing area, only the visible part is kept.
Window-to-Viewport Transformation
- Map the clipped coordinates from the world view window to the screen’s viewport.
- Converts world units to device units (pixels).
- Ensures the scene fits on the display.
Rasterization (Scan Conversion)
- Convert vector data (lines, shapes) into pixel data.
- Fills polygons, draws lines as discrete pixels.
Display
- Send rasterized image to the frame buffer for display on the screen.
Beam Penetration | Shadow Mask |
---|---|
Used in older color CRTs. | Used in modern color CRTs/LCDs. |
Two layers of phosphor (red & green); beam depth controls color. | Three separate phosphors (R, G, B) and a mask to direct beams. |
Limited color range (4–7 colors). | Millions of colors possible. |
Cheaper. | Higher cost. |
Lower image quality. | High image quality. |
Raster Scan | Vector Scan |
---|---|
Displays image as a matrix of pixels. | Draws image directly as a set of lines. |
Refreshes entire screen sequentially. | Refreshes only the lines needed. |
Used in TVs, modern monitors. | Used in oscilloscopes, plotters. |
Produces jagged edges for curves. | Produces smooth lines. |
Requires frame buffer. | Requires display list (vector memory). |
Aspect | Object Space | Image Space |
---|---|---|
Working Domain | 3D coordinates (world/view space) | 2D coordinates (screen space) |
Data Type | Vertices, edges, polygons | Pixels/fragments |
Visibility Tests | Per object/polygon | Per pixel |
Example Algorithm | Back-face removal, bounding volume tests | Z-buffer, scan-line |
Speed | Often faster for culling large objects | Slower if many unnecessary pixels |
Accuracy | High for geometry | High for final pixel colors |