wahn / rs_pbrt

Rust crate to implement a counterpart to the PBRT book's (3rd edition) C++ code. See also https://www.rs-pbrt.org/about ...

Home Page:https://www.rs-pbrt.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement SubsurfaceMaterial

wahn opened this issue · comments

This is how the C++ code renders subsurface scattering:

> cd ~/Graphics/Rendering/PBRT/pbrt-v3-scenes/subsurface
> ~/builds/pbrt/release/pbrt f15-7.pbrt

f15-7

We have to implement the Rust counterpart:

> pwd
/mill3d/users/jan/Graphics/Rendering/PBRT/pbrt-v3-scenes/sssdragon
> rg subsurface
dragon_250.pbrt
26:    Material "subsurface" 

f15-7.pbrt
25:    Material "subsurface" 

dragon_10.pbrt
26:    Material "subsurface" 

dragon_50.pbrt
26:    Material "subsurface" 

Don't forget to execute the last loop in compute_beam_diffusion_bssrdf() in parallel:

pub fn compute_beam_diffusion_bssrdf(g: Float, eta: Float, t: &mut BSSRDFTable) {
...
    // ParallelFor([&](int i) {
    for i in 0..t.n_rho_samples as usize {
           // TODO: execute in parallel
...
    }
    // }, t.n_rho_samples);
}

This is how Rust renders the same scene (after commit b9c343a):

pbrt_50pc

I reduced the pixelsamples to 16, but there is something going wrong which needs debugging.

I think I found the bug. The wrong BSDF pointer was used to call bsdf.sample_f(). After commit 63516c2 we get:

pbrt

That still used only 16 pixelsamples, so lets render the full 8192 samples and compare vs. the C++ version, before closing the issue.

There is no difference between the images render by C++ vs. Rust:

sss_dragon

> imf_diff sss_dragon.png ~/Graphics/Rendering/PBRT/pbrt-v3-scenes/sssdragon/f15-7.png
sss_dragon.png /usr/people/jan/Graphics/Rendering/PBRT/pbrt-v3-scenes/sssdragon/f15-7.png: no differences.
== "sss_dragon.png" and "/usr/people/jan/Graphics/Rendering/PBRT/pbrt-v3-scenes/sssdragon/f15-7.png" are identical

Closing the issue ...