Prerequisites
Platform requirements
x86_64-unknown-linux-gnu
(1)x86_64-unknown-linux-musl
Build requirements
-
for users install
cargo
stable latest build system (seerust-toolchain.toml
for stable version) -
for devels install
rustup
that will automatically provision the correct toolchainFor unit tests coverage
cargo-tarpaulin
is required as additional componentThere is an handy
makefile
useful to:- preview documentation built with
rustdoc
- preview html code coverage analysis created with
cargo-tarpaulin
- create demo animations
- preview documentation built with
Installation
From binary
Install from binary:
## Install the latest version `gnu` variant in `~/.rustracer/bin`
|
## Install the `0.4.0` version `musl` variant in `~/.rustracer/bin`
|
From source
Install from source code, a template could be:
## Install the latest version using `Cargo.lock` in `~/.rustracer/bin`
## Install the `0.4.0` version in `~/.rustracer/bin`
Usage
rustracer
subcommands | description |
---|---|
rustracer-convert | convert an hdr image into ldr image |
rustracer-demo | render a simple demo scene (example purpose) |
rustracer-render | render a scene from file (yaml formatted) |
rustracer-completion | generate shell completion script (hidden) |
a multi-threaded raytracer in pure rust
Usage: rustracer <COMMAND>
Commands:
convert Convert HDR (pfm) image to LDR (ff|png) image
demo Render a demo scene (hard-coded in main)
render Render a scene from file (yaml formatted)
Options:
-h, --help Print help
-V, --version Print version
rustracer-convert
Convert a pfm file to png:
Convert HDR (pfm) image to LDR (ff|png) image
Usage: rustracer convert [OPTIONS] <HDR> <LDR>
Arguments:
<HDR> Input pfm image
<LDR> Output image [possible formats: ff, png]
Options:
-v, --verbose Print stdout information
-f, --factor <FACTOR> Normalization factor [default: 1.0]
-g, --gamma <GAMMA> Gamma parameter [default: 1.0]
-h, --help Print help (see more with '--help')
-V, --version Print version
rustracer-demo
Rendering demo scene:
demo scene 360 degree (see makefile
):
Render a demo scene (hard-coded in main)
Usage: rustracer demo [OPTIONS] <OUTPUT>
Arguments:
<OUTPUT> Output image [possible formats: ff, png]
Options:
-v, --verbose Print stdout information
--output-pfm Output also hdr image
--orthogonal Use orthogonal camera instead of perspective camera
--width <WIDTH> Image width [default: 640]
--height <HEIGHT> Image height [default: 480]
--angle-deg <ANGLE_DEG> View angle (in degrees) [default: 0.0]
-f, --factor <FACTOR> Normalization factor [default: 1.0]
-g, --gamma <GAMMA> Gamma parameter [default: 1.0]
-a, --algorithm <ALGORITHM> Rendering algorithm [default: pathtracer] [possible values: onoff, flat, pathtracer]
-n, --num-of-rays <NUM_OF_RAYS> Number of rays [default: 10]
-m, --max-depth <MAX_DEPTH> Maximum depth [default: 3]
--init-state <INIT_STATE> Initial random seed (positive number) [default: 42]
--init-seq <INIT_SEQ> Identifier of the random sequence (positive number) [default: 54]
--anti-aliasing <ANTI_ALIASING> Anti-aliasing level [default: 1]
-h, --help Print help (see more with '--help')
-V, --version Print version
rustracer-render
Rendering demo scene from scene file examples/demo.yml
:
you can use this example scene to learn how to write your custom scene, ready to be rendered!
But let's unleash the power of a scene encoded in data-serialization language such as yaml
Well repetitive scenes could be nightmare to be written, but for these (and more) there is cue
Let's try to render a 3D fractal, a sphere-flake, but without manually write a yaml scene file
we can automatic generate it from examples/flake.cue
|
so with this trick we've been able to condense a scene info from 2750 to 92 lines, x30 shrink! 😎
and the generated flake.yml
can be simple parsed
Render a scene from file (yaml formatted)
Usage: rustracer render [OPTIONS] <INPUT> <OUTPUT>
Arguments:
<INPUT> Input scene file
<OUTPUT> Output image [possible formats: ff, png]
Options:
-v, --verbose Print stdout information
--output-pfm Output also hdr image
--width <WIDTH> Image width [default: 640]
--height <HEIGHT> Image height [default: 480]
--angle-deg <ANGLE_DEG> View angle (in degrees) [default: 0.0]
-f, --factor <FACTOR> Normalization factor [default: 1.0]
-g, --gamma <GAMMA> Gamma parameter [default: 1.0]
-a, --algorithm <ALGORITHM> Rendering algorithm [default: pathtracer] [possible values: onoff, flat, pathtracer]
-n, --num-of-rays <NUM_OF_RAYS> Number of rays [default: 10]
-m, --max-depth <MAX_DEPTH> Maximum depth [default: 3]
--init-state <INIT_STATE> Initial random seed (positive number) [default: 42]
--init-seq <INIT_SEQ> Identifier of the random sequence (positive number) [default: 54]
--anti-aliasing <ANTI_ALIASING> Anti-aliasing level [default: 1]
-h, --help Print help (see more with '--help')
-V, --version Print version
rustracer-completion
Simple generate completion script for bash
shell (same for fish
and zsh
):
Generate shell completion script
Usage: rustracer completion [OPTIONS] <SHELL>
Arguments:
<SHELL> Shell to generate script for [possible values: bash, fish, zsh]
Options:
-o, --output <OUTPUT> Specify output script file
-h, --help Print help (see more with '--help')
-V, --version Print version
Acknowledgements
- pytracer - a simple raytracer in pure Python