Skip to content

saevuss/ComputerGraphics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DH2323 — Computer Graphics

Laboratory work and projects for the DH2323 course at KTH Royal Institute of Technology.


📁 Labs Overview

Lab 1 — Projections & Interpolation

Focused on the transition from 2D pixel plotting to 3D coordinate systems.

  • Linear Interpolation — Numerical and vector interpolation to generate smooth color gradients across the viewport.
  • Starfield Simulation — Real-time animation of 3D points moving toward a pinhole camera.
  • Perspective Projection — Mapping 3D coordinates (x, y, z) to 2D screen coordinates (u, v) using focal length and aspect ratio calculations.


Lab 2 — Raytracing

A CPU-based raytracer designed to render 3D scenes by tracing light paths from the camera into the environment.

  • Geometry Engine — Scenes modeled using triangular surfaces with pre-computed normals.
  • Ray-Triangle Intersection — Solving the linear system Ax = b via matrix inversion to find the exact hit point (t, u, v).
  • Camera System — Interactive movement with 3×3 rotation matrices for Y-axis yaw.
  • Lighting Model:
    • Direct Illumination — Lambertian reflectance based on the dot product between surface normals and light direction vectors.
    • Shadow Rays — Secondary rays cast from intersection points to the light source to detect occlusions.
    • Indirect Illumination — Constant ambient term approximation to simulate light bounces.

Lab 3 — Rasterization

Focus on real-time rendering using rasterization, transitioning from ray-based rendering to scanline-based triangle filling.

  • Wireframe Rendering — Projection of 3D triangles onto screen space for structural validation.
  • Triangle Rasterization — Filling triangles using row-wise interpolation between edges.
  • Depth Buffer (Z-buffer) — Visibility handling using inverse depth (1/z) comparisons.
  • Shading Models:
    • Per-Vertex Illumination — Lighting computed at vertices and interpolated.
    • Per-Pixel Illumination — Lighting computed per fragment for higher accuracy.
  • Perspective-Correct Interpolation — Attributes interpolated using 1/z to avoid distortion caused by perspective projection.


About

Computer graphics labs and project from DH2323 course at KTH

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages