PadhaikoAll subjects

Graphics Software, Viewing Pipelines & Applications

Computer Graphics and Visualization (ENCT 201)

Open in the Padhaiko app

1.2.2 Graphics Software and Tools

Graphics software systems are broadly categorized into two main types:

  1. Special-Purpose Application Packages: Turnkey, user-oriented software programs designed for non-programmers to create, modify, and analyze graphical imagery without writing software code. Examples include Computer-Aided Design (CAD) packages, digital painting tools, architectural drafting software, and 3D animation suites.
  2. General Programming Packages: Comprehensive software libraries (Application Programming Interfaces, or APIs) that provide a collection of graphics functions callable from high-level programming languages (C, C++, Java, Python, Rust). Examples include OpenGL, DirectX, Vulkan, and WebGL.

Coordinate Representations

A fundamental role of graphics software is managing geometric descriptions across multiple spatial coordinate systems. As graphical primitives move from their initial mathematical definition to physical screen display, they pass through five primary reference frames:

[Modeling Coordinates (MC)]
         │
         ▼  Modeling Transformation (Translation, Rotation, Scaling)
[World Coordinates (WC)]
         │
         ▼  Viewing Transformation (Camera / Eye Positioning)
[Viewing Coordinates (VC)]
         │
         ▼  Projection Transformation & Clipping (Parallel / Perspective)
[Normalized Device Coordinates (NDC)]
         │
         ▼  Viewport / Workstation Transformation
[Device Coordinates (DC / Screen Coordinates)]
Definition

Hierarchy of Coordinate Reference Systems

  1. Modeling Coordinates (MC / Local / Object Space): The coordinate system in which an individual geometric primitive or model is defined in isolation. The origin is typically positioned at a convenient natural reference point of the object (such as the center of mass or base).
  2. World Coordinates (WC / World Space): A global Cartesian reference frame in which multiple individual models are assembled into a complete composite scene via modeling transformations (translation, scaling, rotation).
  3. Viewing Coordinates (VC / Camera / Eye Space): The coordinate frame established by defining a virtual camera in world space. The origin represents the viewpoint (eye position), and the axes are aligned with the camera's line-of-sight and orientation (view-plane normal and view-up vector).
  4. Normalized Device Coordinates (NDC / Canonical View Volume): A device-independent, standardized coordinate system obtained by applying projection transformations and perspective division. Coordinates are normalized into a standard unit range (typically or along all axes).
  5. Device Coordinates (DC / Screen Coordinates): The final physical coordinate system corresponding to integer pixel locations on a raster monitor, printer, or mobile screen.

Graphics Functions

General-purpose graphics programming libraries organize their functional calls into six core categories:

  1. Output Primitives: Functions that define the fundamental geometric entities to be drawn, including points, straight line segments, polylines, convex/concave polygons, spline curves, circles, and text characters.
  2. Attributes: Functions that control the visual styling of output primitives, such as line width, dashed/dotted styles, primary colors, surface transparency, polygon fill patterns, and typographic fonts.
  3. Geometric Transformations: Functions that alter the position, orientation, and size of primitives in 2D or 3D space (translation, rotation, scaling, reflection, and shearing).
  4. Viewing Transformations: Functions that define virtual camera parameters, select world-space clipping windows, configure parallel or perspective projection volumes, and map primitives into viewports.
  5. Input Functions: Functions that capture interactive user input from peripheral devices (mouse position, mouse button clicks, tablet stylus coordinates, keyboard strokes, and touch events).
  6. Control Operations: Administrative functions that manage the display context, such as initializing graphics hardware, clearing display buffers, swapping double buffers, setting video modes, and handling graphics pipeline errors.

Software Standards and PHIGS Workstations

To achieve software portability across diverse display devices and computer architectures, international standardization bodies established formal graphics software standards:

Industry Graphics APIs and Authoring Tools

Modern computer graphics practice relies on standardized low-level graphics APIs and high-level 3D content creation packages:

1.3 Graphics Pipeline

The graphics pipeline is the conceptual sequence of operations through which 3D geometric models, illumination settings, and camera parameters are systematically processed to produce a 2D color image on a raster display screen.

Early graphics hardware executed fixed-function pipelines with non-programmable transformation and lighting stages. Modern graphics hardware operates a fully programmable graphics pipeline orchestrated by GPU shader programs:

[Vertex Data: Positions, Normals, UVs]
                 │
                 ▼
      [Programmable Vertex Shader]
(Model-View-Projection Transforms, Vertex Lighting)
                 │
                 ▼
       [Primitive Assembly]
    (Lines, Triangles, Polygons)
                 │
                 ▼
           [3D Clipping]
  (Discard Primitives Outside View Frustum)
                 │
                 ▼
      [Perspective Division & Viewport]
      (Map to Normalized Coordinates & Screen)
                 │
                 ▼
          [Rasterization]
 (Scan-Convert Triangles into Pixel Fragments)
                 │
                 ▼
     [Programmable Fragment Shader]
  (Texture Mapping, Per-Pixel Phong Shading)
                 │
                 ▼
    [Per-Sample Operations / Blending]
  (Depth Test / Z-Buffer, Alpha Blending)
                 │
                 ▼
         [Frame Buffer]

1.3.1 Two-Dimensional (2D) Viewing Pipeline

In 2D computer graphics, the viewing pipeline isolates a rectangular region of interest in world space and maps it into a designated sub-rectangle on the physical display surface.

+-------------------------------------------------------------------------------+
|  1. Construct World Model: Primitives positioned in World Coordinates (WC)   |
+-------------------------------------------------------------------------------+
                                       │
                                       ▼
+-------------------------------------------------------------------------------+
|  2. Define Clipping Window: Specify [xw_min, xw_max] x [yw_min, yw_max]       |
+-------------------------------------------------------------------------------+
                                       │
                                       ▼
+-------------------------------------------------------------------------------+
|  3. 2D Clipping: Eliminate primitives outside the clipping window boundaries  |
+-------------------------------------------------------------------------------+
                                       │
                                       ▼
+-------------------------------------------------------------------------------+
|  4. Window-to-Viewport Transformation: Linear mapping to [xv_min, xv_max]     |
+-------------------------------------------------------------------------------+
                                       │
                                       ▼
+-------------------------------------------------------------------------------+
|  5. Device Coordinate Mapping: Display inside physical screen coordinates     |
+-------------------------------------------------------------------------------+
Definition

Window vs. Viewport

Mathematical Derivation of Window-to-Viewport Transformation

Let the world window boundaries be defined by:

Let the corresponding viewport boundaries on the display device be defined by:

To maintain the proportional relative positions of objects, any point inside the world window must occupy the exact same fractional position within the viewport:

Solving explicitly for the viewport coordinates :

where the horizontal and vertical scaling factors and are defined as:

Matrix Representation of Window-to-Viewport Transformation

The complete window-to-viewport transformation can be expressed as a composite 2D homogeneous transformation matrix composed of three elementary transformations:

  1. Translate the world window minimum corner to the origin: .
  2. Scale proportionally by factors and : .
  3. Translate from the origin to the viewport minimum corner : .

Multiplying these matrices yields the composite transformation matrix :

1.3.2 Three-Dimensional (3D) Viewing Pipeline

The 3D viewing pipeline extends 2D viewing concepts to handle depth, camera positioning, projection onto planar surfaces, and depth clipping.

[Modeling Coordinates (MC)]
         │
         ▼  Modeling Transformation (Translation, Rotation, Scaling)
[World Coordinates (WC)]
         │
         ▼  Viewing Transformation (Camera / Eye Coordinates)
[Viewing Coordinates (VC / Eye Space)]
         │
         ▼  Projection Transformation (Perspective / Orthographic)
[Clip Coordinates (4D Homogeneous: xc, yc, zc, wc)]
         │
         ▼  Perspective Division (Divide by wc) & 3D Frustum Clipping
[Normalized Device Coordinates (NDC: [-1, 1]³)]
         │
         ▼  Viewport Transformation
[Device Coordinates (Screen Space Pixels + Depth Buffer)]

Detailed Transformation Stages

  1. Modeling Transformation: Transforms local object vertices defined in Modeling Coordinates (MC) into a shared World Coordinate (WC) reference frame using translation, rotation, and scaling matrices ().
  2. Viewing Transformation: Aligns the world scene with a virtual camera located at position (eye point), pointed toward a reference target point (look-at point), with a specified view-up vector (). This produces Viewing Coordinates (VC / eye coordinates), where the camera resides at the origin looking down the negative -axis.
  3. Projection Transformation: Maps the 3D viewing volume onto a 2D projection plane:
    • Parallel Projection: Projectors are parallel, preserving relative proportions and planar parallelism (used in engineering CAD drawings).
    • Perspective Projection: Projectors converge at a single center of projection (the camera eye), creating realistic depth diminution where distant objects appear smaller.
  4. 3D Clipping (Canonical View Volume Clipping): Primitives lying partially or wholly outside the viewing volume (the frustum) are clipped against the canonical clipping boundaries:
  1. Perspective Division: Divides the 4D homogeneous coordinates by the homogeneous scaling factor :

This normalizes all visible geometry into the standard cubic Normalized Device Coordinate (NDC) space .

  1. Viewport Transformation: Linearly maps normalized coordinates into integer raster device coordinates and maps into the depth-buffer range for visible-surface determination.

1.4 Applications in Various Fields & Augmented / Virtual Reality

Computer graphics has revolutionized numerous scientific, industrial, artistic, and entertainment domains:

1. Computer-Aided Design (CAD) and Engineering

In mechanical, aerospace, civil, and electrical engineering, CAD systems allow engineers to construct 2D schematics and 3D solid models. Finite Element Analysis (FEA) visualizes structural stress, thermal distributions, and fluid dynamics using false-color gradient mapping over 3D triangular/tetrahedral meshes.

2. Medicine and Diagnostic Imaging

Computerized Tomography (CT), Magnetic Resonance Imaging (MRI), and 3D ultrasound generate volume slices that graphics systems reconstruct into 3D volumetric models. Surgeons utilize these visualizations for pre-operative path planning, robotic minimally invasive surgery, and virtual endoscopy.

3. Computer Art and Entertainment

Modern motion picture visual effects (VFX) and video games utilize physically based rendering (PBR), digital character sculpting, cloth simulation, and skeletal kinematics to create synthetic photorealistic worlds.

4. Scientific and Information Visualization

5. Augmented Reality (AR) and Virtual Reality (VR)

AspectVirtual Reality (VR)Augmented Reality (AR)
Visual EnvironmentCompletely synthetic, computer-generated digital environment.Real physical world overlaid with digital, computer-generated graphics.
User ImmersionFully immersed; physical surroundings are visually occluded.Semi-immersed; user maintains direct visual contact with reality.
Display TechnologyOpaque Head-Mounted Displays (HMDs) with optical collimating lenses.Optical see-through glasses (waveguide prisms) or video pass-through cameras.
Tracking Requirements6-DOF head and controller tracking within an internal virtual coordinate space.Precise real-time environmental tracking (SLAM) and physical plane detection.
Primary Latency ChallengeMotion-to-photon latency must remain below to avoid simulator sickness.Registration latency causes synthetic digital objects to drift or swim over physical surfaces.

Worked Examples

Example 1

2D Window-to-Viewport Coordinate Transformation

A 2D world window has its lower-left corner at and its upper-right corner at . The corresponding display viewport has its lower-left corner at and upper-right corner at .

  1. Calculate the horizontal and vertical scaling factors and .
  2. Determine the mapped viewport coordinates for the world points and .

Calculation of Scaling Factors: The window dimensions are:

The viewport dimensions are:

Evaluating the scaling factors:

Since , uniform scaling is maintained, and objects mapped from the window to the viewport will preserve their geometric aspect ratio without stretching.

Mapping World Point P1(40, 50): Applying the window-to-viewport transformation equations:

Thus, point maps to viewport location .

Mapping World Point P2(80, 20): Applying the transformation equations:

Thus, point maps to viewport location .

Answer:
  1. Scaling factors: , .
  2. Mapped coordinates:
Example 2

Aspect Ratio Preservation in Viewport Mapping

A square world window of width and height spanning is to be mapped into a rectangular display viewport of resolution spanning .

  1. Calculate the unconstrained scaling factors and and explain the resulting distortion.
  2. Determine the uniform scaling factor and the adjusted viewport boundaries needed to preserve aspect ratio while centering the image within the available viewport.

Unconstrained Scaling Factors and Geometric Distortion: The world window width and height are:

The viewport width and height are:

Calculating independent scaling factors:

Because , horizontal features are magnified by a factor of while vertical features are magnified by only . Consequently, circles drawn in the world coordinate space are distorted into horizontally elongated ellipses on the screen, and square boundaries are stretched into wide rectangles.

Constraining Scaling to Preserve Aspect Ratio: To eliminate geometric distortion, both axes must share an identical scaling factor . To guarantee that the mapped scene fits entirely inside the available viewport without clipping, we choose:

With this uniform scaling factor:

Centering the Square Viewport within the Display Area: The height of the rendered image () fills the viewport vertical dimension entirely (). The available horizontal width is , while the rendered width is . The remaining horizontal padding is:

Distributing this padding equally across left and right margins:

Thus, the adjusted viewport boundaries that center the undistorted square image are:

Answer:
  1. Unconstrained scaling yields and , causing horizontal stretching distortion.
  2. The uniform scaling factor is . Centering the undistorted square image within the area yields adjusted viewport boundaries .
Example 3

Matrix Composition of 2D Window-to-Viewport Transformation

A 2D window is defined in world coordinates by . The target viewport is defined by .

  1. Derive the numerical homogeneous transformation matrix that maps world points directly to viewport points.
  2. Using matrix multiplication, compute the viewport coordinates for the world center point .

Evaluating Scaling and Translation Terms: The window dimensions are and . The viewport dimensions are and .

The scaling factors are:

The translation offset terms are:

Constructing the Composite Matrix Mwv: The general window-to-viewport matrix is:

Matrix Mapping of Point P(40, 25): Representing point as a homogeneous column vector:

Carrying out the matrix multiplication:

The mapped viewport position is , which corresponds exactly to the center of the viewport .

Answer:
  1. The composite window-to-viewport transformation matrix is:
  1. The world center point maps to the viewport point .

Exercises

Viewing Pipelines & Coordinate Transformation Exercises

Question 1

A 2D graphics application specifies a world window with corners and . It first transforms world coordinates into a normalized device coordinate viewport and then maps normalized coordinates to physical screen pixels on a display with coordinates .

  1. Derive the normalized viewport coordinates for the world point .
  2. Calculate the corresponding physical screen pixel coordinates.

Mapping to Normalized Viewport: Given window boundaries:

Target normalized viewport:

The scaling factors to normalized device coordinates are:

Mapping the point :

Mapping Normalized Coordinates to Physical Screen Coordinates: Target display screen coordinates:

Mapping linearly:

Answer:
  1. Normalized device coordinates: .
  2. Physical screen pixel coordinates: (or rounded from ).
Question 2

Draw and explain the block diagram of the 3D viewing pipeline. Explicitly differentiate the roles and coordinate spaces of Viewing Coordinates (VC) and Normalized Device Coordinates (NDC).

Block Diagram of the 3D Viewing Pipeline: The complete coordinate transformation sequence in 3D viewing is:

[Modeling Coordinates (MC)]
         │
         ▼  Modeling Transformation (Object Assembly)
[World Coordinates (WC)]
         │
         ▼  Viewing Transformation (Camera Orientation)
[Viewing Coordinates (VC / Eye Space)]
         │
         ▼  Projection Transformation (Perspective / Parallel)
[Clip Coordinates (4D Homogeneous: xc, yc, zc, wc)]
         │
         ▼  Perspective Division & 3D Frustum Clipping
[Normalized Device Coordinates (NDC: [-1, 1]³)]
         │
         ▼  Viewport Transformation
[Device Coordinates (Screen Pixels + Depth Buffer)]

Role of Viewing Coordinates (VC / Eye Space): Viewing Coordinates define a 3D coordinate space centered at the virtual camera's focal point (eye position). The camera is positioned at the origin, with its line of sight aligned with the viewing direction (usually looking down the axis) and its orientation governed by the view-up vector. In this space, object positions reflect their physical distance and angle relative to the observer's eye, simplifying depth testing, back-face culling, and lighting calculations.

Role of Normalized Device Coordinates (NDC): Normalized Device Coordinates represent a device-independent, standardized canonical viewing volume (typically a cube ranging from along and ). After applying projection transformation and perspective division (), all visible scene geometry is compressed into this unit volume. NDC decouples the rendering engine from specific output hardware resolutions, allowing standard rasterization and clipping algorithms to operate uniformly across any monitor, mobile screen, or printer.

Answer:

The 3D viewing pipeline transforms coordinates along the path . Viewing coordinates position the world relative to the camera eye, while Normalized Device Coordinates standardize projected geometry into a device-independent canonical cube ready for rasterization.

Question 3

Compare GKS and PHIGS as graphics software standards. Explain the purpose of the Centralized Structure Store (CSS) in PHIGS and describe how hierarchical modeling is achieved.

Comparison of GKS and PHIGS: GKS (Graphical Kernel System) was introduced primarily as a 2D graphics programming standard. It utilizes a flat, pipeline-oriented architecture where primitives and attributes are dispatched directly to the display surface without retaining a persistent scene graph. In contrast, PHIGS (Programmer's Hierarchical Interactive Graphics System) is an advanced 3D graphics standard engineered for dynamic interactive applications. PHIGS retains graphical models in a centralized database and provides native support for hierarchical object assemblies, nested coordinate frames, and 3D geometric transformations.

The Centralized Structure Store (CSS): The Centralized Structure Store is an object-oriented memory repository in PHIGS that maintains a collection of named graphical structures. A structure contains a sequential list of structure elements, which may include geometric primitives (POLYLINE, FILL_AREA), attribute definitions (LINE_COLOR, INTERIOR_STYLE), transformation matrices, and structure invocation commands (EXECUTE_STRUCTURE).

Hierarchical Modeling Mechanism: Hierarchical modeling is implemented by having parent structures execute child structures. For instance, a "Robot" structure can invoke an "Arm" structure, which in turn invokes a "Hand" structure. When a child structure is invoked, it inherits the composite transformation matrix of its parent, applies its own local transformation, and renders its geometry. Changes made to parent transformations automatically propagate down the hierarchy, enabling realistic articulated motion without recomputing individual vertex coordinates.

Answer:

GKS is a 2D immediate-mode graphics standard, whereas PHIGS is a 3D retained-mode standard built around the Centralized Structure Store (CSS). The CSS stores hierarchical networks of structures where child structures inherit transformation matrices from parent structures to enable articulated modeling.

Question 4

Describe the technical requirements of Virtual Reality (VR) and Augmented Reality (AR). Explain why motion-to-photon latency is critical in VR systems, and describe how tracking drift affects AR registration.

Technical Requirements of VR vs. AR: Virtual Reality requires high-refresh stereoscopic displays, wide field-of-view optical lenses, low-latency head orientation tracking (3-DOF or 6-DOF), and complete visual immersion that occludes the external physical environment. Augmented Reality requires either optical see-through or video pass-through display hardware, high-resolution environmental sensors (depth cameras, LiDAR), and real-time computer vision algorithms to track physical surfaces and estimate environmental lighting.

Motion-to-Photon Latency in VR: Motion-to-photon latency is the total delay from the instant an IMU sensor registers a head rotation to the exact moment the updated stereoscopic frame is emitted by the display panel. If this latency exceeds , a sensory conflict occurs between the vestibular system of the inner ear (which senses physical motion instantaneously) and the visual cortex (which perceives delayed visual motion). This sensory mismatch triggers vestibular disorientation, nausea, and headache, collectively known as simulator sickness.

Tracking Drift and AR Registration: In Augmented Reality, synthetic digital objects must maintain the illusion of being rigidly anchored to physical surfaces (such as a tabletop). This spatial alignment is termed registration. If tracking algorithms accumulate numerical drift (from sensor noise or feature tracking errors), the virtual coordinate frame diverges from the physical room geometry. This causes synthetic objects to jitter, drift, or "swim" across real-world surfaces, destroying user immersion and realism.

Answer:

VR demands full sensory immersion with motion-to-photon latency below to prevent simulator sickness. AR requires sub-millimeter real-time tracking (SLAM) to avoid tracking drift and maintain rigid registration of virtual objects on real physical surfaces.

Question 5

List and describe the six fundamental categories of graphics functions defined in general-purpose graphics programming libraries.

The Six Fundamental Categories of Graphics Functions:

  1. Output Primitives: Functions that generate the fundamental graphical elements of a scene, including points, line segments, polylines, polygons, spline curves, quadric surfaces, and stroke or bitmap text.
  2. Attributes: Functions that control how primitives are visually styled, such as line thickness, dash pattern, stroke color, polygon interior fill style (solid, pattern, hatch), surface specular reflectivity, and font families.
  3. Geometric Transformations: Functions that manipulate the spatial configuration of primitives in 2D or 3D, including translation, rotation, scaling, reflection, and shearing.

Viewing, Input, and Control Functions:

  1. Viewing Transformations: Functions that configure the virtual camera, define world clipping windows, specify parallel or perspective projection matrices, and map normalized coordinates into screen viewports.
  2. Input Functions: Functions that handle interactive user input events from hardware peripherals (mouse position, mouse button clicks, keyboard characters, stylus pressure, touch gestures).
  3. Control Operations: Administrative routines that manage the graphics pipeline environment, such as initializing display hardware, allocating frame buffer memory, swapping front and back double buffers, and clearing color/depth buffers.
Answer:

The six fundamental categories are: (1) Output Primitives, (2) Attributes, (3) Geometric Transformations, (4) Viewing Transformations, (5) Input Functions, and (6) Control Operations.

Question 6

A 2D world window has its lower-left corner at and upper-right corner at . It is mapped to a display viewport with lower-left corner at and upper-right corner at .

  1. Construct the window-to-viewport transformation matrix .
  2. Verify the mapping by computing the viewport coordinates for the world point .

Computing Scaling and Translation Elements: Window dimensions:

Viewport dimensions:

Scaling factors:

Since , aspect ratio is strictly preserved. Translation terms:

Matrix Construction and Point Evaluation: The composite transformation matrix is:

Multiplying with the homogeneous coordinates of :

The world center point maps to , which is the exact center of the viewport .

Answer:
  1. The window-to-viewport transformation matrix is:
  1. The world point maps to the viewport point .

Past exam questions for Computer Graphics and Visualization

← History & Video Display DevicesRasterizing Points & Lines: DDA and Bresenham →