Commit 74b1fdc
Fix APV not working with subtractive and shadowmask mode
Jira: https://jira.unity3d.com/browse/UUM-44229
This is a continuation of https://github.cds.internal.unity3d.com/unity/unity/pull/43294
Adaptive Probe Volumes (APV) do currently work correctly with mixed lighting modes (Subtractive, Distance shadowmask, Shadowmask) - APV does not store per-probe occlusion like the old light probe system did. This results in missing shadows when use the aforementioned mode. This has resulted in a long standing bug (due to scale of the fix) which has been reported several times by our users. Mixed Lighting is enabled by default and used particularly heavily on mobile.
This PR changes APV to store the missing occlusion data, allowing for proper shadowing when using mixed lighting. The changes include:
- Adding the new occlusion data to APV. It has its own data-file and texture. It is stored in 4 bytes representing [0;1] values for 4 lights per probe.
- Implementing streaming, scenario blending and dilation for the new occlusion data.
- Adding a mode to the debug visualization tool which allows viewing the occlusion data.
- Adding an API function that allows getting shadowmask indices of baked lights. This was missing and required to calculate the occlusion data.
- Updating shader code of the SRP's to allow sampling occlusion.
- I've added a new define, `USE_APV_PROBE_OCCLUSION`, which is defined when probe occlusion should be sampled from APV. This is _not_ a new keyword, it's simply an alias for some existing keywords. This define is used to strip all the added code related to occlusion sampling when it isn't needed (in particular, when we aren't using mixed lighting).
- For HDRP, I just sample the occlusion in the GBuffer pass. There's already a slot in the GBuffer for it, it was just not being set before.
- For URP, the scale of changes is greater. APV supports being sampled both in vertex and fragment shader. For fragment shader sampling, the changes are simple enough, I've changed the code of relevant shaders to read occlusion and feed it to the existing designated outputs. For vertex shader sampling, I had to add a new (conditionally-defined) variable to each relevant `Varyings` struct.
To a user, the change is seamless: If they were using mixed lighting before, their project was missing shadows. If they re-bake after this change, the missing shadows will appear.
Before:

After:

Debug view mode (mimics shadowmask view mode):
1 parent 30d6d86 commit 74b1fdc
96 files changed
Lines changed: 6629 additions & 133 deletions
File tree
- Packages
- com.unity.render-pipelines.core
- Editor/Lighting/ProbeVolume
- Runtime
- Debug
- Lighting/ProbeVolume
- Utilities
- com.unity.render-pipelines.high-definition/Runtime/Material
- com.unity.render-pipelines.universal
- Editor/ShaderGraph
- Includes
- Targets
- Runtime/VFXGraph/Shaders
- ShaderLibrary
- Debug
- Shaders
- Nature
- Particles
- Terrain
- Tests/SRPTests/Projects
- HDRP_Tests
- Assets
- GraphicTests/Scenes/2x_Lighting
- 2123_APV_Baking_Shadowmask
- Tests/TestFilters
- ProjectSettings
- UniversalGraphicsTest_Lighting
- Assets
- Scenes
- 007-BasicAPV
- 230_APV_Subtractive
- Test/TestFilters
- ProjectSettings
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
| |||
108 | 113 | | |
109 | 114 | | |
110 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
111 | 119 | | |
112 | 120 | | |
113 | 121 | | |
| |||
328 | 336 | | |
329 | 337 | | |
330 | 338 | | |
| 339 | + | |
| 340 | + | |
331 | 341 | | |
332 | 342 | | |
333 | 343 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
Lines changed: 116 additions & 16 deletions
Large diffs are not rendered by default.
Lines changed: 99 additions & 6 deletions
Large diffs are not rendered by default.
Lines changed: 8 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
220 | 221 | | |
221 | 222 | | |
222 | 223 | | |
223 | | - | |
| 224 | + | |
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
| |||
246 | 247 | | |
247 | 248 | | |
248 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
249 | 253 | | |
250 | 254 | | |
251 | 255 | | |
| |||
473 | 477 | | |
474 | 478 | | |
475 | 479 | | |
476 | | - | |
| 480 | + | |
477 | 481 | | |
478 | 482 | | |
479 | 483 | | |
| |||
1059 | 1063 | | |
1060 | 1064 | | |
1061 | 1065 | | |
1062 | | - | |
| 1066 | + | |
| 1067 | + | |
1063 | 1068 | | |
1064 | 1069 | | |
1065 | 1070 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| |||
Lines changed: 16 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
58 | 65 | | |
59 | 66 | | |
60 | 67 | | |
| |||
104 | 111 | | |
105 | 112 | | |
106 | 113 | | |
107 | | - | |
| 114 | + | |
108 | 115 | | |
109 | 116 | | |
110 | 117 | | |
| |||
137 | 144 | | |
138 | 145 | | |
139 | 146 | | |
140 | | - | |
| 147 | + | |
141 | 148 | | |
142 | 149 | | |
143 | 150 | | |
| |||
153 | 160 | | |
154 | 161 | | |
155 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
156 | 169 | | |
157 | 170 | | |
158 | 171 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
305 | 310 | | |
306 | 311 | | |
307 | 312 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
0 commit comments