shaunbennett / lucis

A rust ray tracer with lua based modelling

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)

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

Volumetric Solids and Effects

Command Description
rt.volume_box(pos, size) Create a new volumetric box with position pos and size size
rt.volume_cone(pos, scale_y, rot) Create a new volumetric cone with position pos, y scaling scale_y, and rotation rot
rt.effect_fog(color) Create a fog effect with the fog color color
rt.effect_light(color) Create a light effect with the light color color
rt.effect_solid(color) Create a solid color effect with the color color
volume:set_effect(effect) Set the effect for the volumetric solid volume

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.

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

About

A rust ray tracer with lua based modelling

License:MIT License


Languages

Language:Rust 84.2%Language:Lua 15.7%Language:Shell 0.1%