User:Erikenglesson/GSoC 2018/Reports/WorkProduct/

Summary
This project implemented the Importance Sampling of Many Lights with Adaptive Tree Splitting paper by A. Conty and C. Kulla in Blender's path tracer Cycles. The paper provides a new strategy for path tracers to pick lights proportional to their estimated contribution. This is done by first constructing a light hierarchy as a pre-process which is then efficiently traversed during rendering to pick one or more lights.

Below is a summary of what has been done:
 * Implemented a Bounding Volume Hierarchy(BVH) with the new Surface Area Orientation Heuristic
 * Implemented a traversal algorithm that stochastically chooses which child node to go down to
 * Added support for all types of light sources
 * Restructured the Probability Distribution Function(PDF) calculations in Cycles to separate the PDF to pick a certain light and the PDF to pick a position on a light
 * Implemented the split traversal method
 * Added support for several lights per leaf node in the BVH
 * Added support for multiple importance sampling
 * Disabled the new light picking method for volumes until the volume sampling part of the paper has been implemented

Results
Below are some comparisons between the original method and the new light picking strategy. A fully converged image has no noise and the more noise there are in the image the further it is from having converged.

The Barcelona Pavilion scene above was rendered using branched path tracing with 20 diffuse, 10 glossy, 5 transmission, 1 AO, 20 mesh light, 1 subsurface, and 1 volume samples. The original and the reference images were created by sampling all direct and indirect lights. Here there is not that big of a noise difference but the new method is much faster. The scene contains 15 spotlights, 3 mesh lights, and a background light.

Links

 * My Commits
 * My Weekly Reports

What Is Left To Do
All parts of the paper except for the volume part(Section 5.2) has been implemented. Here are the next steps for the project:
 * Volumes:
 * Implement splitting for branched path tracing of volumes
 * Implement the importance metric for volumes and use this importance metric during traversal if the shading point is inside a volume.
 * Devices: The code has only been tested on the CPU. Make sure it works properly on other devices.
 * Splitting: Implement split traversal with a stack instead of using recursion. This might be necessary for the method to work well on the GPU.
 * Bugs: Try more complex scenes to find and fix bugs. The scenes under "Cycles tests" here for example.
 * The clock in the classroom scene is darker using the light tree with PATH. This is most probably coming from this or this commit.
 * Mesh lights: Currently mesh lights are double-sided but the method considers them single-sided. If, for example, a plane is turned into a mesh light with a normal pointing away from a given shading point then this light picking strategy will not pick this light even though the plane emits light towards it. A potential solution for this would be to make mesh lights single-sided by default.
 * Tests: Add simple regression tests


 * Optimization: The code is currently unoptimized. An optimization pass could greatly improve the performance. The bottlenecks could be found by using a profiler.