Skip to content

ben-hansske/bsdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bsdf

A rust implementation of BSDFs for pathtracing

This crate is designed to cover a wide range of materials in a path tracer. Furthermore, methods for importance sampling are provided.

Design Decisions

NOTE: This crate is pretty much in alpha state. Therefore a lot of the following things may or may not change in the future

The code is geared towards pathtracing. Direct lighting techniques such as image based lighting or polygonal lights are not implemented.

Lighting calculations are done exclusively in f64s. This is because BSDFs can be extremely spiky. Using f64 has helped reducing numerical errors. However, material parameters are stored as f32s for a minimal memory footprint. All materials can be constructed on the fly, since they (currently) do not rely on precomputed data. At some point in the future we might address this with generic implementations over f32 and f64.

BSDFs are computed in a local space. That means, the surface is assumed to be the xy-plane and the z-vector is assumed to be the normal. Therefore incident and exitant vectors must be rotated before or after evaluation of the BSDF.

The |omega_i.dot(n)|, |cos theta_i| or |omega_i.z| are not part of the BSDF. The user is responsible for multiplying them in if necessary (almost always). Pdf's on the other hand, are meant for high quality importance sampling. Therefore, they try to take this cosine term into account when generating samples.

sample_... functions are deterministic. That means you are responsible for generate f64 in the range of 0.0..1.0. This allows you to control the sampling process and the random generator or low discrepancy sequence in use. These random floats are either passed as a Vec3d or Vec2d

This crate is built on glam for a simple but fast vector math library at the core.

Examples

The pathtracer example shows you how to integrate this crate into a simple forward pathtracer. The code is kept very close to Raytracing in a Weekend to make it easy to understand.

References

A lot of pathtracing literature went into this. Here are the most influential papers and other sources I have used:

About

A rust implementation of BSDFs for pathtracing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages