Skip to content

Commit fec3d38

Browse files
NzollnerEvergreen
authored andcommitted
[Graphics][URP][Bugfix]Fixed reflection probes being in reverse order for forward plus
Error introduced in this PR: https://github.cds.internal.unity3d.com/unity/unity/pull/39057 Reflection probes are currently in the reverse order we need it for forward+ which this PR undo. This PR also adds a test case for reflection probes and lights using the mobile light and reflection probe limit. To catch this error in the future as well as other issues.
1 parent 390aace commit fec3d38

File tree

62 files changed

+10841
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+10841
-2
lines changed

Packages/com.unity.render-pipelines.universal/Runtime/ForwardLights.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,26 @@ internal void PreSetup(UniversalRenderingData renderingData, UniversalCameraData
254254
var worldToViews = new Fixed2<float4x4>(cameraData.GetViewMatrix(0), cameraData.GetViewMatrix(math.min(1, viewCount - 1)));
255255
var viewToClips = new Fixed2<float4x4>(cameraData.GetProjectionMatrix(0), cameraData.GetProjectionMatrix(math.min(1, viewCount - 1)));
256256

257+
// Should probe come after otherProbe?
258+
static bool IsProbeGreater(VisibleReflectionProbe probe, VisibleReflectionProbe otherProbe)
259+
{
260+
return probe.importance < otherProbe.importance ||
261+
(probe.importance == otherProbe.importance && probe.bounds.extents.sqrMagnitude > otherProbe.bounds.extents.sqrMagnitude);
262+
}
263+
264+
for (var i = 1; i < reflectionProbeCount; i++)
265+
{
266+
var probe = reflectionProbes[i];
267+
var j = i - 1;
268+
while (j >= 0 && IsProbeGreater(reflectionProbes[j], probe))
269+
{
270+
reflectionProbes[j + 1] = reflectionProbes[j];
271+
j--;
272+
}
273+
274+
reflectionProbes[j + 1] = probe;
275+
}
276+
257277
var minMaxZs = new NativeArray<float2>(itemsPerTile * viewCount, Allocator.TempJob);
258278

259279
var lightMinMaxZJob = new LightMinMaxZJob

Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,8 @@ public override void SetupCullingParameters(ref ScriptableCullingParameters cull
15721572
{
15731573
// We don't add one to the maximum light because mainlight is treated as any other light.
15741574
cullingParameters.maximumVisibleLights = UniversalRenderPipeline.maxVisibleAdditionalLights;
1575-
// Sort the reflection probes in engine.
1576-
cullingParameters.reflectionProbeSortingCriteria = ReflectionProbeSortingCriteria.ImportanceThenSize;
1575+
// Do not sort reflection probe from engine it will come in reverse order from what we need.
1576+
cullingParameters.reflectionProbeSortingCriteria = ReflectionProbeSortingCriteria.None;
15771577
}
15781578
else
15791579
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
13+
m_Name: ReflectionProbes
14+
m_EditorClassIdentifier:
15+
k_AssetVersion: 12
16+
k_AssetPreviousVersion: 12
17+
m_RendererType: 1
18+
m_RendererData: {fileID: 0}
19+
m_RendererDataList:
20+
- {fileID: 11400000, guid: bc60c4bc59aafe74198ea6134790d94b, type: 2}
21+
m_DefaultRendererIndex: 0
22+
m_RequireDepthTexture: 0
23+
m_RequireOpaqueTexture: 0
24+
m_OpaqueDownsampling: 1
25+
m_SupportsTerrainHoles: 0
26+
m_SupportsHDR: 1
27+
m_HDRColorBufferPrecision: 0
28+
m_MSAA: 1
29+
m_RenderScale: 1
30+
m_UpscalingFilter: 0
31+
m_FsrOverrideSharpness: 0
32+
m_FsrSharpness: 0.92
33+
m_EnableLODCrossFade: 0
34+
m_LODCrossFadeDitheringType: 1
35+
m_ShEvalMode: 0
36+
m_LightProbeSystem: 0
37+
m_ProbeVolumeMemoryBudget: 1024
38+
m_ProbeVolumeBlendingMemoryBudget: 256
39+
m_SupportProbeVolumeGPUStreaming: 0
40+
m_SupportProbeVolumeDiskStreaming: 0
41+
m_SupportProbeVolumeScenarios: 0
42+
m_SupportProbeVolumeScenarioBlending: 0
43+
m_ProbeVolumeSHBands: 1
44+
m_MainLightRenderingMode: 1
45+
m_MainLightShadowsSupported: 0
46+
m_MainLightShadowmapResolution: 2048
47+
m_AdditionalLightsRenderingMode: 1
48+
m_AdditionalLightsPerObjectLimit: 4
49+
m_AdditionalLightShadowsSupported: 0
50+
m_AdditionalLightsShadowmapResolution: 2048
51+
m_AdditionalLightsShadowResolutionTierLow: 256
52+
m_AdditionalLightsShadowResolutionTierMedium: 512
53+
m_AdditionalLightsShadowResolutionTierHigh: 1024
54+
m_ReflectionProbeBlending: 1
55+
m_ReflectionProbeBoxProjection: 0
56+
m_ShadowDistance: 50
57+
m_ShadowCascadeCount: 1
58+
m_Cascade2Split: 0.25
59+
m_Cascade3Split: {x: 0.1, y: 0.3}
60+
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
61+
m_CascadeBorder: 0.2
62+
m_ShadowDepthBias: 1
63+
m_ShadowNormalBias: 1
64+
m_AnyShadowsSupported: 1
65+
m_SoftShadowsSupported: 0
66+
m_ConservativeEnclosingSphere: 1
67+
m_NumIterationsEnclosingSphere: 64
68+
m_SoftShadowQuality: 2
69+
m_AdditionalLightsCookieResolution: 2048
70+
m_AdditionalLightsCookieFormat: 3
71+
m_UseSRPBatcher: 1
72+
m_SupportsDynamicBatching: 0
73+
m_MixedLightingSupported: 1
74+
m_SupportsLightCookies: 0
75+
m_SupportsLightLayers: 0
76+
m_DebugLevel: 0
77+
m_StoreActionsOptimization: 0
78+
m_UseAdaptivePerformance: 1
79+
m_ColorGradingMode: 0
80+
m_ColorGradingLutSize: 32
81+
m_UseFastSRGBLinearConversion: 0
82+
m_SupportDataDrivenLensFlare: 1
83+
m_SupportScreenSpaceLensFlare: 1
84+
m_GPUResidentDrawerMode: 0
85+
m_UseLegacyLightmaps: 0
86+
m_SmallMeshScreenPercentage: 0
87+
m_GPUResidentDrawerEnableOcclusionCullingInCameras: 0
88+
m_ShadowType: 1
89+
m_LocalShadowsSupported: 0
90+
m_LocalShadowsAtlasResolution: 256
91+
m_MaxPixelLights: 0
92+
m_ShadowAtlasResolution: 256
93+
m_VolumeFrameworkUpdateMode: 0
94+
m_VolumeProfile: {fileID: 0}
95+
apvScenesData:
96+
obsoleteSceneBounds:
97+
m_Keys: []
98+
m_Values: []
99+
obsoleteHasProbeVolumes:
100+
m_Keys: []
101+
m_Values:
102+
m_PrefilteringModeMainLightShadows: 1
103+
m_PrefilteringModeAdditionalLight: 4
104+
m_PrefilteringModeAdditionalLightShadows: 1
105+
m_PrefilterXRKeywords: 0
106+
m_PrefilteringModeForwardPlus: 1
107+
m_PrefilteringModeDeferredRendering: 1
108+
m_PrefilteringModeScreenSpaceOcclusion: 1
109+
m_PrefilterDebugKeywords: 0
110+
m_PrefilterWriteRenderingLayers: 0
111+
m_PrefilterHDROutput: 0
112+
m_PrefilterSSAODepthNormals: 0
113+
m_PrefilterSSAOSourceDepthLow: 0
114+
m_PrefilterSSAOSourceDepthMedium: 0
115+
m_PrefilterSSAOSourceDepthHigh: 0
116+
m_PrefilterSSAOInterleaved: 0
117+
m_PrefilterSSAOBlueNoise: 0
118+
m_PrefilterSSAOSampleCountLow: 0
119+
m_PrefilterSSAOSampleCountMedium: 0
120+
m_PrefilterSSAOSampleCountHigh: 0
121+
m_PrefilterDBufferMRT1: 0
122+
m_PrefilterDBufferMRT2: 0
123+
m_PrefilterDBufferMRT3: 0
124+
m_PrefilterSoftShadowsQualityLow: 0
125+
m_PrefilterSoftShadowsQualityMedium: 0
126+
m_PrefilterSoftShadowsQualityHigh: 0
127+
m_PrefilterSoftShadows: 0
128+
m_PrefilterScreenCoord: 0
129+
m_PrefilterNativeRenderPass: 0
130+
m_PrefilterUseLegacyLightmaps: 0
131+
m_ShaderVariantLogLevel: 0
132+
m_ShadowCascades: 0
133+
m_Textures:
134+
blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
135+
bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}

Tests/SRPTests/Projects/UniversalGraphicsTest_Lighting/Assets/CommonAssets/URPAssets/ReflectionProbes.asset.meta

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

Tests/SRPTests/Projects/UniversalGraphicsTest_Lighting/Assets/Scenes/223_Forward+_Lights_And_ReflectionProbe_Limit.meta

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

0 commit comments

Comments
 (0)