Shadow linking: Initial work towards MIS support #107439

Merged
Sergey Sharybin merged 17 commits from Sergey/blender:cycles-light-linking-mis into cycles-light-linking 2023-05-05 21:44:14 +02:00

17 Commits

Author SHA1 Message Date
Sergey Sharybin 3a0fd5a769 Remove TODO about the shadow offset. 2023-05-05 21:41:06 +02:00
Sergey Sharybin f3e2d5b452 Hopefully made shade_surface self-contained for inclusion
buildbot/vexp-code-patch-coordinator Build done. Details
2023-05-05 18:19:37 +02:00
Sergey Sharybin 9794cc5862 Fix compilation of GPU kernels
buildbot/vexp-code-patch-coordinator Build done. Details
2023-05-05 17:58:52 +02:00
Sergey Sharybin 2e632df524 Fix old variable names used in OptiX
buildbot/vexp-code-patch-coordinator Build done. Details
2023-05-05 17:39:04 +02:00
Sergey Sharybin 1fcd34b2a8 Properly support volumes
buildbot/vexp-code-patch-coordinator Build done. Details
Trace a dedicated light shadow ray for scatter events.

Makes it so a volume scene with a distant shadow-linked (excluded)
object renders the same as the scene without shadow linking at all.
2023-05-05 17:28:58 +02:00
Sergey Sharybin 1cc075f02c Fix comment about closing #endif 2023-05-05 17:16:24 +02:00
Sergey Sharybin d821f680f3 Use proper ray visibility flag in light intersection 2023-05-05 17:13:34 +02:00
Sergey Sharybin c1c283bfe2 Fix typo in comment 2023-05-05 16:16:58 +02:00
Sergey Sharybin 234b9d312f Merge branch 'cycles-light-linking' into cycles-light-linking-mis 2023-05-05 12:45:38 +02:00
Sergey Sharybin bdf4f318b6 Fix mistake in the lights intersection
The previous change to the way how lights are ignored made it so
lights are ignored by the dedicated shadow ray as well.
2023-05-04 18:00:57 +02:00
Sergey Sharybin 31cd714c02 Cleanup: Apply clang-format 2023-05-04 17:40:59 +02:00
Sergey Sharybin fe95d63f3f Merge branch 'cycles-light-linking' into cycles-light-linking-mis 2023-05-04 17:40:25 +02:00
Sergey Sharybin 397308a017 Better handling of the indirect lights 2023-05-04 10:06:35 +02:00
Sergey Sharybin 7ed67b02fa Rename blocked_light -> dedicated_light 2023-05-04 09:40:36 +02:00
Sergey Sharybin cd4b5f1f61 Take shader ray visibility into account
Refactored code a bit so that there is less duplication.

The downside is that the camera ray visibility for light shader
is now checked twice (in the intersect_closest and shade_light),
but it is unlikely to cause measurable performance impact.
2023-05-04 09:40:36 +02:00
Sergey Sharybin 1f31187450 Use proper weighting in the shade_blocked_light kernel 2023-05-04 09:40:36 +02:00
Sergey Sharybin 88abd725cc Shadow linking: Initial work towards MIS support
The goal of this change is to make it so the emitters are not forced
to have MIS disabled when shadow linking in used. On the user level
it means that lights sources sources which are behind excluded shadow
blocker will be visible in sharp glossy reflection.

In order to support this an extra shadow ray is traced in the direction
of the main path, to gather contribution of emitters behind shadow
blockers. This is done in the two new kernels.

First kernel performs light intersection to see if the extra shadow
ray is needed. It is not needed if, for example, there are no light
sources in the direction of the main path.

The second kernel shades the light source and generates the actual
shadow path.

Such separation allows to keep kernels small (so that no intersection
and shading happens in the same kernel). It also helps having good
occupancy on the GPU: the main path will not wait for the shadow
kernels to complete before continuing (the main path is needed by the
extra shadow path generation, to have access to direction and shading
reading state).

Current implementation is limited to lights only: there is no support
of mesh lights yet.

The MIS weight of the new shadow ray needs to be double-checked. It was
verified to give same result as the main path when the same light is
hit.

To avoid contribution from the same light source counted by the shadow
ray and the main path the light source which was chosen to trace the
shadow ray to is excluded from intersection via transparent bounces.
This seems unideal and feels that it could be done via some MIS wights
as well. Doing so is an exercise for later.

The kernel naming could be improved. Suggestions are welcome.
There are also quiet some TODOs in the code. Not sure how much of those
must be resolved prior to merge to the cycles-light-linking branch.
Would be cool to have extra eyes on some of the MIS aspects, which is
easier in the shared branch.

Tested on the CPU and Metal on M2 GPU.
2023-04-28 15:08:52 +02:00