Hi. I have an issue with SPPM I'd like to fix, it is the way buffer are normalized in Lux.
In SPPM I have two kind of contributions:
a) The contribution from the eyepass, it should be normalized per pixel
b) The contribution from the photonsampler. It should be normalized per number of samples (ie, photon)
My issue is that any contribution from eyepass and photonpass are taken into account for the normalization (because buffers share their normalization value. This is an issue because it means that the contribution from the photon pass is too much normalized)
It currently works on SPPM because of an ugly cheat and because We are storing in the SPPMRenderer some value which needs to be restored for film restart (or network rendering). Solving this issue will make the SPPM code cleaner and helps network rendering and film restart.
So I want to be able to normalize buffer only by the number of contribution associated to the buffer.
I have a working patch (I may commit it in a separate branch soon), but I have some question I wanted to discuss with you first :
- a) Is there a need for that sharing of number of sample ? There is only one other integrator which use more than one buffer, it is the bidirectional one. jeanphi, can you confirm me that this sharing of number of sample is used in the bidirectional, or this feature is not used ? (It will dramatically improve the code if not, but by the way, I currently have a code which work for both)
- b) API design. Currently we add a sample with AddSample. The default implementation is:
void Sampler::AddSample(const Sample &sample)
{
sample.contribBuffer->AddSampleCount(1.f);
for (u_int i = 0; i < sample.contributions.size(); ++i)
sample.contribBuffer->Add(sample.contributions[i], 1.f);
sample.contributions.clear();
}
I have currently change the AddSampleCount method to take a second argument, buffer_id. I'm planning on using -1 as a wilcard (ie, every buffer) and 0..N as a buffer number. And using AddSample(sample, buffer_id).
So for me in sppm it means that a sample from the eye should be added as AddSample(sample, eye_buffer_id), and a sample from the photon pass should be added as AddSample(sample, photon_buffer_id).
But I'm wondering, the contribution already stores the indice of the associated buffer, so two use cases:
a) We suppose that one day we'll need to add a sample with contribution to different buffer, but only changing the count of one of them ?
b) We suppose the same think, but we want to be able to change the count of just some buffer at once (so AddSampleCount should take a vector as parameter)
c) It will never happen and we can refactor Contribution to remove the buffer field which may earn some memory (not a lot I guess) at a cost of a really hard refactoring.
Ideas ?
