Cycles: Many Lights Sampling #77889
Open
opened 2020-06-15 16:52:52 +02:00 by Sam Kottler
·
54 comments
No Branch/Tag Specified
main
temp-sculpt-dyntopo
blender-v3.6-release
asset-shelf
brush-assets-project
blender-v3.3-release
temp-sculpt-dyntopo-hive-alloc
tmp-usd-python-mtl
asset-browser-frontend-split
node-group-operators
blender-v2.93-release
universal-scene-description
temp-sculpt-attr-api
blender-v3.5-release
realtime-clock
sculpt-dev
gpencil-next
bevelv2
microfacet_hair
blender-projects-basics
xr-dev
principled-v2
v3.3.7
v2.93.18
v3.5.1
v3.3.6
v2.93.17
v3.5.0
v2.93.16
v3.3.5
v3.3.4
v2.93.15
v2.93.14
v3.3.3
v2.93.13
v2.93.12
v3.4.1
v3.3.2
v3.4.0
v3.3.1
v2.93.11
v3.3.0
v3.2.2
v2.93.10
v3.2.1
v3.2.0
v2.83.20
v2.93.9
v3.1.2
v3.1.1
v3.1.0
v2.83.19
v2.93.8
v3.0.1
v2.93.7
v3.0.0
v2.93.6
v2.93.5
v2.83.18
v2.93.4
v2.93.3
v2.83.17
v2.93.2
v2.93.1
v2.83.16
v2.93.0
v2.83.15
v2.83.14
v2.83.13
v2.92.0
v2.83.12
v2.91.2
v2.83.10
v2.91.0
v2.83.9
v2.83.8
v2.83.7
v2.90.1
v2.83.6.1
v2.83.6
v2.90.0
v2.83.5
v2.83.4
v2.83.3
v2.83.2
v2.83.1
v2.83
v2.82a
v2.82
v2.81a
v2.81
v2.80
v2.80-rc3
v2.80-rc2
v2.80-rc1
v2.79b
v2.79a
v2.79
v2.79-rc2
v2.79-rc1
v2.78c
v2.78b
v2.78a
v2.78
v2.78-rc2
v2.78-rc1
v2.77a
v2.77
v2.77-rc2
v2.77-rc1
v2.76b
v2.76a
v2.76
v2.76-rc3
v2.76-rc2
v2.76-rc1
v2.75a
v2.75
v2.75-rc2
v2.75-rc1
v2.74
v2.74-rc4
v2.74-rc3
v2.74-rc2
v2.74-rc1
v2.73a
v2.73
v2.73-rc1
v2.72b
2.72b
v2.72a
v2.72
v2.72-rc1
v2.71
v2.71-rc2
v2.71-rc1
v2.70a
v2.70
v2.70-rc2
v2.70-rc
v2.69
v2.68a
v2.68
v2.67b
v2.67a
v2.67
v2.66a
v2.66
v2.65a
v2.65
v2.64a
v2.64
v2.63a
v2.63
v2.61
v2.60a
v2.60
v2.59
v2.58a
v2.58
v2.57b
v2.57a
v2.57
v2.56a
v2.56
v2.55
v2.54
v2.53
v2.52
v2.51
v2.50
v2.49b
v2.49a
v2.49
v2.48a
v2.48
v2.47
v2.46
v2.45
v2.44
v2.43
v2.42a
v2.42
v2.41
v2.40
v2.37a
v2.37
v2.36
v2.35a
v2.35
v2.34
v2.33a
v2.33
v2.32
v2.31a
v2.31
v2.30
v2.28c
v2.28a
v2.28
v2.27
v2.26
v2.25
Labels
Clear labels
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
Apply labels
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
Eevee & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest/Import
Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest: Wayland
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Eevee & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
Eevee & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest/Import
Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest: Wayland
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Eevee & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
Milestone
Set milestone
Clear milestone
No items
No Milestone
Projects
Set Project
Clear projects
No project
Assignees
Assign users
Clear assignees
No Assignees
21 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#77889
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
Under development in
soc-2022-many-lights-sampling
branch, implementing this paper .Feedback thread with various bug reports and tests.blend files.
Tasks
Testing
Implementation
Avoid computing importance for emitters twice for distant lights, use reservoir sampling instead
Better balancing with distant/background lights (see D16179, D16149 for some approaches)
Cleanup distance lights implementation to unify more with light tree
Support for light sampling inside of volumes
Make distant and background lights part of tree?
Fix zero radius distant light (mesh/shadow_terminator.blend test renders black)
Barbeshop light falloff shader node leads to noise, do better constant folding to avoid it
Add mesh light option for auto/none/front/back/both sides emission sampling
Auto exclude low emission strength triangles from tree for performance/memory?
Fix crash in spring (out of memory, avoided for now by excluding low emission)
Fix CUDA crash in wdas_cloud scene
Remove broken shadow pass with light tree (may restore later if there is a need)
Parallel tree build
23c5e06932
Workaround HIP internal compiler error
Future
Abandoned Ideas
light_tree_sample
, taking into account effective contribution of lights instead of uniform using the same weight for allHistory
Previous attempts in GSoC 2020 and 2018.
Added subscriber: @samkottler-1
#68916 was marked as duplicate of this issue
Added subscriber: @DuarteRamos
Added subscriber: @bent
Added subscriber: @Alaska
Added subscriber: @SteffenD
Added subscriber: @brecht
Added subscribers: @dfelinto, @BeckersC, @PetterLundh, @filibis, @higgsas, @GuidoMedici, @lemenicier_julien, @marcog
Added subscriber: @Stefan_Werner
Removed subscriber: @higgsas
Added subscriber: @Drop
Added subscriber: @lsscpp
Added subscriber: @Emi_Martinez
Added subscriber: @EvertonSchneider
Added subscriber: @Garek
Added subscriber: @lichtwerk
Not sure if this is still relevant?
In any case, will set its subtype to TODO to get it out of the #triaging queue.
Changed status from 'Needs Triage' to: 'Confirmed'
Added subscriber: @Jebbly
Added subscriber: @Yuro
I have decided to bring a bunch of the test scenes reported in the Many Lights Sampling feedback thread here so it's all organised into one place.
Extra notes:
The Bistro Scene is a modified version of the "Amazon Lumberyard Bistro" scene from here: https://developer.nvidia.com/orca/amazon-lumberyard-bistro
The Nvidia Attic Scene is a modified version of the Nvidia Attic scene from here: https://developer.nvidia.com/attic-nvidia
The Ladder scene is a modified version of the "DLSC Example Scene" from here: https://luxcorerender.org/example-scenes/
Checking the licenses of these scenes, Bistro and Attic are CC-BY 4.0. So we can potentially add those to our benchmark scenes as long as we add proper attribution. The ladder scene doesn't seem to specify a license.
For the regression test scenes, we are looking to gather various small .blend files that render 128x128 pixel images, sample count typically is between 16 and 64 samples so they render quickly. These should test the basic functioning as well as various corner cases. We'll then commit in them in the
lib/tests/render/light/
folder, or maybe a new one.Here's a few ideas:
0
when sampling the opaque ground plane (when using D16097)And some high quality renders of each scene.
This issue was referenced by None@63053
Added subscriber: @Nurb2Kea
I just thought I would write down some of my thoughts related to improving the balance with distant/background lights:
What's causing the issue?
When deciding whether to sample a distant light or a light from the light tree, we take the importance of an approximate distant light and comparing it to the importance of the root node of the light tree. Then we use a random number to determine which light type we sample. This is an issue because we are approximating the importance of the distance lights and lights in the light tree off of approximate representations of these lights, and these can be inaccurate.
Another issue related to this is that the importance calculations for distant lights end up with relatively low importance compared to other light types for the same lighting contribution. I have provided a simple fix for this here: D16148
Here are some ideas on how we could fix it:
Calculate the sum of importance of all distant lights and the sum of importance of all lights in the light tree before making the decision on which to follow. - This is probably the best solution in terms of accuracy, but it's expensive and thus probably not worth pursuing for the final release.
Evenly split samples between distant lights and the light tree when the distant lights have an importance greater than 0. - It's simple and fast. It's just not that great in terms of image quality for certain scenes. An alternative approach could be taken. Split samples between the light tree and distant lights based on the number of each light. However, this doesn't work well in scenes with lots of lights and few distant lights. This is probably not worth pursuing.
Calculate the importance for a distant light and the importance for a light in the light tree make a decision on which light to sample based on those. - If I understand correctly, this will introduce complexity into our PDF calculations when considering MIS, similar to how splitting introduces complexity. However this approach can lead to some good results. I have created a prototype for this here: D16179
Use weighted reservoir sampling to pick a sample from the distant light group and compare it to the sample from the light tree. - Similar to the approach above, just done in a different manner resulting in potentially different/better results.
Maybe some other method.
Another thing related to distant light is that they'd benefit from something like splitting in certain situations. Like when different distant lights have different colours and brightnesses. This is a similar situation to the one described in the links below.
Added subscriber: @Memento
I updated the remaining tasks. We now have an approach that no longer uses splitting, see D16315: Compute upper and lower bounds of emitter importance. Splitting is disabled due to increased noise. So splitting related improvements have been crossed out, assuming we can get the new approach working well enough for the benchmark scenes.
Added subscriber: @Xianyao-Zhang
@brecht I understand the changes made to switch to a non-splitting based Many Lights Sampling approach happened relatively recently and there may still be some work planned to further improve it. But in the meantime, splitting can still be useful for some scenes (like the scene I attached below). So with my limited understanding of the future improvements of Many Lights Sampling, I believe splitting is a feature worth while keeping until it can confidently be removed.
Simple scene that benefits from splitting.blend
I'm also not sure whether or not you want to add a test scene for the PDF calculations of rough glass when a light is in front and behind the surface and Cycles took the glossy path off the glass. I bring this up as you had to make specific changes to fix the PDF calculations for this situation and I'm not sure whether or not you want to test for it.
many_lights_sampling_test_glass_reflection_pdf.blend
Another thing that was discovered when LazyDodo tried to build the Many Lights Sampling branch on the build bot was that the HIP GPU kernel for Vega fails to build.
Edit: This error appears to only occur on Linux.
Added subscriber: @weizhen
We let the
should_split()
function return false instead of deleting all splitting-related stuff because we are not 100% confident yet that the current approach is better, but splitting is inefficient without the support of multiple lights per shading point as in the paper & has more variance in many scenes without adjusting the reservoir weights, so we are trying other strategies. The improved weights (min + max) are only applied on leaf nodes now because it already works better on most test scenes we have, I suppose it will work fine on your scene if also applied on interior nodes. Tbh everything is heuristic and there is no optimal weight, it could take us forever just finding better weights. So currently I'd like to focus on bringing full functionality (eg. adding volume support), after that we could look into better weights & strategies for difficult scenes.I ran some tests on my computer to see if I could reproduce the issues and identify the cause. I was personally unable to reproduce a crash in wdas_cloud. But on Spring I got a
Out of Memory
error after consuming all my RAM and swap (My computer has 64GB of RAM and only a few GB of swap).The Spring out of memory error comes from large number of light emitting triangles in the scene. These triangles come from the
flower
assets that are distributed over the foreground objects.Yes, the light tree data structure does not support instancing (and neither did the old distribution), but it now quite a bit of memory per triangle. It should be possible to significantly reduce this with some optimization.
At the same time I'm working on some changes that will make those flowers not part of the light tree by default, because they are just emitting a little bit and not worth the overhead to samples as a light source.
I have a few proposals to help with this:
auto emission sampling heuristic
to be even more conservative. At the moment if you have a mesh light with an emission strength of 1.0 and a pure colour (E.G. 100% red, 0% Green, 0% Blue), it will be excluded from direct light sampling. I have created two different versions of working around this. D16554, D16553Then there's some other ideas that I think may be useful, but probably aren't useful for most people:
emission sampling
setting for all materials.auto emission sampling cutoff
user controllable?I don't think a view layer option for emission sampling makes much sense, this seems to me really some per material or object, using the same setting for all objects in the scene doesn't seem right.
Maybe a there could be a scene wide cut-off, though I prefer not to add more obscure options.
This issue was referenced by
ac51d331df
This issue was referenced by
396b407c7d
I've merged code refactoring and the new emission sampling option into master, leaving just the light tree itself in the branch.
I'm still trying to isolate the CUDA wdas_cloud error and issue with HIP compilation on Vega. Verifying that these other changes work correctly by themselves helps isolate the problems a bit more.
This issue was referenced by None@63110
Added subscriber: @makizar
This issue was referenced by
0731d78d00
I tried to get the shadow pass working, but found it was already working poorly in most scenes. I removed it for now, as some of the use cases have been replaced by the shadow catcher passes. We may restore it, but that would be with a different implementation, and it's not clear what even the correct way to do this is.
I haven't been able to fix the HIP internal compile error so far, I may disable the light tree on HIP for now if I can't get it fixed tomorrow. I don't want this to block the merge to master.
@weizhen, I noticed the mesh/shadow_terminator.blend test renders completely black. It has a distant light with angle zero, making it a bit smaller works again. I guess there is some issues with
theta_e == 0
in the light tree, but not immediately spot the problem.Strange, I didn't encounter this problem in all_light_types.blend with angle = 0. Anyway, fixed that now 7d33edcf36
This issue was referenced by
ee89f213de
This issue was referenced by None@63118
This issue was referenced by
0808eaf44e
This issue was referenced by None@63122
This issue was referenced by
7d99c51e17
This issue was referenced by None@63124
Would it be a good idea to switch the light tree over from a binary tree to a four wide tree? The original paper (http://www.aconty.com/pdf/many-lights-hpg2018.pdf) states that they switched to a four wide tree for these reasons:
I took a look into improving how IES lights are handled, but couldn't figure out how to get it to work so I'll just document my findings.
From my understanding, the way we want to improve IES lights sampling with the light tree is by doing this:
Other ideas may be better pursuing.
Now, onto the information I found.