Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
aed46f1
Remove superfluous bounce_count param from try_hit_rec
bubba2k Sep 7, 2025
7285734
Implement iterative try_hit for BVH Mesh
bubba2k Sep 7, 2025
c7bab7b
Merge branch 'perf_mode' into bvh
bubba2k Sep 7, 2025
4f2938a
Remove debug flag for release profile
bubba2k Sep 7, 2025
3461d74
Add missing AABB check
bubba2k Sep 7, 2025
dc910e7
Make AABoundingBox::hit() ignore hits behind ray origin
bubba2k Sep 7, 2025
0074475
Add AABBoundingBox::dist()
bubba2k Sep 7, 2025
4f21360
Add accidentally removed AABB check
bubba2k Sep 7, 2025
fc32e08
Check for t_intervall in AABB dist/hit funcs
bubba2k Sep 7, 2025
be99c49
Update AABB hit and dist
bubba2k Sep 7, 2025
78922eb
Implement (buggy) ordered bvh query
bubba2k Sep 7, 2025
5205a7d
Do use t_interval min in AABB hit/dist funcs
bubba2k Sep 7, 2025
d1996d4
Compute and display min/max prim per leaf metric
bubba2k Sep 7, 2025
9efa52e
Remove unused import
bubba2k Sep 7, 2025
faffe29
Add ray_info struct
bubba2k Sep 12, 2025
03dc615
Let BVH query return more information
bubba2k Sep 21, 2025
70294c3
Add helper func to downcast f64 Vec3 to f32 Vec3
bubba2k Sep 21, 2025
4c6f2aa
Add Renderpass trait
bubba2k Sep 21, 2025
dc8d45f
Add generic render_region function
bubba2k Sep 22, 2025
78d4f99
Add dragon test model
bubba2k Sep 23, 2025
99d6912
Implement render with pass trait
bubba2k Sep 23, 2025
3ee4017
Remove dead singlepass/mutlipass code
bubba2k Sep 23, 2025
a1c5aaf
Remove unused import
bubba2k Sep 23, 2025
cf54b15
Save renderpasses with names
bubba2k Sep 23, 2025
e5c86f1
Rename RenderPass trait, add documentation
bubba2k Sep 24, 2025
d65f474
Implement BVHDebug pipeline
bubba2k Oct 3, 2025
900b84e
Add a few more low poly testing models
bubba2k Oct 5, 2025
5d5e9e9
Fix bug where AABBs _always_ included the coordinate system origin
bubba2k Oct 5, 2025
17aeb1d
Fix a few warnings
bubba2k Oct 5, 2025
bfaeb90
Cleanup postproc module
bubba2k Oct 5, 2025
ca34a68
Fix render time estimation
bubba2k Oct 5, 2025
69452df
Replace custom Interval struct with RangeInclusive from std lib
bubba2k Oct 5, 2025
8df9868
Unsilence dead code warnings
bubba2k Oct 5, 2025
511c4d3
Remove some dead code
bubba2k Oct 5, 2025
93b30e7
Remove more dead code
bubba2k Oct 5, 2025
f379a1d
Implement basic tonemapping, reimplement denoising
bubba2k Oct 5, 2025
372347d
Fix ordered traversal
bubba2k Oct 6, 2025
b9e3164
Small optimization: Cache node AABB dist in ordered traversal
bubba2k Oct 6, 2025
7ee7857
Use statically allocated stack for discovery
bubba2k Oct 6, 2025
aa21d45
Fix rotation of stanford dragon model
bubba2k Oct 21, 2025
9394efa
Add overcast sky environment map
bubba2k Oct 21, 2025
c215afe
Rescale merged sponza model
bubba2k Oct 21, 2025
ef6d84c
Run script tweak
bubba2k Oct 21, 2025
9478b1c
Reduce number of evaluated candidates during SAH best split search
bubba2k Oct 21, 2025
2733532
Create heatmaps of primitive checks
bubba2k Oct 28, 2025
46e5ff6
Add a new 3D model and a new environment map
bubba2k Oct 28, 2025
190706f
Add a utility function to dump render stats to a txt file
bubba2k Oct 28, 2025
93b61ea
Add README
bubba2k Oct 28, 2025
d2207e7
Include example renders
bubba2k Oct 30, 2025
74eac8b
Update README with example renders
bubba2k Oct 30, 2025
bf42aa7
Add exposure attenuation parameter for environment map backgrounds
bubba2k Oct 30, 2025
16f4bd4
Update run script
bubba2k Oct 30, 2025
8b6b7c7
Add scene setup helper functions
bubba2k Oct 30, 2025
f1ada92
Increase number of evaluated split candidates in SAH-assisted BVH con…
bubba2k Oct 30, 2025
4cd81ab
Update README
bubba2k Oct 30, 2025
5c19ff8
Update BVH visualization description in README
bubba2k Oct 30, 2025
622aed3
Update README
bubba2k Oct 30, 2025
bd0b3ae
Fix whitespace in README
bubba2k Oct 30, 2025
fb65cb7
Update project description
bubba2k Oct 30, 2025
df447f8
Fix cargo run command syntax in README
bubba2k Oct 30, 2025
397f80c
Update README
bubba2k Nov 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ name = "weekend_of_rays"
version = "0.1.0"
edition = "2024"

[profile.release]
debug = true

[dependencies]
chrono = "0.4.41"
fastrand = "2.3.0"
Expand Down
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Softpasses

Physically based software pathtracer

## Current features

- Support for multiple types of primitives (Spheres, Triangles, Parallelograms, Parallelipeds)
- Handrolled BVH2 implementation (SAH construction, ordered traversal)
- Triangle mesh loading (.obj format)
- Materials: Lambertian diffuse BRDF, basic glass BSDF and metallic BRDF
- Environment map defined lighting (.hdr, .exr)
- Thin lens camera model with DOF simulation
- Generation of auxiliary passes (albedo, normal) for denoising
- Generation of BVH debug and visualization passes (node intersects, primitive checks)
- Multithreaded, tiled rendering
- Denoising through Intel OpenImageDenoise integration
- Basic filmic tonemapping

## Renders

All images were rendered and postprocessed exclusively within this software on an i7U quadcore @ 3.1 GHz processor.

1080p, 512 spp, ~870k triangles @ ~1 MRays/s in 17:45 minutes
![Final render of the Stanford dragon with environment map lighting and DoF simulation](renders/stanford_dragon_full_001/beauty_tonemapped.png)

1080p, 1024 spp, ~5k primitives @ ~0.7 MRays/s in 49:40 minutes (no denoising/tonemapping)
![Render of Stanford bunny without denoising or tonemapping](renders/stanford_bunny_shelf_001/color.png)

### Auxiliary and Intermediate passes
In addition to the final render, Softpasses also produces and outputs a collection of auxiliary/intermediate passes.

#### Color pass
The raw computed HDR luminance data before denoising, tonemapping and gamma correction.
![Linear HDR data of the Stanford dragon render](renders/stanford_dragon_full_001/color.png)

#### Albedo and Normal passes
Describing the diffuse reflection and surface normal properties of the scene, they serve as common auxiliary inputs for denoisers, and are fed to the Intel OIDN library during the postprocessing stage.
![Albedo data of the Stanford dragon scene](renders/stanford_dragon_full_001/albedo.png)
![Surface normal data of the Stanford dragon scene](renders/stanford_dragon_full_001/normal.png)

#### BVH visualization
BVH visualization passes such as **Average number of node checks per pixel** and **Average number of primitive checks per pixel** aid in profiling and debugging the acceleration structure. Both heatmapped (ie normalized to 0-1, as seen below) and raw HDR versions are supplied.
![Average number of node AABB checks / pixel in the Stanford dragon scene](renders/stanford_dragon_full_001/aabb_checks_heatmapped.png)
![Average number of primitve checks / pixel in the Stanford dragon scene](renders/stanford_dragon_full_001/primitive_checks_heatmapped.png)


## Planned features

- Environment map importance sampling
(Contrast-rich environment maps lead to very noisy images currently. Ideally take advantage of MIS to importance sample both the environment map and materials.)
- Support for texture mapping on models (eg diffuse, roughness, metallic maps)
- Implementation of a physically based general-purpose BSDF, eg the Burley BSDF
- Support for a user friendly scene description format, like glTF or USD

## Building and Usage

Prerequisites:
- Have [Intel OpenImageDenoise](https://github.com/RenderKit/oidn) library installed

Then build in release mode (debug builds are *very* slow):
```cargo build --release```

Run the following to render the current scene:
```cargo run --release -- <output directory>```

There is no proper, user friendly way to do so at the moment, but you can play around with the scene and render settings inside `main`.

## References

A practical introduction to the basics of raytracing, which this project was originally loosely based on:
[Peter Shirley - Ray Tracing in One Weekend](https://raytracing.github.io/books/RayTracingInOneWeekend.html)

For all your PBR needs:
[Pharr, Jakob, Humphreys - Physically Based Rendering: From Theory to Implementation](https://www.pbrt.org/)

A great tutorial on building BVHs:
[Bikker - How to Build a BVH (Article series)](https://jacco.ompf2.com/2022/04/13/how-to-build-a-bvh-part-1-basics/)

Arguably more of historical importance, these two papers were among the first to discuss the usage of BVHs in Raytracing. Regardless, they give a good overview of the fundamental problem at hand:
[Kay, Kajiya (1986) - Ray Tracing Complex Scenes](https://papers.cumincad.org/data/works/att/67d2.content.pdf?utm_source=chatgpt.com)
[Goldsmith, Salmon (1987) - Automatic Creation of Object Hierarchies for Ray Tracing](https://doi.org/10.1109/MCG.1987.276983)

Binary file added assets/hdri/apartmentbalcony_4k.exr
Binary file not shown.
Binary file added assets/hdri/overcastpuresky_4k.hdr
Binary file not shown.
24 changes: 24 additions & 0 deletions assets/models/cube.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Blender 4.5.3 LTS
# www.blender.org
o Cube
v 0.500000 1.000000 -0.500000
v 0.500000 0.000000 -0.500000
v 0.500000 1.000000 0.500000
v 0.500000 0.000000 0.500000
v -0.500000 1.000000 -0.500000
v -0.500000 0.000000 -0.500000
v -0.500000 1.000000 0.500000
v -0.500000 0.000000 0.500000
vn -0.0000 1.0000 -0.0000
vn -0.0000 -0.0000 1.0000
vn -1.0000 -0.0000 -0.0000
vn -0.0000 -1.0000 -0.0000
vn 1.0000 -0.0000 -0.0000
vn -0.0000 -0.0000 -1.0000
s 0
f 1//1 5//1 7//1 3//1
f 4//2 3//2 7//2 8//2
f 8//3 7//3 5//3 6//3
f 6//4 2//4 4//4 8//4
f 2//5 1//5 3//5 4//5
f 6//6 5//6 1//6 2//6
Loading