Skip to content

wivest/ray-tracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ray Tracer

Ray tracer written in Taichi lang, Python. Customizable toy renderer using BVH optimisation with must-have functionality. Example scene render:

Example render

Features

The project supports following features:

  • recognizing glTF files (export from Blender possible)
  • preview mode with movable camera
  • renderer settings (samples, ray bounces etc.)
  • diffuse, specular and emission colors of materials
  • point/sun light sampling

Getting started

Prerequisites

Taichi requires Python to run. To clone the project git is needed (skip if downloading archive). Ensure python and git are on PATH.

Important

Not all Python versions work with Taichi. Which specific do are listed on official website. To avoid further conflicts release 3.10.11 is recommended.

Repository

Clone the repository from GitHub using your terminal of choice

git clone https://github.com/wivest/ray-tracer.git

Then navigate to the repository itself

cd ray-tracer

Tip

Optional step. Recommended to avoid package versions conflicts.
To manage Python packages virtual environment can be created. More information can be found here.

Also some third-party packages are needed. After installing Python run

pip install -r requirements.txt

You're now ready to run the project! To get CLI help type

python main.py -h

Usage

Scenes

First, you need scenes to display (scenes under /examples are ready to use). Those can be exported from Blender in glTF format. Go to File > Export > glTF 2.0 and choose desired location to export, it will be passed to main program later.

Important

There are some necessary checkboxes in export settings! In Include > Data check Cameras and Punctual lights. In Data > Lighting choose Lighting Mode Unitless.

Modes and camera controls

The simplest command to run is

python main.py examples/suzanne.glb

which opens scene in Scene preview mode. In this mode you can move, rotate camera and switch between lenses (gray preview and render). Camera controls at a glance:

  • move: WASD (horizontal), EX (vertical) + Shift if using global space
  • switch camera modes: M
  • switch cameras (if there are many): Tab

Scene preview mode is, as the name says, only a preview. To render an image you need to lauch the project in scene render mode

python main.py examples/suzanne.glb -r

The window appears where you can see the render process. It is safe to quit with an unfinished render, it will still be saved.

Settings

Some parameters are customizable via the CLI. You can get them and their description by typing help message

python main.py -h

Most of them affect both scene preview and render modes. Render savepath is a location, where a ready image will be stored (default is render.png and will be ignored by .gitignore). Camera index is useful if there are multiple cameras in the scene. So a specific one can be selected to render (default is 0). You can however switch cameras in scene preview mode with Tab!

About

Simple ray tracer written in taichi.

Topics

Resources

License

Stars

Watchers

Forks

Languages