Giter VIP home page Giter VIP logo

illumination-theory's Introduction

Illumination-Theory

Alt text

Raytracing in a weekend implemented in Rust.

Following this: https://raytracing.github.io/.
With some modifications:

  • Multithreading ₊˚ʚ ᗢ₊˚✧ ゚.
    • GPU rendering will be added soon.
  • Direct output to a file.
  • Progress bar(s).

Running

Clone this repo:

git clone https://github.com/MaximusPrimeForever/Illumination-Theory.git

Options

The script allows you to configure the following values:

  • Image width - in pixels (higher resolution generally results in a cleaner image).
  • Aspect ratio - ratio of image width and height.
  • Vertical FOV - how wide the image is vertically (affects horizontal FOV as well of course).
  • Sample rate - how many rays are simulated per pixel (higher values generate a cleaner image).
  • Trace depth - how many times a ray can bounce around the scene until it dies (higher values generate better reflections/refractions).
  • Thread count - how many threads to run in parallel while rendering. This can be increased past the actual CPU core count to divide the image into smaller parts, and thus potentially increasing performance.

Note: if rendering a complex scene with parameters turned up on all cores, the render WILL use up ALL of the CPU.

Alt text

Default values

Running the script without passing args will use:

  • Image width = 400
  • Sample rate = 100
  • Trace depth = 10
  • Core count = 0 - meaning all cores.
  • Vertical FOV = 60
  • Aspect Ratio = 1.7777 (roughly 16:9)

On Linux

Run the script:

cd Illumination-Theory
chmod +x ./render.sh

# image_width = 400, sample_rate = 100, trace_depth = 10, core_count = 0
./render.sh image

# image_width = 600, sample_rate = 200, trace_depth = 20, core_count = 0
./render.sh image 600 200 20 0

On Windows

Run the script:

cd Illumination-Theory

.\run.ps1 image

# specifiying a bunch of parameters
.\run.ps1 rectangle_diffuse_light -thread_count 32 -trace_depth 30 -vertical_fov 25 -aspect_ratio 1.7777 -image_width 600 -samples_per_pixel 100

Images

You can checkout a tag to get a specific image.
e.g. this will render an early image with anti aliasing implemented:

git checkout antialiased_world
./render.sh aa_world

Testing

On August 2023, "Ray Tracing in One Weekend" was updated with a significant refactor (for the better), and while refactoring this code I broke a lot of things.
So, for the future, here's a test scene to make sure everything looks correct (located in rtweekend.rs): Alt text

Run:

.\run.ps1 -run_test $True

Output image test_scene.png will be next to the script. if -run_test $True is present all other flags are ignored.

illumination-theory's People

Contributors

maximusprimeforever avatar

Watchers

 avatar

illumination-theory's Issues

Add more shapes.

How can this only render SPHERES?!
Add:

  • box,
  • cylinder
  • triangle

Add lights.

Such a basic thing. Can't BELIEVE it's not implemented yet.

Add CUDA support.

Since I own an RTX 4070 Ti it would be interesting to see if I can run code on the RT cores and speed up the computation even more.

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.