[Bf-cycles] Lightprobe importance sampling

Mike Farnsworth mike.farnsworth at gmail.com
Sat Dec 31 17:45:56 CET 2011

> I'm not familiar with the terms marginal/conditional CDF, but my
> impression was that this method used a CDF as already in
> light_distribution for mesh lights and regular lights? My original
> idea was to stuff all light sources in one big CDF and always sample
> that, but maybe it's not possible.

I couldn't figure out at first glance how to keep it in the light
distribution CDF.  The env importance sampling works in two stages:
first use randu to sample the marginal distribution with binary search
(visualize it as the CDF for choosing a column in the env map), and
then use randv to sample the conditional distribution with binary
search (visualize the conditionals as a CDF for each column, to select
a pixel).

It's because of the two-stage thing that I didn't think it could fit
in the regular light distribution.  I might be able to combine the two
in a novel way so I can put it back into light_distribution, but
typically there are quite a few values in there (1024 x 1024).  To
reduce memory usage I used a float2 that had as the first component
the original brightness, and as the second component the actual  CDF
value, rather than the float4 used in light_distribution.

> Sampling the background with at a fixed resolution should be fine yes.
> Ray differentials aren't used properly by all textures yet, but once
> that is added it should work quite well for shaders that are higher
> frequency than this resolution too.
> I've refactored the code a bit now in svn to shader evaluation for
> this possible, is a bit tricky with kernel/device changes. Attached a
> patch that will dump the background to an image as an example.

Thanks!  I'll try that out today.  Last night I just iterated the
shader graph looking for environment image nodes, then used OIIO to
load it and iterate it quickly to build the map, but that is pretty
hackish and restrictive.


More information about the Bf-cycles mailing list