Skip to main content

Crate solstrale

Crate solstrale 

Source
Expand description

A WGPU-based GPU Monte Carlo path tracing library, with features like:

§Core Engine

  • Global illumination
  • Caustics
  • Reflection
  • Refraction
  • Soft shadows
  • Bump mapping
  • Light attenuation

§Performance & Loading

  • Loading of obj models with included materials
  • Multithreaded BVH creation using Rayon to greatly speed up rendering

§Post-Processing

Custom GPU-accelerated filters implemented as compute shaders via WGPU:

  • Bloom filter
  • Saturation filter

§Example:

let camera = CameraConfig {
    vertical_fov_degrees: 20.,
    aperture_size: 0.1,
    look_from: Vec3::new(0., 0., 4.),
    look_at: Vec3::new(0., 0., 0.),
    up: Vec3::new(0., 1., 0.),
};
let mut world: Vec<Hittables> = Vec::new();
let yellow = Lambertian::new(SolidColor::new(1., 1., 0.).into(), None);
let light = DiffuseLight::new(10., 10., 10., None);
world.push(Sphere::new(Vec3::new(0., 0., 0.), 0.5, yellow.into()).into());

let scene = Scene {
    world: Bvh::new(world).into(),
    camera,
    background_color: Vec3::new(0.2, 0.3, 0.5),
    render_config: RenderConfig::default(),
};

let (device, queue) = get_wgpu_device_and_queue();

let (output_sender, output_receiver) = channel();
let (_, camera_config_receiver) = channel();
let (_, abort_receiver) = channel();

thread::spawn(move || {
    ray_trace(scene, &output_sender, &camera_config_receiver, &abort_receiver, &device, &queue, false).unwrap();
});

for render_output in output_receiver {
    let _buffer = render_output.output_buffer;
}

§Example output

bedroom2 conference happy sponza-bump2

§Credits

The ray tracing is inspired by the excellent Ray Tracing in One Weekend Book Series by Peter Shirley

Modules§

camera
Provides a camera used by raytracer to shoot rays into the scene
geo
Basic geometric constructs
hittable
Objects that are hittable by rays shot by the ray tracer. Some of these hittable objects are containers for other objects
loader
Module containing object model loaders
material
Materials to be applied to hittable objects
post
Post processors for applying effects to the raw rendered image
renderer
The renderer takes a Scene as input, renders it and reports RenderProgress
util
Various small helpers used by the raytracer

Macros§

combine_aabbs
Combines the given Aabb arguments into a single Aabb encapsulating all

Functions§

ray_trace
Executes the ray tracing with the given Scene and reports RenderProgress on the output Sender. Listens to abort Receiver for aborting a started ray trace operation