GSoC 2022: Many Lights Sampling in Cycles X (Weekly Report)

Hi everyone, this thread is going to be used for my GSoC project’s weekly progress report. I’m going to try to keep these posts as higher-level summaries, but I’m also planning to write longer, more technical posts on my personal website. Feel free to check it out - constructive criticism is appreciated!

If you have any feedback (questions, concerns, bugs, etc), please post it to this thread and I will try to respond as soon as I can!


Hi Jeffrey.
Awesome to see this feature implementation getting love again.
Will there be a branch for this project any soon? And I’d like to know if this implementation will speed up render times in scenes with multiple lights through volume objects( volume illumination)


Hi Roggii, thanks for reaching out! I’m pushing to a branch called soc-2022-many-lights-sampling which you can also see here. I’m also going to be periodically updating this diff (likely every week or major update or so).

As for your second question, support for volumes is definitely on the to-do list. Right now, this is the sequence that I’ll be trying to follow:

  1. CPU Implementation
    a. Point Lights
    b. Spot and Area Lights
    c. Emissive Triangles
    d. Distant and Background Lights
    e. Volumes
  2. GPU Implementation

This is relatively high-level and definitely subject to change, but this feels like a somewhat natural order for me.


Hi, I try to build your branch but it stop with:

Building CXX object intern/cycles/kernel/CMakeFiles/cycles_kernel.dir/device/cpu/kernel.cpp.o
In Datei, eingebunden von /home/user/blender-git/blender/intern/cycles/kernel/../kernel/integrator/shade_surface.h:17,
                 von /home/user/blender-git/blender/intern/cycles/kernel/../kernel/device/cpu/kernel_arch_impl.h:32,
                 von /home/user/blender-git/blender/intern/cycles/kernel/device/cpu/kernel.cpp:48:
/home/user/blender-git/blender/intern/cycles/kernel/../kernel/light/light_tree.h: In Funktion »bool ccl::light_tree_sample(KernelGlobals, const RNGState*, float, float, float, float3, float3, int, uint32_t, LightSample*, float*) [mit bool in_volume_segment = false]«:
/home/user/blender-git/blender/intern/cycles/kernel/../kernel/light/light_tree.h:192:1: Fehler: Kontrollfluss erreicht Ende von Nicht-void-Funktion [-Werror=return-type]
  192 | }
      | ^
/home/user/blender-git/blender/intern/cycles/kernel/../kernel/light/light_tree.h: In Funktion »float ccl::light_tree_emitter_importance(KernelGlobals, float3, float3, int)«:
/home/user/blender-git/blender/intern/cycles/kernel/../kernel/light/light_tree.h:93:1: Fehler: Kontrollfluss erreicht Ende von Nicht-void-Funktion [-Werror=return-type]
   93 | }
      | ^

Error: control flow reached end of non-void function [-Werror=return-type]
192 | }

Is it to early to build for now?

Cheers, mib
EDIT: gcc (SUSE Linux) 12.1.0

1 Like

Hi, yes - right now, I’ve only been building on MSVC with just warnings on. Thank you for pointing that out though - I’ll try to build with warnings as errors, and let you know when it compiles for me.

1 Like

Closing this thread to limit this to the weekly reports. @Jebbly Feel free to open a second thread for feedback if you like.


Weekly Report #1 (6/13 - 6/19):

This week, I completed an initial CPU implementation of the light tree with support for point lights, spot lights, and area lights. I’ve also written a longer and more technical post if anyone is interested. The scenes I tested consisted of a single cube, no background light, and some light sources scattered around. Here’s an example with 1 point light, 1 spot light, and 1 area light - 8192 samples:

Overall, my implementation’s renders seem to converge towards the original implementation’s renders given enough samples. However, as you can see in the above image, there is definitely a lot more work that needs to be done in terms of adjusting heuristics to reduce noise. Optimizations are also going to take place once the algorithm is deemed stable enough.

Objective for Week #2:

I’d like to complete the following for next week:

  • Implement support for emissive triangles
  • Implement support for distant lights and background light
    • I’ll be joining the bi-weekly rendering meeting to discuss how to handle this (since they need to be handled outside of the light tree)
  • Read up on light sampling from volumes in preparation for implementing light tree traversal inside of participating media

Weekly Report #2 (6/20 - 6/26):

This week, I added initial support for emissive triangles, distant lights, and background lights. Unfortunately, due to the fact that we ended up changing the sampling strategy, I wasn’t able to test this as thoroughly as I would’ve liked. Given that there haven’t been many tests for either triangles or background lights, I may have to revert some of the changes I made to test each feature individually.

I also started reading up on light sampling from volumes, but I haven’t made too much progress on that end yet. This is also going to be continued, but the other features take priority.

Objective for Week #3:

I’d like to complete the following for next week:

  • Test and debug support for both emissive triangles and distant lights
    • Some changes may have to be reverted and then gradually pushed again (depending on how well the features work)
  • Continue reading on light sampling from participating media from PBRT

Weekly Report #3 (6/27 - 7/03)

This week, I cleaned up some of my work and performed a bit more testing with emissive triangles and distant lights. Here’s a more technical post about how all the different light types were implemented. Again, the tests I did were mostly simple scenes, like this one with 2 emissive triangles:

As I did this testing, I realized that I still haven’t updated some of the multiple importance sampling logic (for indirect lighting). This will be the main focus of my work for next week. I also created a scene that I’d like to use to verify some of the importance heuristic calculations.

Objective for Week #4:

I’d like to complete the following for next week:

  • Fix the PDF calculations done for multiple importance sampling
  • Debug some of the issues mentioned in the feedback thread
    • In general, I’m going to try to start debugging bug reports sooner rather than later, so that I don’t introduce too many new features that will make it much more difficult to debug
      • It’s also good to know which things are actually bugs at the moment, compared to things that aren’t working just because they have not yet been implemented