A rust ray tracer with lua based modelling
Switch branches/tags
Nothing to show
Clone or download

README.md

lucis

Lucis is a basic ray tracer written in rust. Scenes are created using lua scripting, based off primitive types or meshes, and manipulated using hierarchical affine transformations (scale, rotate, translate). Scene modelling examples can be found in the scene directory and example renders can be found in render.

Features

  • Lua bindings for scene modelling (see Scripting)
  • Hierarchical Modelling
  • Sphere, Cube, Cone, and Cylinder Primitive Types
  • Meshes using obj format (only supports triangle faces)
  • Bounding volumes on meshes for improved performance
  • Phong Illumination
  • Shadow rays
  • Soft shadows using spherical light sources
  • Texture mapping for primitives
  • Multithreaded rendering
  • Volumetric objects with fog and lighting effects
  • Generated background scene behind the render
  • Animation rendering (can be done through lua scripts)

TODO List

  • Adaptive Supersampling
  • Spacial partitioning of the hierarchical scene structure for improved performance
  • Phong shading for meshes
  • Texture mapping for meshes
  • Bump mapping
  • Reflections

Scripting

Object Creation

Command Description
rt.node(name) Create a new hierarchical node with the name name
rt.sphere(name) Create a sphere node centered at (0,0,0) with radius 1 and name name
rt.cube(name) Create a cube node with corners (0,0,0), (1,1,1) and name name
rt.cone(name) Create a cone node with base (0,0,0), radius 1, height 1 and name name
rt.mesh(name, file_name) Create a mesh node from file file_name and name name
rt.material(d, s, p) Create a phong material with diffuse constants d, spectral s and shininess p
rt.light(c, pos, f) Create a new light with color c, position pos, falloff f
rt.print(node) Print a node (and all of its children) to standard out
rt.render()

Node Manipulation

Command Description
node:translate(x, y, z) Translate node by (x, y, z)
node:scale(x, y, z) Scale node by (x, y, z)
node:rotate(axis, degrees) Rotate node on axis axis by degrees degrees
node:add_child(child) Copy the node child as a child to node

Light Manipulation

By default, lights act as a point light meaning they will only generate hard shadows. You can can modify the light to act a soft light

Command Description
light:set_soft(radius, samples) Set a light to be a soft light with radius radius and samples light samples.

Usage

Clone to repository and run cargo build --release. A binary will be built at target/release/lucis. The program can be ran as lucis <file_name> where file_name is the lua file you would like to run and lucis is the path to the binary. For example, try lucis soft_shadows.lua.