mitsuba-renderer / mitsuba2

Mitsuba 2: A Retargetable Forward and Inverse Renderer
Other
2.05k stars 266 forks source link

[❔ other question] Path Tracer - Scaling with bsdf and cos-theta value #594

Closed MaximilianBader closed 2 years ago

MaximilianBader commented 2 years ago

Summary

Problems to locate the scaling factor cos(theta) to compute the throughput in path.cpp.

Description

@GuillaumeZahnd and me are trying to relate the implementation of path.cpp with the theory provided in the PBR book (https://pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Path_Tracing). It is clear to us, that to update throughput for each surface interaction in a path iteration, it has to be scaled with bsdf_val*cos(theta) (https://github.com/mitsuba-renderer/mitsuba2/blob/master/src/integrators/path.cpp#L176). Checking the implementation, we concluded, the scaling with cos(theta) is already included in bsdf->sample(...) (line 177). When we look at the implementation roughDielectric::sample(), we can see the scaling in line 304 with dot(si.wi, m) (https://github.com/mitsuba-renderer/mitsuba2/blob/master/src/bsdfs/roughdielectric.cpp#L304) of the implementation. However, when checking the implementation SmoothDielectric::sample(), we were not able to locate where this scaling is executed (https://github.com/mitsuba-renderer/mitsuba2/blob/master/src/bsdfs/dielectric.cpp#L201).

Could you elaborate, how the scaling with cos(theta) is included in the computation? We're definitely missing something crucial here, but we have not been able to figure it out ourselves.

Thanks a lot in advance!

Speierers commented 2 years ago

Hi @MaximilianBader ,

I would suggest you take a close look at the bsdf.h header file. The docstring of the different methods clearly explain how this cosine term is handled in Mitsuba.

In some BSDF implementation you might not be able to find this term as it cancels out somehow in the math, hence doesn't need to be computed explicitly.

MaximilianBader commented 2 years ago

Hi @Speierers,

@GuillaumeZahnd and me would like to thank you for the quick response and the help you provided! We will check out the bsdf.h header and look into the theory again afterwards.