Skip to content

gnikoloff/software-renderer

Repository files navigation

Software rasterizer dojo

3D renderer written as an exercise to learn C and how graphics APIs such as OpenGL are implemented under the hood.

Shadow mapping demo preview

Features

  1. Software rasterization
  2. Pure C17 implementation
  3. Right hand Y-up coordinate system
  4. Uses SDL for access to graphics hardware, mouse, keyboard, etc.
  5. Supports native and web via emscripten
  6. Perspective correct interpolation
  7. Support for vertex and fragment shaders
  8. Depth buffer
  9. Face culling
  10. Viewport clipping
  11. Loading and parsing Wavefront .OBJ files and PNG images
  12. Cube map sampling

References and readings

  1. 3D Computer Graphics Programming
  2. Modern C
  3. niepp/spbr
  4. Lode's Computer Graphics Tutorial

Building for native

Clone the project and run in the terminal:

make build DEMO_NAME=DESIRED_DEMO_NAME
make run DEMO_NAME=DESIRED_DEMO_NAME

Where DESIRED_DEMO_NAME is the demo you want to build and run.

Here is a full list of the demo names:

GEOMETRY_EXAMPLE
SHADOWMAP_EXAMPLE
PHYSICS2D_EXAMPLE
DEPTHBUFFER_EXAMPLE
ENVIRONMENTMAPPING_EXAMPLE
PLASMA_EXAMPLE
TUNNEL_EXAMPLE

Building for web

Clone the project and run in the terminal:

make build-emscripten DEMO_NAME=DESIRED_DEMO_NAME

To run the web server to view it in a browser run:

npm i
npm start

This will start a local web server you can open in your browser of choice.

3D Geometry demo preview
Geometries
Depth buffer demo preview
Visualised depth buffer
Environment mapping demo preview
Environment mapping
Plasma demo preview
Plasma
Tunnel demo preview
Tunnel
2D Physics demo preview
2D Physics