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.
- Templated
Vector
andMatrix
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.
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.
- OpenGL 2.1 loaded with Glad (only used for blitting the final image onto the screen)
- GLFW 3.3
- LibTIFF
- CImg
- Skybox by Pieter ‘Spiney’ Verhoeven
- Grass and metal by p0ss
- Utah teapot by Martin Newell