SkillAgentSearch skills...

Renderer

A shader-based software renderer written from scratch in C89

Install / Use

/learn @zauonlok/Renderer

README

Software Renderer

<img src="assets/helmet/screenshot2.png" width="410"> <img src="assets/helmet/screenshot3.png" width="410"> <img src="assets/drone/screenshot1.gif" width="410"> <img src="assets/drone/screenshot2.gif" width="410">

This is a shader-based software renderer written from scratch in C89 with minimal dependencies, available for Windows, macOS, and Linux.

Features

  • Cross platform
  • Minimal dependencies
  • Shader based
  • Homogeneous clipping
  • Back-face culling
  • Perspective correct interpolation
  • Depth testing
  • Alpha testing
  • Alpha blending
  • Cubemapped skybox
  • Skeletal animation
  • Tangent space normal mapping
  • Shadow mapping
  • ACES tone mapping
  • Blinn–Phong reflection model
  • Physically based rendering (PBR)
  • Metallic-roughness workflow
  • Specular-glossiness workflow
  • Image-based lighting (IBL)
  • Orbital camera controls
  • PBR material inspector

Download

Pre-built binaries for Windows, macOS, and Linux are available for download from the Releases page.

Build

To build the software renderer from source, a C89 compiler and development files for your window system are required.

Windows

Install Visual Studio with C++ support and run build_win32.bat.

macOS

Install Command Line Tools for Xcode with the command below and run build_macos.sh.

xcode-select --install

Linux

Install GCC and Xlib with the following commands and run build_linux.sh.

Ubuntu / Debian

sudo apt install gcc libx11-dev

Fedora / RHEL

sudo dnf install gcc libX11-devel

openSUSE / SUSE

sudo zypper install gcc libX11-devel

Bonus

A CMakeLists.txt file is provided for generating project files using CMake (see examples below).

Visual Studio

mkdir build
cd build
cmake -G "Visual Studio 16 2019" ..
start Renderer.sln

Xcode

mkdir build
cd build
cmake -G Xcode ..
open Renderer.xcodeproj

Makefile

mkdir build
cd build
cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Release ..
make

Usage

Launch

If the software renderer is launched without arguments, one of the available scenes will be chosen randomly. To display a specific scene (see below), additional arguments should be supplied. The command line syntax is:

Viewer [test_name [scene_name]]

Controls

  • Orbit: left mouse button
  • Pan: right mouse button
  • Zoom: mouse wheel
  • Rotate lighting: <kbd>A</kbd> <kbd>D</kbd> <kbd>S</kbd> <kbd>W</kbd>
  • Reset everything: <kbd>Space</kbd>

Inspector

For PBR scenes, a material inspector that is very similar to the layers view of Marmoset Viewer is provided. Double click to bring it up.

Screenshots

| Scene | Command | | --------------------------------------------------------------------------------------- | ------------------------- | | <img src="assets/azura/screenshot.png" width="600"> | Viewer blinn azura | | <img src="assets/centaur/screenshot.png" width="600"> | Viewer blinn centaur | | <img src="assets/craftsman/screenshot2.gif" width="600"> | Viewer blinn craftsman | | <img src="assets/elfgirl/screenshot2.png" width="600"> | Viewer blinn elfgirl | | <img src="assets/kgirl/screenshot.gif" width="600"> | Viewer blinn kgirl | | <img src="assets/lighthouse/screenshot.png" width="600"> | Viewer blinn lighthouse | | <img src="assets/mccree/screenshot.png" width="600"> | Viewer blinn mccree | | <img src="assets/nier2b/screenshot.png" width="600"> | Viewer blinn nier2b | | <img src="assets/phoenix/screenshot.gif" width="600"> | Viewer blinn phoenix | | <img src="assets/vivi/screenshot.png" width="600"> | Viewer blinn vivi | | <img src="assets/whip/screenshot.gif" width="600"> | Viewer blinn whip | | <img src="assets/witch/screenshot.png" width="600"> | Viewer blinn witch | | <img src="assets/assassin/screenshot.gif" width="600"> | Viewer pbr assassin | | <img src="assets/buster/screenshot1.gif" width="600"> | Viewer pbr buster | | <img src="assets/crab/screenshot.gif" width="600"> | Viewer pbr crab | | <img src="assets/dieselpunk/screenshot.png" width="600"> | Viewer pbr dieselpunk | | <img src="assets/drone/screenshot1.gif" width="600"> | Viewer pbr drone | | <img src="assets/helmet/screenshot1.png" width="600"> | Viewer pbr helmet | | <img src="assets/horse/screenshot.gif" width="600"> | Viewer pbr horse | | <img src="assets/junkrat/screenshot.gif" width="600"> | Viewer pbr junkrat | | <img src="assets/ornitier/screenshot.png" width="600"> | Viewer pbr ornitier | | <img src="assets/ponycar/screenshot2.png" width="600"> | Viewer pbr ponycar | | <img src="assets/robot/screenshot.png" width="600"> | Viewer pbr robot | | <img src="assets/spruit/screenshot1.png" width="600"> | Viewer pbr sphere | | <img src="assets/workshop/screenshot2.png" width="600"> | Viewer pbr spheres |

References

Rendering pipeline

Physically based rendering

File formats

Miscellaneous

License

MIT License

View on GitHub
GitHub Stars2.7k
CategoryDevelopment
Updated2d ago
Forks293

Languages

C

Security Score

100/100

Audited on Mar 25, 2026

No findings