appleseedhq / appleseed

A modern open source rendering engine for animation and visual effects
https://appleseedhq.net/
MIT License
2.19k stars 329 forks source link

Area lights with few polygons are very noisy when other area lights with many polygons are present in the scene #449

Open dictoon opened 10 years ago

dictoon commented 10 years ago

Sampling a mixture of area lights where some have many polygons and some have few results in massive noise for those that have few polygons.

The solution is to allocate the same number of samples to all lights, regardless of the number of polygons they have (it is then possible to allocate more samples to lights contributing the most noise by adjusting their importance multiplier).

dictoon commented 10 years ago

Some details:

Currently, to sample so-called mesh lights (i.e. mesh objects with a light-emitting material), we proceed as follow:

Before rendering:

  1. Collect triangles from all light-emitting objects into one big array.
  2. Build a Cumulative Distribution Function (CDF) to efficiently sample this array of light-emitting triangles.

During rendering, when a light sample is needed:

  1. Pick a random triangle using the CDF.
  2. Pick a random point on that triangle.

The problem with this very naïve approach is when you mix area lights with few triangles and area lights with many triangles. The algorithm above will allocate many more samples to area lights with few triangles, resulting in a lot of noise from area lights with many triangles.

A simple fix is to group triangles by area lights, and first pick a random area light, then pick a random triangle on that area light (and finally pick a random point on that triangle, but that part doesn't change).

I believe all the changes should happen in lightsampler.cpp (and the corresponding header file).

Narann commented 10 years ago

Is every triangle should have a factor depending on its surface area (or energy)?

dictoon commented 10 years ago

In the current implementation, the probability of picking a given triangle is already proportional to its surface area. We could however pick triangles according to their "non-occluded contribution", i.e. taking their emission power into account. However Nathan's BVH-guided sampling approach is more general and I think that's where we should be heading next.