lerouxrgd / raytracer

The Ray Tracer Challenge in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ray Tracer

Rust implementation for The Ray Tracer Challenge. Download the CLI from the release page.

There are some extra post processing effects available:

Usage

The Ray Tracer Challenge CLI

Usage: raytracer [OPTIONS] --scene <FILE>

Options:
      --scene <FILE>        A yaml description of the scene to render
      --obj <FILE>          Optional obj models to add to the scene
      --ppm <FILE>          Optional ppm textures to use as material
      --dithering <PARAMS>  Add dithering effect to the final image [possible values: bayer2, bayer4, bayer8, bayer16, bayer-color]
      --out <OUT>           Optional output ppm file, defaults to stdout
  -h, --help                Print help

Examples

See comments in yaml scene files for information about how to get all resources (obj models, ppm textures) used in the examples commands.

Basic scene

The rendered scenes can be piped directly to ImageMagick or outputted to a file.

raytracer --scene samples/scenes/basic_scene.yaml | magick display

basic-scene

Books's cover

raytracer --scene samples/scenes/cover.yaml --out cover.ppm

cover

Spaceship model

raytracer --scene samples/scenes/space_ship.yaml \
          --obj samples/obj/space_ship.obj \
          --out space_ship.ppm

spaceship

Teapot and Spaceship models

Multiple obj models can be added/combined in a scene.

raytracer --scene samples/scenes/space_teapot.yaml \
          --obj samples/obj/space_ship.obj \
          --obj samples/obj/teapot_low.obj \
          --out space_teapot.ppm

space-teapot

Constructive Solid Geometry (CSG)

raytracer --scene samples/scenes/csg.yaml --out csg.ppm

csg

Soft shadows (Area Light)

raytracer --scene samples/scenes/soft_shadows.yaml --out soft_shadows.ppm

soft-shadows

Bounding Boxes - Dragons

Beware that rendering this scene will be quite long (about 45 minutes on my machine with 16 cores).

raytracer --scene samples/scenes/dragons.yaml \
          --obj samples/obj/dragon.obj \
          --out dragons.ppm

dragons

Texture Mapping - Patterns

raytracer --scene samples/scenes/checkered_cube.yaml --out checkered_cube.ppm

checkered-cube

checkered-sphere checkered-plane checkered-cylinder

Texture Mapping - Image

raytracer --scene samples/scenes/earth.yaml \
          --ppm samples/textures/earthmap1k.ppm \
          --out earth.ppm

earth

Texture Mapping - Skybox

raytracer --scene samples/scenes/skybox.yaml \
          --ppm samples/textures/negx.ppm \
          --ppm samples/textures/negy.ppm \
          --ppm samples/textures/negz.ppm \
          --ppm samples/textures/posx.ppm \
          --ppm samples/textures/posy.ppm \
          --ppm samples/textures/posz.ppm \
          --out skybox.ppm

skybox

About

The Ray Tracer Challenge in Rust


Languages

Language:Rust 100.0%