7 releases

0.2.6 Apr 24, 2023
0.2.5 Apr 17, 2023

#4 in Rendering engine

48 downloads per month

MIT license

160KB
3.5K SLoC

Lumo

crates.io docs.rs Coverage

Lumo is a CPU based multithreaded rendering engine. Made with the goal of learning Rust and physically based rendering :) The renderer is designed to be as modular as possible such that adding new features or algorithms is straightforward.

Features

Usage

Once the repository is cloned, the examples/ folder contains scenes. To run the hello_sphere.rs example execute the command:

cargo run --example hello_sphere

The renderer can be configured either through its setter methods or partially through the CLI:

Usage: hello_sphere [-s <samples>] [-t <threads>] [-d] [-b]

Optional CLI configuration of renderer. Renderer setter methods have priority.

Options:
  -s, --samples     number of samples per pixel (defaults to 1)
  -t, --threads     number of threads used (defaults to all)
  -d, --direct      use direct light integrator instead of path tracing.
  -b, --bdpt        use bidirectional path tracing instead of path tracing.
  --help            display usage information

Using the API

The hello_sphere.rs example is written as follows:

use glam::DVec3;
use lumo::tracer::*;
use lumo::*;

fn main() -> Result<(), png::EncodingError> {
    let camera = Camera::default(1280, 720);
    let mut scene = Scene::default();

    scene.add(Plane::new(
        DVec3::NEG_Y,
        DVec3::Y,
        Material::diffuse(Texture::Solid(srgb_to_linear(190, 200, 210))),
    ));

    scene.add_light(Sphere::new(
        8.0 * DVec3::Y + 1.5 * DVec3::NEG_Z,
        4.0,
        Material::Light(Texture::Solid(srgb_to_linear(255, 255, 255))),
    ));

    scene.add(
        Sphere::new(
            DVec3::ZERO,
            1.0,
            Material::diffuse(Texture::Solid(srgb_to_linear(0, 0, 255))),
        )
        .scale(0.3, 0.3, 0.3)
        .translate(0.0, -0.7, -1.5),
    );

    let mut renderer = Renderer::new(scene, camera);
    renderer.set_samples(36);
    renderer.render().save("hello.png")
}

References

Bust of Nefertiti Cornell box Stanford dragon Circle of spheres

Dependencies

~12–18MB
~373K SLoC