A simple cross-platform, still image raytracer implementing a phong shading model and five-bounce reflections with attenuation.
- Clone the project
- Render with a one-liner from the project directory:
cargo run --release -- -i sample-files/sphereflake.ray
sample-files/sphereflake.ray
can be replaced with the path to any file- This will render the sphereflake.ray sample input file included in this repo.
- The resulting image will be written in BMP format to
render.bmp
in the project root
- Compiling
- debug build:
cargo build
- optimized release build:
cargo build --release
- binaries in the
target
directory
- debug build:
Input files utilize a simplified version of the Rayshade 4.0 .ray
file format.
Arguments
-i
path to the input file-o
path and file name where the resulting image should be written- optional
- default output file format is BMP
- default write location is
render.bmp
in the directory from the current directory - output file format is determined by extension.
.bmp
for BMP,.png
for PNG,.jpeg
for JPEG, etc.
Sample run command (using windows paths for inclusivity):
.\rusty-rays -i .\input-file-name.ray -o .\Pictures\renders\output-file-name.png
- The application will create a log folder in the users cache directory
- win:
C:\Users\<user>\AppData\Local\rusty-rays\logs\
- linux:
$HOME/.cache/rusty-rays/logs/
- mac:
$HOME/Libary/Caches/rusty-rays/logs/
- win:
- The logger will default to console only logging if unable to create the log folder or file
- The application will create a
config.json5
file in the users config directory- win:
C:\Users\<user>\AppData\Roaming\rusty-rays\
- linux:
$HOME/.config/rusty-rays/
- mac:
$HOME/Library/Application Support/rusty-rays/
- win:
- If
config.json5
is inaccessible, the application will use its internal default config - If a value is missing from the config or null, the default internal config value will be used
- If
max_render_threads
option is set to a value less than 1 or greater than the number of physical cores, it will default to the number of physical cores.
Simple input files cna be written by hand.
More complex classic benchmark input files can be generated with the Standard Procedural Databases
.ray
files can be generated by specifying the-r 8
flag.- Note: To compile on unix systems you'll need to replace references to
sscanf_s
,sprint_s
, andfopen_s
withsscanf
,sprintf
, andfopen
. Just follow the compiler errors. - Note: The project needs to be compiled with the C89 standard. Add
-ansi
to the compiler arguments in the MakeFile (line 4).
You can find a quick reference sheet on the Rayshade file format here.
The original Rayshade 4.0 (Not Rayshader) program for which the rayshade file format was created, can be found here.
The Rayshade 4.0 renderer has capabilities and a feature set similar to that of blender so by extension the .ray
input specification is extensive.
Rusty-Rays can parse and render the bare-bone basics of the specification. Below is a rundown of what's supported
- up
- eyep
- lookp
- fov
- screen
- background
- surface
- diffuse
- ambient
- specular
- specpow
- reflect
- sphere
- polygon
- triangle
- light