Skip to content

wwills2/rusty-rays

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rusty Rays

A simple cross-platform, still image raytracer implementing a phong shading model and five-bounce reflections with attenuation.

Quick Start

  • 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

Usage

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

Logging

  • 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/
  • The logger will default to console only logging if unable to create the log folder or file

Config

  • 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/
  • 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.

Generating Additional Input Files

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, and fopen_s with sscanf, sprintf, and fopen. 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).

Simplified Rayshade 4.0 File Format

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

Supported Rayshade Keywords:

  • up
  • eyep
  • lookp
  • fov
  • screen
  • background
  • surface
    • diffuse
    • ambient
    • specular
    • specpow
    • reflect
  • sphere
  • polygon
  • triangle
  • light

About

A simple CPU raytracer written in rust

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages