nvpro-samples / nvpro_core

shared source code and resources needed for the samples to run
Apache License 2.0
494 stars 114 forks source link

Stochastic evaluation of BSDF lobes efficiency vs. the traditional "evaluate all BSDF lobes" approach #75

Open TomClabault opened 1 week ago

TomClabault commented 1 week ago

bsdfEvaluate() seems to evaluate only one lobe at a time.

https://github.com/nvpro-samples/nvpro_core/blob/master/nvvkhl/shaders/bsdf_functions.h#L887

From an efficiency standpoint, I wonder how that compares to the usual approach of evaluating all lobes for the given pair of directions as I've seen in most renderers.

Maybe that actually makes sense to do things this way if we're calling bsdfEvaluate() with a light direction that comes from bsdfSample()? The bsdfEvaluate() then ensures the evaluation of a lobe with a proper incident light direction matching the distribution of that lobe whereas evaluating the other lobes with that same sampled direction may not end up contributing much (although this depends on the lobe. The diffuse lobe may actually benefit from almost any sampled direction so maybe that lobe should always be evaluated?)

This is not really an issue with the implementation but rather a discussion, trying to learn from the best ;)

tigrazone commented 1 week ago

Maybe that actually makes sense to do things this way if we're calling bsdfEvaluate() with a light direction that comes from bsdfSample()?

renderer which use this library https://github.com/nvpro-samples/vk_gltf_renderer/blob/master/shaders/rt_common.h