Why isnt sample all in default pt for cycles

Sampling all lights could be enabled in PT in cycles instead of having it exclusively in BPT which would eliminate the overhead of having to sample each shader with branched and should give a decent speed up in complex scenes with a lot of lights that dont need BPT to be clean

I doubt that it would help. It is needed in BPT, because you have less primary/camera rays. If you don’t do it, you would possibly undersample the direct lighting, so you would need more AA samples. What is contrary to what you want to achieve with BPT. But you have many camera rays in PT, so you would unnecessary sample the (not that noisy) direct lighting and would achieve a quite large slowdown without gaining much. I mean if you have 200 lights and 80 camera rays, you take 1600 direct light samples (if you sample all), or 80, if you don’t. But 80 aren’t enough, because you have 200 lights (and you need to sample every light that has an influence on the pixel at least once (if it has smooth shadows of course more)).
If you would activate it for PT with 200 lights and 2000 camera rays, you would take 400.000 direct light samples (per pixel). The only noise in direct lighting comes from area lights/soft shadows, so you would kill your performance to gain a little bit on the soft shadows.

Yes but in our current scenes with around 500 point lights we MUST use BPT to even get clean results under 10k samples

Maybe something like “sample n random lights” would be better than “sample all”. You are right, this is a problem, but the sample all solution is completely overkill for PT in my opinion. But sampling for example 10 lights instead of 1 per sample would probably help a lot. There are some papers/algorithms/or just ideas for selecting those lights better than random, for example weighted by their influence/light reaching that point, or by building some kind of “light influence” data structures that avoid randomly choosing lights that completely shadowed in a region (this makes sampling of course slower, needs precomputation time and memory, but helps when you have many lights that don’t overlap too much).
But I’m not a Blender developer and I don’t know exactly, what cycles is doing and sadly don’t have the time to try some approaches.

I don’t understand what you are talking about? Can you explain?

You just assume sampling all lights would be faster, but it would increase the cost of each individual sample massively. In regular path tracing, most path edges are not that valuable, yet you want to sample 500 lights at each and every vertex? You would get a cleaner result with less samples, but each sample would be much more expensive. With BPT at least you have some control over which paths are valuable.

I believe the idea of a “light BVH” has been thrown around to speed up light sampling, so that could be a solution to sampling many lights more efficiently.

The other question is, why do you need 500 point lights? If at least it was emissive faces, paths could hit the light without sampling it. Maybe the same is true for area lights, I don’t know (in Luxrender, it is).

Second that.

I know sample all is a hack and a very crappy one but it is one that is needed sometimes. Lukas is making some magic hopefully he will show that off soon to the public which makes sample all almost not needed

I know it is significantly slower per sample as well obviously I never assumed it was faster I assumed it was cleaner (which it is) I know 500 mesh lights with sample all is impossible to even do on GPU because it will kill your driver. I did assume it would be faster in PT vs BPT

Mesh lights will never ever produce a clean result under our circumstances. Basically we have many buildings and light is coming out of the windows and casting light on to the streets and other assets. Buuuut we still have to light the scene with a world and sun lamps. If we dont use sample all lights the point lights take so much priority our lights meant for lighting the scene well never get sampled.

If we turned the lights on in all of our buildings (At the moment they are randomly turned on and off) we would have over 2000 lights… Which we might have to do if we do night scenes. We cannot compromise on quality we just have to brute force it the best way possible and thats with sample all (at the moment). We have very complex shader trees that dont necessarily need BPT to resolve but using BPT does cause a slow down because of the complexity of the shaders.

All im asking is why isnt sample all lights in PT mode without the overhead of BPT

I know there are many proper more efficient ways to do it but someone would have to do it… I assume adding this hack to PT is somewhat simple vs light bvh / heuristics

I still don’t think that it would be faster than BPT, because you will have a bad sampling balance between direct light and the GI effects (reflections, etc.). It would basically act like BPT, if you activate sample all lights and set the sample for Diffuse, Glossy, etc to 1 and then crank up the AA samples massively. It would be a little bit faster than that because of the easier shader evaluation but have even a little bit more noise in the GI part (because it would use one sample for either Diffuse, Specular, etc. instead of one for each). You would have almost none noise in the direct lighting after lets say 10 samples, but a lot of noise in the GI (because 10 samples is not enough for GI). You basically waste a lot of time sampling the direct light and gain almost none loss in noise, because you need to double the amount of samples to half the error/noise.
But you are right, it should be straigth forward to implement. I don’t know the blender code but in mitsuba or pbrt it would need a change in maybe 5-10 lines of code (at least without exposing the settings). It is a quite difficult scene for Cycles and choosing a random light is almost senseless, if you have many lights with almost no influence.
Weighting the light sampling by the light’s influence should be one way to go for this, but that is quite difficult to implement and costs quite some performance. You would need to iterate at least once over all lights for each sample and calculate their possible influence and then choose a light according to this information. I don’t even know if that is feasible on GPU. Maybe light BVHs would be a solution…
But all these techniques have their performance cost. BPT would perform better, unless your shaders are really extremely complex (but I guess yours are). I guess that’s the point where Cycles isn’t quite production ready… Maybe because it doesn’t have enough users that build such extreme projects as you are. I think it is a good thing, to bring the dev’s attention to this.

And I’m quite tempted now to try your proposed hack. Maybe I’ll do it in the next days, if I find some spare time.

Without lukas most of what we do wouldnt be possible. Hopefully after a few more of our projects blender will be nearly on par with with most production software