Skip to content

Commit 20486fd

Browse files
YvainRaeymaekersEvergreen
authored andcommitted
Fix 2121_APV_Baking_Sky_Occlusion test: revert ref image change and use more reliable sampler than xor shift
The sky occlusion ref image was incorrectly updated for HDRP Test: 2121_APV_Baking_Sky_Occlusion.png. What can be perceived on bottom right as an artifact is actually test the rendering layers feature for APV.
1 parent 0f0d3c8 commit 20486fd

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.RenderingLayers.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Runtime.InteropServices;
33
using UnityEngine.Rendering.UnifiedRayTracing;
44
using Unity.Collections;
5+
using UnityEngine.Rendering.Sampling;
56

67
namespace UnityEngine.Rendering
78
{
@@ -46,6 +47,7 @@ class DefaultRenderingLayer : RenderingLayerBaker
4647
static readonly int _ProbePositions = Shader.PropertyToID("_ProbePositions");
4748
static readonly int _LayerMasks = Shader.PropertyToID("_LayerMasks");
4849
static readonly int _RenderingLayerMasks = Shader.PropertyToID("_RenderingLayerMasks");
50+
static readonly int _SobolBuffer = Shader.PropertyToID("_SobolMatricesBuffer");
4951

5052
int batchIndex, batchCount;
5153
Vector4 regionMasks;
@@ -63,6 +65,7 @@ class DefaultRenderingLayer : RenderingLayerBaker
6365
AccelStructAdapter m_AccelerationStructure;
6466
GraphicsBuffer scratchBuffer;
6567
GraphicsBuffer probePositionsBuffer;
68+
GraphicsBuffer sobolBuffer;
6669

6770
public override ulong currentStep => (ulong)batchIndex;
6871
public override ulong stepCount => (ulong)batchCount;
@@ -92,12 +95,16 @@ public override void Initialize(ProbeVolumeBakingSet bakingSet, NativeArray<Vect
9295
layerMaskBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, batchSize, Marshal.SizeOf<uint>());
9396
scratchBuffer = RayTracingHelper.CreateScratchBufferForBuildAndDispatch(m_AccelerationStructure.GetAccelerationStructure(), s_TracingContext.shaderRL, (uint)batchSize, 1, 1);
9497

98+
int sobolBufferSize = (int)(SobolData.SobolDims * SobolData.SobolSize);
99+
sobolBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, sobolBufferSize, Marshal.SizeOf<uint>());
100+
sobolBuffer.SetData(SobolData.SobolMatrices);
101+
95102
cmd = new CommandBuffer();
96103
m_AccelerationStructure.Build(cmd, ref scratchBuffer);
97104
Graphics.ExecuteCommandBuffer(cmd);
98105
cmd.Clear();
99106
}
100-
107+
101108
static AccelStructAdapter BuildAccelerationStructure()
102109
{
103110
var accelStruct = s_TracingContext.CreateAccelerationStructure();
@@ -115,6 +122,7 @@ static AccelStructAdapter BuildAccelerationStructure()
115122
var matIndices = new uint[subMeshCount];
116123
Array.Fill(matIndices, renderer.component.renderingLayerMask); // repurpose the material id as we don't need it here
117124
var perSubMeshMask = new uint[subMeshCount];
125+
118126
Array.Fill(perSubMeshMask, GetInstanceMask(renderer.component.shadowCastingMode));
119127
accelStruct.AddInstance(renderer.component.GetInstanceID(), renderer.component, perSubMeshMask, matIndices);
120128
}
@@ -145,6 +153,7 @@ public override bool Step()
145153
shader.SetVectorParam(cmd, _RenderingLayerMasks, regionMasks);
146154
shader.SetBufferParam(cmd, _ProbePositions, probePositionsBuffer);
147155
shader.SetBufferParam(cmd, _LayerMasks, layerMaskBuffer);
156+
shader.SetBufferParam(cmd, _SobolBuffer, sobolBuffer);
148157

149158
shader.Dispatch(cmd, scratchBuffer, (uint)batchSize, 1, 1);
150159
batchIndex++;
@@ -176,6 +185,7 @@ public override void Dispose()
176185
scratchBuffer?.Dispose();
177186
probePositionsBuffer.Dispose();
178187
m_AccelerationStructure.Dispose();
188+
sobolBuffer?.Dispose();
179189

180190
layerMaskBuffer.Dispose();
181191
layerMask.Dispose();

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/RenderingLayerMask/TraceRenderingLayerMask.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "Packages/com.unity.rendering.light-transport/Runtime/UnifiedRayTracing/FetchGeometry.hlsl"
55
#include "Packages/com.unity.rendering.light-transport/Runtime/UnifiedRayTracing/TraceRay.hlsl"
66

7-
#define QRNG_METHOD_RANDOM_XOR_SHIFT
7+
#define QRNG_METHOD_SOBOL
88
#define SAMPLE_COUNT 32
99
#define RAND_SAMPLES_PER_BOUNCE 2
1010
#include "Packages/com.unity.rendering.light-transport/Runtime/Sampling/QuasiRandom.hlsl"

0 commit comments

Comments
 (0)