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.raysample-files/sphereflake.raycan 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.bmpin the project root
- Compiling
- debug build:
cargo build - optimized release build:
cargo build --release - binaries in the
targetdirectory
- debug build:
Input files utilize a simplified version of the Rayshade 4.0 .ray file format.
Arguments
-ipath to the input file-opath and file name where the resulting image should be written- optional
- default output file format is BMP
- default write location is
render.bmpin the directory from the current directory - output file format is determined by extension.
.bmpfor BMP,.pngfor PNG,.jpegfor 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.jsonfile 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.jsonis 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_threadsoption 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 can be written by hand.
More complex classic benchmark input files can be generated with the Standard Procedural Databases
.rayfiles can be generated by specifying the-r 8flag.- Note: To compile on unix systems you'll need to replace references to
sscanf_s,sprint_s, andfopen_swithsscanf,sprintf, andfopen. Just follow the compiler errors. - Note: The project needs to be compiled with the C89 standard. Add
-ansito 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