Skip to content

Auria-dev/software-renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Software Renderer

This project is a software-based 3d renderer implemented entirely in C99. It mimics the functionality of a modern graphics api such as OpenGL, but runs fully on the CPU. The renderer is built around a modular architecture, focusing on flexibility and ease of integration.


“The Lighthouse” by Cotman Sam (used under CC BY 4.0). 15ㅤㅤㅤㅤ,000 triangles rendered in real time at ~60FPS on the AMD Ryzen 7 5800X

Features

  • Complete 3d rendering pipeline: from model import to final pixel output, every stage of the pipeline is implemented in software
  • Cross-platform support: includes a lightweight platform layer compatible with both windows (windows.h) and linux (x11)

Linux support is currently only partial due to hardware limitations and time constraints

  • Custom asset loaders: manually written parsers for .obj and .mtl formats

  • Minimal external dependencies: uses only platform libraries for window management and stb_image for texture loading

  • Optimized rasterization:

    • perspective-correct interpolation for vertex attributes (color, uv coordinates)
    • back-face culling for performance
    • depth buffering (z-buffer) for proper occlusion
  • Shading and texture mapping:

    • supports gouraud and flat shading
    • textured and non-textured rendering modes
    • bilinear and nearest-neighbor texture sampling
  • 3d math library:

    • custom implementation for vector and matrix operations
    • left-handed coordinate system
    • column-major matrix layout for transformations

Technical Specifications

  • Language: c99 (no external frameworks)

  • Rendering core:

    • cpu-driven rasterizer
    • dedicated framebuffers for color and depth
  • Implemented graphics pipeline stages:

    1. model & view transformation: converts object-space vertices into world and camera space
    2. projection: applies perspective projection to map 3d coordinates into 2d screen space
    3. clipping: clips primitives against the view frustum boundaries
    4. rasterization: converts triangles into pixel fragments
    5. shading & texturing: applies color interpolation or texture sampling per pixel
  • Dependencies:

    • stb_image.h for texture loading
    • windows.h (on windows) or x11/xlib.h (on linux) for windowing and input handling

Showcase

Building and Running

the project includes a makefile for straightforward compilation.

  1. clone the repository:

    git clone https://github.com/auria-dev/software-renderer.git
    cd software-renderer
  2. build the project:

    • on linux, ensure x11 development headers are installed:

      # debian/ubuntu
      sudo apt-get install libx11-dev
      
      # arch
      sudo pacman -S libx11
      
      # nix
      nix-shell -p libX11
      
      # void
      sudo xbps-install -S libX11-devel
    • compile the source using:

      make
  3. run the application:

    ./renderer

Controls

  • w, a, s, d: move camera forward, left, backward, and right

  • space: move camera up

  • left shift: move camera down

  • arrow keys: rotate camera

  • escape: exit the application

About

A 3d software renderer written from scratch.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published