Skip to content

Commit a7ddb52

Browse files
szymonbonfirepastasfuture
authored andcommitted
Dynamic GI:
Max Sim Per Frame Control per Probe Volumes Dynamic GI (#44) * Control over max # of probe volume dynamic GI simulation's per frame * fixed issues with static value construction * More direct control of perf controls to dynamic GI Less GC allocations and better cleanup Cleanup and removed the need entirely clearing radiance cache on first frame of probe volume dynamic GI sim. compute shaders just handle that first frame case via variant instead. Removes hitches this way Sometimes we got NaN's, so added an extra safe clear on radiance data but via compute dispatch when needed slight bug fix to previous commit Quality variants for propagation axis amounts Dynamic GI: Added basic probe volume dynamic GI stats more dynamic GI stats Optimize GI data layout (#45) * Optimized the layout of the dynamic GI data. * Added migration of existing baked data to new layout. Context menu item "Reserialize (All)" on Probe Volume Asset now also runs the migration. Had to move the migration code from Probe Volume to Probe Volume Asset for this. Limitation: Context menu migration is skipped for assets of version < 3, since updating to v.3 requires rotation from an object in a scene. * Apply inverse-square law to propagation axis weights to get a more correct distribution for diagonal axes. Dynamic GI: Dynamic GI baked emission (#51) * Bake emission into dynamic GI neighbors and use it in the propagation. * Use 2x2 pixel blocks per baking request to control texture lods with uv and position gradients within these blocks. * Added the logic to control the material sampling lod for neighbor baking. * Added support of any Probe Volume rotation while baking dynamic GI neighbors and combining dynamic and baked SH. * Respect the Baked Emission material toggle when baking the dynamic GI neighbors. * Added a volume component setting to scale baked emission for dynamic GI. * Provide ddx and ddy for position and UV of a hit when baking neighbor materials. * Set the camera position shader property to zero before baking neighbors to support position-based effects in materials. * Clean-up. Work in progress for dgi optimization - setup new compute buffer Work in progress. Populate new neighbor axis lookups buffer and switch to reading from it. Remove old neighbour axis lookup array. Order members in NeighborAxisLookup by type size. adding safety cleanup to help trigger the sorted axis set after cleanup call Dynamic GI: Bind white texture for HVSSS in dynamic GI light loop
1 parent 863dec0 commit a7ddb52

26 files changed

+828
-391
lines changed

com.unity.render-pipelines.high-definition/Editor/Lighting/ProbeVolume/ProbeVolumeUI.Drawer.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,10 @@ static void Drawer_PrimarySettings(SerializedProbeVolume serialized, Editor owne
157157
if (serialized.supportDynamicGI.boolValue)
158158
{
159159
EditorGUILayout.PropertyField(serialized.drawNeighbors, Styles.s_DrawNeighborsLabel);
160-
if (serialized.drawNeighbors.boolValue && serialized.advancedFade.boolValue)
160+
161+
if (serialized.drawNeighbors.boolValue)
161162
{
163+
EditorGUILayout.PropertyField(serialized.drawEmission, Styles.s_DrawEmissionLabel);
162164
EditorGUILayout.PropertyField(serialized.neighborsQuadScale, Styles.s_NeighborsQuadScaleLabel);
163165
}
164166
}

com.unity.render-pipelines.high-definition/Editor/Lighting/ProbeVolume/ProbeVolumeUI.Skin.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ internal static class Styles
2828
internal static readonly GUIContent s_DrawValidityLabel = new GUIContent("Draw Validity", "Visualize per-probe validity. Green is full validity, no backfaces visible. Red is no validity, max backfaces visible.");
2929
internal static readonly GUIContent s_HighlightRingingLabel = new GUIContent("Highlight Ringing", "Negative values on probes due to ringing will be highlighted and blinked in red.");
3030
internal static readonly GUIContent s_DrawNeighborsLabel = new GUIContent("Draw Neighbors", "Enable or disable drawing probe neighborhood to debug dynamic gi.");
31+
internal static readonly GUIContent s_DrawEmissionLabel = new GUIContent("Draw Emission", "Show neighborhood emission instead of albedo.");
3132
internal static readonly GUIContent s_NeighborsQuadScaleLabel = new GUIContent("Draw Neighbors Scale", "The size of the debug quads when viewing draw neighbors mode");
3233
internal static readonly GUIContent s_DrawOctahedralDepthRays = new GUIContent("Draw Octahedral Depth Rays", "Enable or disable drawing rays to visualize to the octahedral depth data.");
3334
internal static readonly GUIContent s_DrawOctahedralDepthRayIndexX = new GUIContent("Octahedral Depth Rays Probe X", "Specifies the x index of the probe to visualize octahedral depth rays for.");

com.unity.render-pipelines.high-definition/Editor/Lighting/ProbeVolume/SerializedProbeVolume.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class SerializedProbeVolume
1010
internal SerializedProperty drawValidity;
1111
internal SerializedProperty highlightRinging;
1212
internal SerializedProperty drawNeighbors;
13+
internal SerializedProperty drawEmission;
1314
internal SerializedProperty neighborsQuadScale;
1415
internal SerializedProperty drawOctahedralDepthRays;
1516
internal SerializedProperty drawOctahedralDepthRayIndexX;
@@ -61,6 +62,7 @@ internal SerializedProbeVolume(SerializedObject serializedObject)
6162
drawValidity = probeVolumeParams.FindPropertyRelative("drawValidity");
6263
highlightRinging = probeVolumeParams.FindPropertyRelative("highlightRinging");
6364
drawNeighbors = probeVolumeParams.FindPropertyRelative("drawNeighbors");
65+
drawEmission = probeVolumeParams.FindPropertyRelative("drawEmission");
6466
neighborsQuadScale = probeVolumeParams.FindPropertyRelative("neighborsQuadScale");
6567

6668
drawOctahedralDepthRays = probeVolumeParams.FindPropertyRelative("drawOctahedralDepthRays");

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbeDynamicGI.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class ProbeDynamicGI : VolumeComponent
1919
{
2020
[Tooltip("Indirect multiplier for all lights affect Dynamic GI")]
2121
public ClampedFloatParameter indirectMultiplier = new ClampedFloatParameter(1f, 0.0f, 2f);
22+
[Tooltip("Multiplier for material emissive colors that affect Dynamic GI")]
23+
public ClampedFloatParameter bakedEmissionMultiplier = new ClampedFloatParameter(0f, 0f, 2f);
2224
[Tooltip("A control for blending in more influence of infinite bounce light near surfaces")]
2325
public ClampedFloatParameter infiniteBounce = new ClampedFloatParameter(1f, 0.0f, 2f);
2426

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagation.hlsl

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagationGlobals.hlsl"
66
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbeVolumeDynamicGI.hlsl"
77

8+
int _ProbeVolumeProbeCount;
9+
810
RWStructuredBuffer<float3> _RadianceCacheAxis;
911
StructuredBuffer<float3> _PreviousRadianceCacheAxis;
10-
int _RadianceCacheAxisCount;
1112

1213
int _ProbeVolumeIndex;
1314
float _LeakMultiplier;
@@ -26,15 +27,8 @@ bool IsFarFromCamera(float3 worldPosition, float rangeInFrontOfCamera, float ran
2627

2728
float3 ReadPreviousPropagationAxis(uint probeIndex, uint axisIndex)
2829
{
29-
const uint index = probeIndex * NEIGHBOR_AXIS_COUNT + axisIndex;
30-
31-
// TODO: remove this if check with stricter checks on construction side in C#
32-
if(index < (uint)_RadianceCacheAxisCount)
33-
{
34-
return _PreviousRadianceCacheAxis[index];
35-
}
36-
37-
return 0;
30+
const uint index = axisIndex * _ProbeVolumeProbeCount + probeIndex;
31+
return _PreviousRadianceCacheAxis[index];
3832
}
3933

4034
float3 NormalizeOutputRadiance(float4 lightingAndWeight, float probeValidity)
@@ -48,16 +42,10 @@ float3 NormalizeOutputRadiance(float4 lightingAndWeight, float probeValidity)
4842
return radiance;
4943
}
5044

51-
void WritePropagationOutput(uint probeIndex, uint axisIndex, float4 lightingAndWeight, float probeValidity)
45+
void WritePropagationOutput(uint index, float4 lightingAndWeight, float probeValidity)
5246
{
53-
const uint index = probeIndex * NEIGHBOR_AXIS_COUNT + axisIndex;
54-
55-
// TODO: remove this if check with stricter checks on construction side in C#
56-
if(index < (uint)_RadianceCacheAxisCount)
57-
{
58-
const float3 finalRadiance = NormalizeOutputRadiance(lightingAndWeight, probeValidity);
59-
_RadianceCacheAxis[index] = finalRadiance;
60-
}
47+
const float3 finalRadiance = NormalizeOutputRadiance(lightingAndWeight, probeValidity);
48+
_RadianceCacheAxis[index] = finalRadiance;
6149
}
6250

6351

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagationAxes.compute

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
#pragma multi_compile _ SAMPLE_NEIGHBORS_DIRECTION_ONLY SAMPLE_NEIGHBORS_POSITION_AND_DIRECTION
2+
#pragma multi_compile _ PROPAGATION_AXIS_MOST PROPAGATION_AXIS_LEAST
3+
#pragma multi_compile _ PREVIOUS_RADIANCE_CACHE_INVALID
4+
5+
#pragma kernel PropagateLight
6+
#define GROUP_SIZE 64
7+
//#pragma enable_d3d11_debug_symbols
8+
9+
110
#include "Packages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl"
211
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
312
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
@@ -14,14 +23,18 @@
1423
// #define PROBE_VOLUMES_SAMPLING_MODE PROBEVOLUMESENCODINGMODES_SPHERICAL_HARMONICS_L1
1524
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolume.hlsl"
1625

17-
#pragma multi_compile _ SAMPLE_NEIGHBORS_DIRECTION_ONLY SAMPLE_NEIGHBORS_POSITION_AND_DIRECTION
1826

19-
#pragma kernel PropagateLight
20-
#define GROUP_SIZE 64
21-
//#pragma enable_d3d11_debug_symbols
27+
#if defined(PROPAGATION_AXIS_LEAST)
28+
#define PROPAGATION_AXIS_AMOUNT 10
29+
#elif defined(PROPAGATION_AXIS_MOST)
30+
#define PROPAGATION_AXIS_AMOUNT 17
31+
#else
32+
#define PROPAGATION_AXIS_AMOUNT 26
33+
#endif
34+
2235

2336
float4 _RayAxis[NEIGHBOR_AXIS_COUNT];
24-
float4 _SortedNeighborAxis[NEIGHBOR_AXIS_COUNT * NEIGHBOR_AXIS_COUNT];
37+
StructuredBuffer<NeighborAxisLookup> _SortedNeighborAxisLookups;
2538

2639
StructuredBuffer<NeighborAxis> _ProbeVolumeNeighbors;
2740
int _ProbeVolumeNeighborsCount;
@@ -212,8 +225,8 @@ void PropagateLight(uint3 id : SV_DispatchThreadID)
212225
const int index = id.x;
213226
if (index < _ProbeVolumeNeighborsCount)
214227
{
215-
const uint probeIndex = (uint)index / NEIGHBOR_AXIS_COUNT;
216-
const uint axisIndex = (uint)index - probeIndex * NEIGHBOR_AXIS_COUNT;
228+
const uint axisIndex = (uint)index / _ProbeVolumeProbeCount;
229+
const uint probeIndex = (uint)index - axisIndex * _ProbeVolumeProbeCount;
217230

218231
float4 lightingAndWeight = float4(0, 0, 0, 1);
219232
uint3 probeCoordinate = ProbeIndexToProbeCoordinatesUint(probeIndex);
@@ -224,6 +237,12 @@ void PropagateLight(uint3 id : SV_DispatchThreadID)
224237
// Early out at far distances
225238
if (IsFarFromCamera(probePositionWS, _RangeInFrontOfCamera, _RangeBehindCamera))
226239
{
240+
#if defined(PREVIOUS_RADIANCE_CACHE_INVALID)
241+
_RadianceCacheAxis[index] = 0;
242+
#else
243+
_RadianceCacheAxis[index] = _PreviousRadianceCacheAxis[index];
244+
#endif
245+
227246
return;
228247
}
229248

@@ -243,22 +262,13 @@ void PropagateLight(uint3 id : SV_DispatchThreadID)
243262
float probeValidity = 0;
244263
int neighborAxisIndexOffset = axisIndex * NEIGHBOR_AXIS_COUNT;
245264

246-
// use NEIGHBOR_AXIS_COUNT for all of them
247-
// use 17 for only the very small values trimmed (very subtle)
248-
// use 10 for some quality loss (noticeable)
249-
const int relevantAxisLookups = 10;
250-
251-
for(int l=0; l < relevantAxisLookups; ++l)
265+
for(int l=0; l < PROPAGATION_AXIS_AMOUNT; ++l)
252266
{
253-
float4 neighborAxisLookup = _SortedNeighborAxis[neighborAxisIndexOffset + l];
254-
int i = (int)neighborAxisLookup.y;
255-
float sgWeight = neighborAxisLookup.x;
267+
NeighborAxisLookup neighborAxisLookup = _SortedNeighborAxisLookups[neighborAxisIndexOffset + l];
268+
int i = neighborAxisLookup.index;
269+
float sgWeight = neighborAxisLookup.sgWeight;
256270

257-
float3 neighborDirection = _RayAxis[i].xyz;
258-
float3 neighborWorldDirection = neighborDirection;
259-
neighborWorldDirection = mul(neighborDirection, probeVolumeLtw);
260-
261-
uint sampleAxis = probeIndex * NEIGHBOR_AXIS_COUNT + i;
271+
uint sampleAxis = i * _ProbeVolumeProbeCount + probeIndex;
262272
NeighborAxis neighbor = _ProbeVolumeNeighbors[sampleAxis];
263273

264274
uint hitIndex = 0;
@@ -282,19 +292,29 @@ void PropagateLight(uint3 id : SV_DispatchThreadID)
282292
neighborProbeCoordinate.y >= 0 && neighborProbeCoordinate.y < (int)_ProbeVolumeDGIResolutionY &&
283293
neighborProbeCoordinate.z >= 0 && neighborProbeCoordinate.z < (int)_ProbeVolumeDGIResolutionZ)
284294
{
285-
uint neighborProbeIndex = ProbeCoordinateToIndex(neighborProbeCoordinate);
286-
float3 prevAxisRadiance = ReadPreviousPropagationAxis(neighborProbeIndex, axisIndex);
287-
288-
incomingNeighborRadiance = prevAxisRadiance;
295+
#if defined(PREVIOUS_RADIANCE_CACHE_INVALID)
296+
incomingNeighborRadiance = 0;
297+
#else
298+
uint neighborProbeIndex = ProbeCoordinateToIndex(neighborProbeCoordinate);
299+
float3 prevAxisRadiance = ReadPreviousPropagationAxis(neighborProbeIndex, axisIndex);
300+
301+
incomingNeighborRadiance = prevAxisRadiance;
302+
#endif
289303
}
290304
#if defined(SAMPLE_NEIGHBORS_DIRECTION_ONLY) || defined(SAMPLE_NEIGHBORS_POSITION_AND_DIRECTION)
291305
else
292306
{
293-
#if defined(SAMPLE_NEIGHBORS_POSITION_AND_DIRECTION)
294-
// sample neighbor probe volumes to gather radiance from neighbor volumes
295-
float3 boundaryEdgePositionWS = ComputeNeighborBoundaryEdgeWorldPosition(probePositionWS, i, probeVolumeLtw, neighborWorldDirection);
296-
SHIncomingIrradiance shIncomingIrradiance = ProbeVolumeEvaluateIncomingIrradiance(boundaryEdgePositionWS, _ProbeVolumeDGILightLayers);
297-
#endif
307+
float3 neighborDirection = neighborAxisLookup.neighborDirection;
308+
float3 neighborWorldDirection = neighborDirection;
309+
310+
#if defined(SAMPLE_NEIGHBORS_POSITION_AND_DIRECTION)
311+
// sample neighbor probe volumes to gather radiance from neighbor volumes
312+
float3 boundaryEdgePositionWS = ComputeNeighborBoundaryEdgeWorldPosition(probePositionWS, i, probeVolumeLtw, neighborWorldDirection);
313+
SHIncomingIrradiance shIncomingIrradiance = ProbeVolumeEvaluateIncomingIrradiance(boundaryEdgePositionWS, _ProbeVolumeDGILightLayers);
314+
#else
315+
neighborWorldDirection = mul(neighborDirection, probeVolumeLtw);
316+
#endif
317+
298318
incomingNeighborRadiance = ProbeVolumeEvaluateIncomingRadiance(shIncomingIrradiance, neighborWorldDirection) * INV_PI;
299319
}
300320
#endif
@@ -305,9 +325,9 @@ void PropagateLight(uint3 id : SV_DispatchThreadID)
305325
}
306326

307327
incomingRadiance *= rcp(max(weight, 0.00001));
308-
probeValidity *= 1.0 / relevantAxisLookups;
328+
probeValidity *= 1.0 / PROPAGATION_AXIS_AMOUNT;
309329

310330
lightingAndWeight.rgb += incomingRadiance * _PropagationContribution;
311-
WritePropagationOutput(probeIndex, axisIndex, lightingAndWeight, probeValidity);
331+
WritePropagationOutput(index, lightingAndWeight, probeValidity);
312332
}
313333
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma kernel ClearPreviousRadianceCache
2+
#define GROUP_SIZE 64
3+
//#pragma enable_d3d11_debug_symbols
4+
5+
6+
RWStructuredBuffer<float3> _RadianceCacheAxis0;
7+
RWStructuredBuffer<float3> _RadianceCacheAxis1;
8+
RWStructuredBuffer<float3> _HitRadianceCacheAxis;
9+
int _RadianceCacheAxisCount;
10+
int _HitRadianceCacheAxisCount;
11+
12+
[numthreads(GROUP_SIZE, 1, 1)]
13+
void ClearPreviousRadianceCache(uint3 id : SV_DispatchThreadID)
14+
{
15+
const int axisIndex = id.x;
16+
if (axisIndex < _RadianceCacheAxisCount)
17+
{
18+
_RadianceCacheAxis0[axisIndex] = 0;
19+
_RadianceCacheAxis1[axisIndex] = 0;
20+
}
21+
if (axisIndex < _HitRadianceCacheAxisCount)
22+
{
23+
_HitRadianceCacheAxis[axisIndex] = 0;
24+
}
25+
}

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagationClearRadianceCache.compute.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagationCombine.compute

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ float4 _ProbeVolumeAtlasResolutionAndSliceCount;
2727
float3 _ProbeVolumeAtlasSHRotateRight;
2828
float3 _ProbeVolumeAtlasSHRotateUp;
2929
float3 _ProbeVolumeAtlasSHRotateForward;
30+
float3 _ProbeVolumeAtlasDynamicSHRotateRight;
31+
float3 _ProbeVolumeAtlasDynamicSHRotateUp;
32+
float3 _ProbeVolumeAtlasDynamicSHRotateForward;
3033

3134
StructuredBuffer<float3> _RadianceCacheAxis;
3235
int _RadianceCacheAxisCount;
@@ -127,14 +130,17 @@ SHIncomingIrradiance ProjectPropagationAxisFromPeak(uint probeIndex)
127130
SHIncomingIrradiance incomingIrradiance;
128131
ZERO_INITIALIZE(SHIncomingIrradiance, incomingIrradiance);
129132

130-
uint localIndex = probeIndex * NEIGHBOR_AXIS_COUNT;
133+
uint localIndex = probeIndex;
131134
for (int axis = 0; axis < NEIGHBOR_AXIS_COUNT; ++axis)
132135
{
133136
float3 radiance = _RadianceCacheAxis[localIndex].xyz;
134137
float3 direction = _RayAxis[axis].xyz;
138+
const float3x3 probeVolumeAtlasDynamicSHRotate = float3x3(_ProbeVolumeAtlasDynamicSHRotateRight, _ProbeVolumeAtlasDynamicSHRotateUp, _ProbeVolumeAtlasDynamicSHRotateForward);
139+
direction = mul(direction, probeVolumeAtlasDynamicSHRotate);
140+
135141
SHIncomingIrradianceAccumulate(incomingIrradiance, direction, radiance);
136142
//FCCAddToOutputRepresentation(radiance, direction, incomingIrradiance);
137-
localIndex++;
143+
localIndex += _ProbeVolumeAtlasReadBufferCount;
138144
}
139145

140146
return incomingIrradiance;
@@ -213,17 +219,19 @@ SHIncomingIrradiance ProjectPropagationAxisFromFit(uint probeIndex)
213219
SHIncomingIrradiance incomingIrradiance;
214220
ZERO_INITIALIZE(SHIncomingIrradiance, incomingIrradiance);
215221

216-
uint localIndex = probeIndex * NEIGHBOR_AXIS_COUNT;
222+
uint localIndex = probeIndex;
217223
for (int axis = 0; axis < NEIGHBOR_AXIS_COUNT; ++axis)
218224
{
219225
float3 radiance = _RadianceCacheAxis[localIndex].xyz;
220226
float3 direction = _RayAxis[axis].xyz;
227+
const float3x3 probeVolumeAtlasDynamicSHRotate = float3x3(_ProbeVolumeAtlasDynamicSHRotateRight, _ProbeVolumeAtlasDynamicSHRotateUp, _ProbeVolumeAtlasDynamicSHRotateForward);
228+
direction = mul(direction, probeVolumeAtlasDynamicSHRotate);
221229

222230
SHIncomingIrradiance incomingIrradianceCurrentSG = SHIncomingIrradianceComputeFromSphericalGaussian(direction, _PropagationSharpness, radiance);
223231

224232
SHIncomingIrradianceAccumulateFromSHIncomingIrradiance(incomingIrradiance, incomingIrradianceCurrentSG);
225233

226-
localIndex++;
234+
localIndex += _ProbeVolumeAtlasReadBufferCount;
227235
}
228236

229237
return incomingIrradiance;

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagationHits.compute

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1+
#pragma multi_compile _ COMPUTE_INFINITE_BOUNCE
2+
#pragma multi_compile _ PREVIOUS_RADIANCE_CACHE_INVALID
3+
4+
#pragma kernel AccumulateLightingDirectional
5+
#define GROUP_SIZE 64
6+
//#pragma enable_d3d11_debug_symbols
7+
8+
19
#define SHADOW_MINIMAL
210
#define LIGHT_EVALUATION_NO_HEIGHT_FOG
3-
411
#define DEBUGGING 0
512
#define SUPPORTS_AREA_LIGHTS 1
613

14+
715
#include "Packages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl"
816
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
917
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
1018
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
1119
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagationSphericalGaussians.hlsl"
1220
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagationLighting.hlsl"
1321

14-
#pragma kernel AccumulateLightingDirectional
15-
#define GROUP_SIZE 64
16-
//#pragma enable_d3d11_debug_symbols
1722

18-
#pragma multi_compile _ COMPUTE_INFINITE_BOUNCE
1923

2024
RWStructuredBuffer<float3> _HitRadianceCacheAxis;
2125
int _HitRadianceCacheAxisCount;
@@ -27,6 +31,7 @@ float4 _RayAxis[NEIGHBOR_AXIS_COUNT];
2731

2832
float _DirectContribution;
2933
float _IndirectScale;
34+
float _BakedEmissionMultiplier;
3035
float _RayBias;
3136
float _InfiniteBounce;
3237
float _InfiniteBounceSharpness;
@@ -106,14 +111,18 @@ void GatherLighting(SurfaceHitData hit, inout float4 lighting)
106111

107112
float3 EstimateIncomingBounceLightSG(uint probeIndex, PackedNeighborHit neighborData)
108113
{
109-
float3 normal = UnpackNormal(neighborData.normalAxis);
110-
float4 albedoDistance = UnpackAlbedoAndDistance(neighborData.albedoDistance, _ProbeVolumeDGIMaxNeighborDistance);
111-
112-
float3 incomingIrradiance = EvaluateBRDFLambertApproximate(probeIndex, normal, _InfiniteBounceSharpness, _RayAxis);
113-
incomingIrradiance *= _InfiniteBounce * INV_PI;
114-
incomingIrradiance *= albedoDistance.rgb;
115-
116-
return incomingIrradiance;
114+
#if defined(PREVIOUS_RADIANCE_CACHE_INVALID)
115+
return 0;
116+
#else
117+
float3 normal = UnpackNormal(neighborData.normalAxis);
118+
float4 albedoDistance = UnpackAlbedoAndDistance(neighborData.albedoDistance, _ProbeVolumeDGIMaxNeighborDistance);
119+
120+
float3 incomingIrradiance = EvaluateBRDFLambertApproximate(probeIndex, normal, _InfiniteBounceSharpness, _RayAxis);
121+
incomingIrradiance *= _InfiniteBounce * INV_PI;
122+
incomingIrradiance *= albedoDistance.rgb;
123+
124+
return incomingIrradiance;
125+
#endif
117126
}
118127

119128
float3 ProbeIndexToProbeCoordinates(uint probeIndex)
@@ -189,6 +198,7 @@ void AccumulateLightingDirectional(uint3 id : SV_DispatchThreadID)
189198
GatherLighting(hit, lightingAndWeight);
190199

191200
const float3 finalRadiance = NormalizeOutputRadiance(lightingAndWeight, probeValidity);
192-
_HitRadianceCacheAxis[hitAxisIndex] = finalRadiance;
201+
const float3 emission = UnpackEmission(neighborData.emission) * _BakedEmissionMultiplier;
202+
_HitRadianceCacheAxis[hitAxisIndex] = finalRadiance + emission;
193203
}
194204
}

0 commit comments

Comments
 (0)