GithubHelp home page GithubHelp logo

murumura / ctrtc Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 358 KB

Ray tracer implementation in C++ inspired by Jamis Buck's book "The Ray Tracer Challenge"

CMake 2.35% Makefile 0.93% Dockerfile 0.43% Shell 0.39% C++ 95.91%
compiletime cpp20 raytracing

ctrtc's Introduction

Compile-Time-RayTracerChallenge (ctrtc)

Ray tracer implementation in C++ inspired by Jamis Buck's book "The Ray Tracer Challenge".

This is a C++20 ray tracer project using constexpr function evaluation to make all computation happend entirely at compile-time.

(This project is currently under development)

Quick Start

Prerequisites

  • CMake 3.16+
  • GTest
  • Compliant C++20 compiler
    • The library is sytematically tested on following compilers
Compiler Version
GCC 12.1.0
clang 15.0.0

With Ubuntu 22.04 (the O.S I used), one could easily install and setup enviorments needed for this project by:

# Install Make/CMake
sudo apt-get install -y build-essential
sudo apt-get install -y cmake
# Install GTest for running test suite
sudo apt-get install -y libgtest-dev
# Install g++20 and setup  
sudo apt-get install -y g++-12 gcc-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 --slave /usr/bin/g++ g++ /usr/bin/g++-12 --slave /usr/bin/gcov gcov /usr/bin/gcov-12
# (optional) or install clang15 if you want
sudo apt-get install -y clang-15
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-15 40

WARNING

(1) While compile-time image generation works with GCC 12, compiler memory usage is extreme -- tens of gigabytes for even modest image sizes. If you want to try it out with GCC, stick to very small images or prepare for violent retribution from the OOM-killer.

(2) Alought I trying to follow and implment the testing examples in books, turning out there must be some trade-off for compile-time implementation in C++, therefore some test-cases mights look completely different from book illustrations (sending me pull requests if you think some implementations could be done better and better approximating examples from book).

Build and run test suite

Use the following commands from the project's top-most directory to run the test suite.

cd ctrtc
make clean # for tidy check
make test=1
make run-test

Render Results (starting from chapter 5)

If you want to complete the render at compile time, all calculations have to be done at compile time, which will cost a lot of memory and take longer to compile.

Chapter5

cd ctrtc
make clean # for tidy check
make CH=5 # render at run time
# ---or render at compile time, this would take up ~30 min to finish ---#
make CH=5 STATIC=1 
./build/default/debug/scene/CHAPTER5 

[Sphere]

Chapter6

cd ctrtc
make clean # for tidy check
make CH=6 # render at run time
# ---or render at compile time, this would take up ~30 min to finish
make CH=6 STATIC=1 
./build/default/debug/scene/CHAPTER6

Silhouette

Chapter7

cd ctrtc
make clean # for tidy check
make CH=7 # render at run time
# ---or render at compile time, this would take up ~30 min to finish
make CH=7 STATIC=1 
./build/default/debug/scene/CHAPTER7

Silhouette

Chapter8

cd ctrtc
make clean # for tidy check
make CH=8 # render at run time
# ---or render at compile time, this would take up ~30 min to finish
make CH=8 STATIC=1 
./build/default/debug/scene/CHAPTER8

Silhouette

Chapter9

cd ctrtc
make clean # for tidy check
make CH=9 # render at run time
# ---or render at compile time, this would take up ~30 min to finish
make CH=9 STATIC=1 
./build/default/debug/scene/CHAPTER9

Silhouette

ctrtc's People

Contributors

murumura avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.