blender/intern
Weizhen Huang fdc2962beb Fix #114634: correlated samples in volume when using equiangular sampling and light tree
The same random number was used when sampling from the volume segment
and from the direct scattering position, causing correlation issues with
light tree.

To solve this problem, we ensure the same light is picked for
volume segment/direct scattering, equiangular/distance sampling by
sampling the light tree only once in volume segment. From the direct
scattering position in volume, we sample a position on the picked light
as usual. If sampling from the light tree fails, we continue with
indirect scattering.
For unbiased MIS weight for forward sampling, we retrieve the `P`, `D`
and `t` used in volume segment for traversing the light tree.

The main changes are:
1. `light_tree_sample()` and `light_distribution_sample()` now only pick
lights. Sampling a position on light is done separately via
`light_sample()`.
2. `light_tree_sample()` is now only called only once from volume
segment. For direct lighting we call `light_sample()`.
3. `light_tree_pdf()` now has a template `<in_volume_segment>`.
4. A new field `emitter_id` is added to struct `LightSample`, which just
stores the picked emitter index.
5. Additional field `previous_dt = ray->tmax - ray->tmin` is added to
`state->ray`, because we need this quantity for computing the pdf.
6. Distant/Background lights are also picked by light tree in volume
segment now, because we have no way to pick them afterwards. The direct
sample event for these lights will be handled by
`VOLUME_SAMPLE_DISTANCE`.
7. Original paper suggests to use the maximal importance, this results
in very poor sampling probability for distant and point lights therefore
excessive noise. We have a minimal importance for surface to balance, we
could do the same for volume but I do not want to spend much time on
this now. Just doing `min_importance = 0.0f` seems to do the job
okayish. This way we still won't sample the light with zero
`max_importance`.

The current solution might perform worse with distance sampling, because
the light tree measure is biased towards equiangular sampling. However,
it is difficult to perform MIS between equiangular and distance sampling
if different lights are picked for each method. This is something we can
look into in the future if proved to be a serious regression.

Pull Request: https://projects.blender.org/blender/blender/pulls/119389
2024-03-25 18:50:52 +01:00
..
atomic Cleanup: move CMake test utility functions into testing.cmake 2024-01-03 14:49:11 +01:00
audaspace Cleanup: use braces for sources in intern/ 2023-09-17 09:05:40 +10:00
clog Revert changes from main commits that were merged into blender-v4.1-release 2024-02-19 15:59:59 +01:00
cycles Fix #114634: correlated samples in volume when using equiangular sampling and light tree 2024-03-25 18:50:52 +01:00
dualcon Mesh: Rename MLoopTri variable names, and functions 2023-12-19 14:57:49 +01:00
eigen Cleanup: remove redundant define checks 2023-12-07 10:39:03 +11:00
ffmpeg Tests: add option to build one binary per GTest file 2024-01-03 18:35:50 +01:00
ghost Fix #119871: Window contents invalid on startup under Wayland & GNOME 2024-03-25 22:08:27 +11:00
guardedalloc Fix #118402: enforce expected minimum alignment in MEM_CXX_CLASS_ALLOC_FUNCS 2024-02-21 18:14:11 +01:00
iksolver Clang Format: bump to version 17 2024-01-03 13:38:14 +01:00
itasc License Headers: Set copyright to "Blender Authors", add AUTHORS 2023-08-16 00:20:26 +10:00
libc_compat License Headers: Set copyright to "Blender Authors", add AUTHORS 2023-08-16 00:20:26 +10:00
libmv UI: fix and improve a few messages 2024-02-05 17:08:17 +01:00
locale License Headers: Set copyright to "Blender Authors", add AUTHORS 2023-08-16 00:20:26 +10:00
mantaflow Cleanup: Replace MIN/MAX macros with C++ functions 2024-01-22 15:58:18 +01:00
memutil Cleanup: use braces in headers 2023-09-24 14:52:38 +10:00
mikktspace Cleanup: use braces in headers 2023-09-24 14:52:38 +10:00
opencolorio Cleanup: Move remaining GPU headers to C++ 2024-03-23 01:24:18 +01:00
opensubdiv Cleanup: Remove unnecessary keywords from C++ headers 2024-01-04 15:07:48 -05:00
openvdb Volumes: refactor volume grid storage 2023-12-20 15:32:52 +01:00
quadriflow Cleanup: Replace MVertTri type with C++ vector 2023-12-20 20:59:11 -05:00
renderdoc_dynload RenderDoc: Set Capture Title 2024-02-23 10:57:37 +01:00
rigidbody Clang Format: bump to version 17 2024-01-03 13:38:14 +01:00
sky License Headers: Set copyright to "Blender Authors", add AUTHORS 2023-08-16 00:20:26 +10:00
utfconv CMake: Fix Compiling Shader Builder on macOS 2023-12-08 15:47:14 +01:00
wayland_dynload Fix #115878: build error with LIBDECOR & WITH_GHOST_WAYLAND_DYNLOAD=OFF 2023-12-13 10:17:07 +11:00
CMakeLists.txt CMake: Fix Compiling Shader Builder on macOS 2023-12-08 15:47:14 +01:00