Skip to content

fahad-cpp/Renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

105 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Renderer

This is a CPU Renderer that renders objects using the CPU , you can use either a ray tracer or a rasterizer to render models, i made this project to learn the graphics pipeline and Windows API , although now it uses FSWindow , a windowing library i made for linux and windows. This project supports rendering OBJ files, with basic lighting (blinn-phong) and includes features for visualization and debugging.

Controls

  • W, A, S, D: Move the camera.
  • Space/CTRL: Move the camera up/down.
  • SHIFT: Increase moving speed.
  • Mouse: Rotate the camera.
  • Key Bindings:
    • R: Toggle ray tracing/rasterization.
    • X: Change lighting modes
    • G: Lock/unlock the mouse.
    • N: set debugstate to normal mode
    • T: set debugstate to wireframe mode
    • V: disable debugstate.
    • M: set debugstate to depth mode
    • B: Show/hide bounding boxes.
    • C: Toggle backface culling.
    • P: Export the current frame to a PPM file.
    • Q: Reset camera position and rotation.
    • L: Display model details.
    • F: Toggle FXAA anti-aliasing.
    • ESC: Exit the application.

Building from source

Windows

  • install a clang, cmake and ninja
winget install cmake
winget install LLVM.LLVM
winget install Ninja-build.Ninja
  • clone the repo.
git clone --recursive https://github.com/fahad-cpp/Renderer Renderer
cd Renderer
  • build using cmake with ninja and run
cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++
cmake --build build --config Release
bin\Release\Renderer.exe

Linux

  • install a clang, cmake and ninja using your package manager
sudo pacman -S clang ninja cmake lld
  • clone the repo
git clone --recursive https://github.com/fahad-cpp/Renderer Renderer
cd Renderer
  • build using cmake with ninja and run
cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++
cmake --build build --config Release
./bin/Release/Renderer

Note:
on Wayland systems the mouse locking does not work so mouse will go out of window
disable mouse lock by pressing G

Sample Outputs

Ray Tracing

  • White King: A ray-traced render of a chess piece. WhiteKing

  • Spheres: Reflection on spheres rendered using ray tracing. RayTracerReflection

Rasterization

  • Demon Skull Normals: Render time : ~8ms
    DemonSkullDepth

  • Demon Skull: Render time : ~8ms
    DemonSkullLightBr

  • Sponza: Render time : ~40ms
    DemonSkullLightBr

About

Software renderer in C++

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors