Skip to content

Commit 715eae7

Browse files
authored
Merge pull request #8036 from Unity-Technologies/internal/master
Internal/master
2 parents 5d43ffe + accba14 commit 715eae7

File tree

368 files changed

+31841
-2907
lines changed

Some content is hidden

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

368 files changed

+31841
-2907
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ static void PerformDilation(ProbeReferenceVolume.Cell cell, ProbeVolumeBakingSet
180180
cmd.SetComputeBufferParam(dilationShader, dilationKernel, _OutputProbes, data.outputProbes);
181181
cmd.SetComputeBufferParam(dilationShader, dilationKernel, _NeedDilating, data.needDilatingBuffer);
182182

183-
int probeCount = cell.data.probePositions.Length;
183+
// There's an upper limit on the number of bricks supported inside a single cell
184+
int probeCount = Mathf.Min(cell.data.probePositions.Length, ushort.MaxValue * ProbeBrickPool.kBrickProbeCountTotal);
184185

185186
cmd.SetComputeVectorParam(dilationShader, _DilationParameters, new Vector4(probeCount, settings.dilationValidityThreshold, settings.dilationDistance, ProbeReferenceVolume.instance.MinBrickSize()));
186187
cmd.SetComputeVectorParam(dilationShader, _DilationParameters2, new Vector4(settings.squaredDistWeighting ? 1 : 0, bakingSet.skyOcclusion ? 1 : 0, bakingSet.skyOcclusionShadingDirection ? 1 : 0, 0));

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,15 +613,15 @@ public bool Bake(in BakeJob job, ref NativeArray<SphericalHarmonicsL2> irradianc
613613
// Bake direct radiance
614614
using (new LightTransportBakingProfiling(LightTransportBakingProfiling.Stages.IntegrateDirectRadiance))
615615
{
616-
var integrationResult = integrator.IntegrateDirectRadiance(ctx, 0, probeCount, job.directSampleCount, job.ignoreEnvironement, job.ignoreEnvironement, directRadianceSlice);
616+
var integrationResult = integrator.IntegrateDirectRadiance(ctx, 0, probeCount, job.directSampleCount, job.ignoreEnvironement, directRadianceSlice);
617617
if (integrationResult.type != IProbeIntegrator.ResultType.Success) return false;
618618
if (cancel) return true;
619619
}
620620

621621
// Bake indirect radiance
622622
using (new LightTransportBakingProfiling(LightTransportBakingProfiling.Stages.IntegrateIndirectRadiance))
623623
{
624-
var integrationResult = integrator.IntegrateIndirectRadiance(ctx, 0, probeCount, job.indirectSampleCount, job.ignoreEnvironement, job.ignoreEnvironement, indirectRadianceSlice);
624+
var integrationResult = integrator.IntegrateIndirectRadiance(ctx, 0, probeCount, job.indirectSampleCount, job.ignoreEnvironement, indirectRadianceSlice);
625625
if (integrationResult.type != IProbeIntegrator.ResultType.Success) return false;
626626
if (cancel) return true;
627627
}

Packages/com.unity.render-pipelines.core/Editor/PostProcessing/LensFlareComponentSRPEditor.cs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,18 @@ class LensFlareComponentSRPEditor : Editor
2222
SerializedProperty m_AttenuationByLightShape;
2323
SerializedProperty m_RadialScreenAttenuationCurve;
2424
SerializedProperty m_UseOcclusion;
25-
SerializedProperty m_BackgroundCloudOcclusion;
25+
SerializedProperty m_fogOcclusion;
2626
SerializedProperty m_WaterOcclusion;
2727
SerializedProperty m_OcclusionRadius;
2828
SerializedProperty m_SamplesCount;
2929
SerializedProperty m_OcclusionOffset;
3030
SerializedProperty m_AllowOffScreen;
31-
SerializedProperty m_VolumetricCloudOcclusion;
3231
SerializedProperty m_OcclusionRemapTextureCurve;
3332
SerializedProperty m_OcclusionRemapCurve;
3433
SerializedProperty m_LightOverride;
3534

35+
Light m_AttachedLight;
36+
3637
void MakeTextureDirtyCallback()
3738
{
3839
LensFlareComponentSRP comp = target as LensFlareComponentSRP;
@@ -41,6 +42,10 @@ void MakeTextureDirtyCallback()
4142

4243
void OnEnable()
4344
{
45+
if (targets.Length == 1)
46+
m_AttachedLight = (target as Component)?.GetComponent<Light>();
47+
else
48+
m_AttachedLight = null;
4449
PropertyFetcher<LensFlareComponentSRP> entryPoint = new PropertyFetcher<LensFlareComponentSRP>(serializedObject);
4550
m_LensFlareData = entryPoint.Find("m_LensFlareData");
4651
m_Intensity = entryPoint.Find(x => x.intensity);
@@ -52,13 +57,12 @@ void OnEnable()
5257
m_AttenuationByLightShape = entryPoint.Find(x => x.attenuationByLightShape);
5358
m_RadialScreenAttenuationCurve = entryPoint.Find(x => x.radialScreenAttenuationCurve);
5459
m_UseOcclusion = entryPoint.Find(x => x.useOcclusion);
55-
m_BackgroundCloudOcclusion = entryPoint.Find(x => x.useBackgroundCloudOcclusion);
60+
m_fogOcclusion = entryPoint.Find(x => x.useFogOpacityOcclusion);
5661
m_WaterOcclusion = entryPoint.Find(x => x.useWaterOcclusion);
5762
m_OcclusionRadius = entryPoint.Find(x => x.occlusionRadius);
5863
m_SamplesCount = entryPoint.Find(x => x.sampleCount);
5964
m_OcclusionOffset = entryPoint.Find(x => x.occlusionOffset);
6065
m_AllowOffScreen = entryPoint.Find(x => x.allowOffScreen);
61-
m_VolumetricCloudOcclusion = entryPoint.Find(x => x.volumetricCloudOcclusion);
6266
m_OcclusionRemapTextureCurve = entryPoint.Find(x => x.occlusionRemapCurve);
6367
m_OcclusionRemapCurve = m_OcclusionRemapTextureCurve.FindPropertyRelative("m_Curve");
6468
m_LightOverride = entryPoint.Find(x => x.lightOverride);
@@ -156,12 +160,16 @@ public override void OnInspectorGUI()
156160
if (m_UseOcclusion.boolValue)
157161
{
158162
++EditorGUI.indentLevel;
159-
if (RenderPipelineManager.currentPipeline is ICloudBackground)
160-
EditorGUILayout.PropertyField(m_BackgroundCloudOcclusion, Styles.backgroundCloudOcclusion);
161-
if (RenderPipelineManager.currentPipeline is IVolumetricCloud volumetricCloud && volumetricCloud.IsVolumetricCloudUsable())
162-
EditorGUILayout.PropertyField(m_VolumetricCloudOcclusion, Styles.volumetricCloudOcclusion);
163-
if (RenderPipelineManager.currentPipeline is IWaterRendering waterRendering && waterRendering.IsWaterRenderingUsable())
164-
EditorGUILayout.PropertyField(m_WaterOcclusion, Styles.waterOcclusion);
163+
EditorGUI.BeginDisabledGroup(m_AttachedLight != null && m_AttachedLight.type != LightType.Directional);
164+
{
165+
if (RenderPipelineManager.currentPipeline is ICloudBackground)
166+
EditorGUILayout.PropertyField(m_fogOcclusion, Styles.fogAndCloudOpacityOcclusion);
167+
if (RenderPipelineManager.currentPipeline is IWaterRendering waterRendering &&
168+
waterRendering.IsWaterRenderingUsable())
169+
EditorGUILayout.PropertyField(m_WaterOcclusion, Styles.waterOcclusion);
170+
}
171+
EditorGUI.EndDisabledGroup();
172+
165173
EditorGUILayout.PropertyField(m_OcclusionRadius, Styles.occlusionRadius);
166174
EditorGUILayout.PropertyField(m_SamplesCount, Styles.sampleCount);
167175
EditorGUILayout.PropertyField(m_OcclusionOffset, Styles.occlusionOffset);
@@ -199,7 +207,7 @@ static class Styles
199207
static public readonly GUIContent attenuationByLightShape = EditorGUIUtility.TrTextContent("Attenuation By Light Shape", "When enabled, if the component is attached to a light, automatically reduces the effect of the lens flare based on the type and shape of the light.");
200208
static public readonly GUIContent radialScreenAttenuationCurve = EditorGUIUtility.TrTextContent("Screen Attenuation Curve", "Specifies the curve that modifies the intensity of the lens flare based on its distance from the edge of the screen.");
201209
static public readonly GUIContent enableOcclusion = EditorGUIUtility.TrTextContent("Enable", "When enabled, the renderer uses the depth buffer to occlude (partially or completely) the lens flare. Partial occlusion also occurs when the lens flare is partially offscreen.");
202-
static public readonly GUIContent backgroundCloudOcclusion = EditorGUIUtility.TrTextContent("Background Clouds", "When enabled, the occlusion is attenuated by the Background Clouds used on the Visual Environnement (Cloud layer).");
210+
static public readonly GUIContent fogAndCloudOpacityOcclusion = EditorGUIUtility.TrTextContent("Fog And Cloud Opacity", "When enabled, the occlusion is attenuated by the Background Clouds, Volumetric Clouds and the Fog.");
203211
static public readonly GUIContent occlusionRadius = EditorGUIUtility.TrTextContent("Occlusion Radius", "Sets the radius, in meters, around the light used to compute the occlusion of the lens flare. If this area is half occluded by geometry (or half off-screen), the intensity of the lens flare is cut by half.");
204212
static public readonly GUIContent sampleCount = EditorGUIUtility.TrTextContent("Sample Count", "Sets the number of random samples used inside the Occlusion Radius area. A higher sample count gives a smoother attenuation when occluded.");
205213
static public readonly GUIContent occlusionOffset = EditorGUIUtility.TrTextContent("Occlusion Offset", "Sets the offset of the occlusion area in meters between the GameObject this asset is attached to, and the Camera. A positive value moves the occlusion area closer to the Camera.");

Packages/com.unity.render-pipelines.core/Editor/Settings/PropertyDrawers/DefaultVolumeProfileSettingsPropertyDrawer.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public abstract class DefaultVolumeProfileSettingsPropertyDrawer : PropertyDrawe
3434
public override VisualElement CreatePropertyGUI(SerializedProperty property)
3535
{
3636
m_Root = new VisualElement();
37+
38+
var header = CreateHeader();
39+
if (header != null)
40+
m_Root.Add(header);
41+
3742
m_SettingsSerializedObject = property.serializedObject;
3843
m_VolumeProfileSerializedProperty = property.FindPropertyRelative("m_VolumeProfile");
3944
m_DefaultVolumeProfileFoldoutExpanded = new EditorPrefBool($"{GetType()}.DefaultVolumeProfileFoldoutExpanded", true);
@@ -50,6 +55,12 @@ public override VisualElement CreatePropertyGUI(SerializedProperty property)
5055

5156
return m_Root;
5257
}
58+
59+
/// <summary>
60+
/// Creates the header for the Volume Profile editor.
61+
/// </summary>
62+
/// <returns>VisualElement containing the header. Null for no header.</returns>
63+
protected virtual VisualElement CreateHeader() => null;
5364

5465
/// <summary>
5566
/// Creates the Default Volume Profile editor.

Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugDisplayStats.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ DebugUI.Value CreateWidgetForSampler(TProfileId samplerId, ProfilingSampler samp
200200
{
201201
var sampler = ProfilingSampler.Get(samplerId);
202202

203+
// In non-dev build ProfilingSampler.Get always returns null.
204+
if (sampler == null)
205+
continue;
206+
203207
sampler.enableRecording = true;
204208

205209
result.Add(new DebugUI.ValueTuple

Packages/com.unity.render-pipelines.core/Runtime/Debugging/ProfilingScope.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class ProfilingSampler
6363
/// <typeparam name="TEnum">Type of the enumeration.</typeparam>
6464
/// <param name="marker">Enumeration value.</param>
6565
/// <returns>The profiling sampler for the given enumeration value.</returns>
66+
#if DEVELOPMENT_BUILD || UNITY_EDITOR
6667
public static ProfilingSampler Get<TEnum>(TEnum marker)
6768
where TEnum : Enum
6869
{
@@ -73,6 +74,13 @@ public static ProfilingSampler Get<TEnum>(TEnum marker)
7374
return sampler;
7475
#endif
7576
}
77+
#else
78+
public static ProfilingSampler Get<TEnum>(TEnum marker)
79+
where TEnum : Enum
80+
{
81+
return null;
82+
}
83+
#endif
7684

7785
/// <summary>
7886
/// Constructor.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Unity.Collections;
4+
using Unity.Jobs;
5+
using Unity.Jobs.LowLevel.Unsafe;
6+
using Unity.Burst;
7+
using UnityEngine.Profiling;
8+
using Unity.Mathematics;
9+
using UnityEngine.Assertions;
10+
11+
namespace UnityEngine.Rendering
12+
{
13+
internal partial class GPUResidentBatcher : IDisposable
14+
{
15+
private void ProcessTrees()
16+
{
17+
int treeInstancesCount = m_BatchersContext.GetAliveInstancesOfType(InstanceType.SpeedTree);
18+
19+
if (treeInstancesCount == 0)
20+
return;
21+
22+
Profiler.BeginSample("GPUResidentInstanceBatcher.ProcessTrees");
23+
24+
int maxInstancesCount = m_BatchersContext.aliveInstances.Length;
25+
26+
if(!m_ProcessedThisFrameTreeBits.IsCreated)
27+
m_ProcessedThisFrameTreeBits = new ParallelBitArray(maxInstancesCount, Allocator.TempJob);
28+
else if(m_ProcessedThisFrameTreeBits.Length < maxInstancesCount)
29+
m_ProcessedThisFrameTreeBits.Resize(maxInstancesCount);
30+
31+
bool becomeVisibleOnly = !Application.isPlaying;
32+
var visibleTreeRendererIDs = new NativeList<int>(Allocator.TempJob);
33+
var visibleTreeInstances = new NativeList<InstanceHandle>(Allocator.TempJob);
34+
35+
ParallelBitArray compactedVisibilityMasks = m_InstanceCullingBatcher.GetCompactedVisibilityMasks(syncCullingJobs: false);
36+
Assert.IsTrue(compactedVisibilityMasks.IsCreated);
37+
38+
m_BatchersContext.GetVisibleTreeInstances(compactedVisibilityMasks, m_ProcessedThisFrameTreeBits, visibleTreeRendererIDs, visibleTreeInstances,
39+
becomeVisibleOnly, out var becomeVisibleTreeInstancesCount);
40+
41+
if (visibleTreeRendererIDs.Length > 0)
42+
{
43+
Profiler.BeginSample("GPUResidentInstanceBatcher.UpdateSpeedTreeWindAndUploadWindParamsToGPU");
44+
45+
// Become visible trees is a subset of visible trees.
46+
var becomeVisibleTreeRendererIDs = visibleTreeRendererIDs.AsArray().GetSubArray(0, becomeVisibleTreeInstancesCount);
47+
var becomeVisibleTreeInstances = visibleTreeInstances.AsArray().GetSubArray(0, becomeVisibleTreeInstancesCount);
48+
49+
if (becomeVisibleTreeRendererIDs.Length > 0)
50+
UpdateSpeedTreeWindAndUploadWindParamsToGPU(becomeVisibleTreeRendererIDs, becomeVisibleTreeInstances, history: true);
51+
52+
UpdateSpeedTreeWindAndUploadWindParamsToGPU(visibleTreeRendererIDs.AsArray(), visibleTreeInstances.AsArray(), history: false);
53+
54+
Profiler.EndSample();
55+
}
56+
57+
visibleTreeRendererIDs.Dispose();
58+
visibleTreeInstances.Dispose();
59+
60+
Profiler.EndSample();
61+
}
62+
63+
private unsafe void UpdateSpeedTreeWindAndUploadWindParamsToGPU(NativeArray<int> treeRendererIDs, NativeArray<InstanceHandle> treeInstances, bool history)
64+
{
65+
if (treeRendererIDs.Length == 0)
66+
return;
67+
68+
Assert.AreEqual(treeRendererIDs.Length, treeInstances.Length);
69+
Assert.AreEqual(m_BatchersContext.renderersParameters.windParams.Length, (int)SpeedTreeWindParamIndex.MaxWindParamsCount);
70+
71+
var gpuInstanceIndices = new NativeArray<GPUInstanceIndex>(treeInstances.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
72+
m_BatchersContext.instanceDataBuffer.CPUInstanceArrayToGPUInstanceArray(treeInstances, gpuInstanceIndices);
73+
74+
if (!history)
75+
m_BatchersContext.UpdateInstanceWindDataHistory(gpuInstanceIndices);
76+
77+
GPUInstanceDataBufferUploader uploader = m_BatchersContext.CreateDataBufferUploader(treeInstances.Length, InstanceType.SpeedTree);
78+
uploader.AllocateUploadHandles(treeInstances.Length);
79+
80+
var windParams = new SpeedTreeWindParamsBufferIterator();
81+
windParams.bufferPtr = uploader.GetUploadBufferPtr();
82+
for (int i = 0; i < (int)SpeedTreeWindParamIndex.MaxWindParamsCount; ++i)
83+
windParams.uintParamOffsets[i] = uploader.PrepareParamWrite<Vector4>(m_BatchersContext.renderersParameters.windParams[i].index);
84+
windParams.uintStride = uploader.GetUIntPerInstance();
85+
windParams.elementOffset = 0;
86+
windParams.elementsCount = treeInstances.Length;
87+
88+
SpeedTreeWindManager.UpdateWindAndWriteBufferWindParams(treeRendererIDs, windParams, history);
89+
m_BatchersContext.SubmitToGpu(gpuInstanceIndices, ref uploader, submitOnlyWrittenParams: true);
90+
91+
gpuInstanceIndices.Dispose();
92+
uploader.Dispose();
93+
}
94+
}
95+
}

Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentBatcher.SpeedTree.cs.meta

Lines changed: 2 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)