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
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):
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:
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:
> 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 ...