Skip to content

A CPU rasterizer that supports texture mapping, shadow mapping, environment mapping, alpha blending, and more.

Notifications You must be signed in to change notification settings

Robochu/Mathics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Mathics is a single-threaded CPU rasterizer made as part of CS 334 in Fall 2022 at Purdue University. It is capable of rendering roughly 3,000 triangles at a 1000 × 600 resolution, while achieving about 15 frames per second. This project makes heavy use of C++ modules and other modern C++ features.

Screenshots

image image image image

Features

  • Templated Vector and Matrix classes for doing linear algebra.
  • Collection of over 900 named color constants located in color.cpp.
  • PinholeCamera class for projecting and unprojecting points. Supports various forms of manipulating the camera position/rotation.
  • Reasonably fast rasterization routine with subpixel precision to avoid visual artifacts.
  • Screen-space interpolation of vertex colors and normals and model-space interpolation of texture coordinates.
  • 2-phase rendering where z-buffering gets done first in order to run the shader code at most once per pixel.
  • Back-face culling.
  • TriangleMesh class which can either be constructed from a few basic shapes (triangles, quads, etc.) or be loaded from a file.
  • Cube mapping which supports shadow mapping, reflections, and skyboxes.
  • Point and directional light sources (directional light sources don't support shadow mapping).
  • Bilinear interpolation for texture lookup and shadow mapping.
  • A shader which supports ambient, diffuse, and specular lighting with plenty of customization options.
  • A basic material system.

Controls

W, A, S, D, space, and left shift to move around. Click on the window and use the mouse to control the camera. Press escape to regain the mouse cursor.

Dependencies

  • OpenGL 2.1 loaded with Glad (only used for blitting the final image onto the screen)
  • GLFW 3.3
  • LibTIFF
  • CImg

Credits

About

A CPU rasterizer that supports texture mapping, shadow mapping, environment mapping, alpha blending, and more.

Topics

Resources

Stars

Watchers

Forks

Languages