I'm implementing ERPT-style energy redistribution of primary samples within a pathtracer. Specifically, to improve the sampling of defocused areas.
The core algorithm does two things:
If sample luminance is higher than threshold, I redistribute the sample energy over many backwards fired rays. This is stored in a framebuffer. The result of this is super clean!
I also store all non-redistributed samples in a separate framebuffer.
My question is about how I should recombine these two framebuffers. Which probabilities should I be using? I've tried a variety of approaches but none of them have worked perfectly. I cannot just remove the samples-to-be-redistributed and sum the redistributed samples on top. This results in discontinuities. I think I need to be using a certain weighting.
An example scenario is as follows:
Pathtraced result I start with:
Take a selection of the samples to redistribute:
Redistributing these high intensity samples in separate framebuffer:
How can I re-combine the redistributed & unredistributed results?
Any help would be appreciated!