Skip to content

Commit b690561

Browse files
adrien-de-tocquevilleEvergreen
authored andcommitted
[HDRP] Refactor clouds and water out of HDRenderPipeline
Moved water and clouds as separate systems instead of being part of HDRenderPipeline class. This helps modularizing the code and simplifies dependencies. Additionally, moved each resources to per system classes that can be stripped independently of the rest of the pipeline resources if the feature is not used at build time. As a result, they show in their own section in the global settings: ![image](https://media.github.cds.internal.unity3d.com/user/2154/files/85471fac-567a-427d-8e56-66feb54b7b57)
1 parent 71dac76 commit b690561

File tree

67 files changed

+1739
-802
lines changed

Some content is hidden

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

67 files changed

+1739
-802
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class DefaultRenderingLayer : RenderingLayerBaker
5858
NativeArray<uint> layerMask;
5959

6060
public override NativeArray<uint> renderingLayerMasks => layerMask;
61-
61+
6262
CommandBuffer cmd;
6363
IRayTracingAccelStruct m_AccelerationStructure;
6464
GraphicsBuffer scratchBuffer;
@@ -141,7 +141,7 @@ public override bool Step()
141141
{
142142
if (currentStep >= stepCount)
143143
return true;
144-
144+
145145
var shader = s_TracingContext.shaderRL;
146146

147147
int batchOffset = batchIndex * k_MaxProbeCountPerBatch;
@@ -152,7 +152,7 @@ public override bool Step()
152152
shader.SetVectorParam(cmd, _RenderingLayerMasks, regionMasks);
153153
shader.SetBufferParam(cmd, _ProbePositions, probePositionsBuffer);
154154
shader.SetBufferParam(cmd, _LayerMasks, layerMaskBuffer);
155-
155+
156156
shader.Dispatch(cmd, scratchBuffer, (uint)batchSize, 1, 1);
157157
batchIndex++;
158158

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public abstract class SkyOcclusionBaker : IDisposable
4040
/// Performs necessary tasks to free allocated resources.
4141
/// </summary>
4242
public abstract void Dispose();
43-
43+
4444
internal NativeArray<uint> encodedDirections;
4545
internal void Encode() { encodedDirections = EncodeShadingDirection(shadingDirections); }
46-
46+
4747
static int k_MaxProbeCountPerBatch = 65535;
4848
static readonly int _SkyShadingPrecomputedDirection = Shader.PropertyToID("_SkyShadingPrecomputedDirection");
4949
static readonly int _SkyShadingDirections = Shader.PropertyToID("_SkyShadingDirections");
@@ -71,7 +71,7 @@ internal static NativeArray<uint> EncodeShadingDirection(NativeArray<Vector3> di
7171
{
7272
int batchOffset = batchIndex * k_MaxProbeCountPerBatch;
7373
int probeInBatch = Mathf.Min(probeCount - batchOffset, k_MaxProbeCountPerBatch);
74-
74+
7575
directionBuffer.SetData(directions, batchOffset, 0, probeInBatch);
7676

7777
cs.SetBuffer(kernel, _SkyShadingPrecomputedDirection, precomputedShadingDirections);
@@ -84,7 +84,7 @@ internal static NativeArray<uint> EncodeShadingDirection(NativeArray<Vector3> di
8484
var batchResult = directionResults.GetSubArray(batchOffset, probeInBatch);
8585
AsyncGPUReadback.RequestIntoNativeArray(ref batchResult, encodedBuffer, probeInBatch * sizeof(uint), 0).WaitForCompletion();
8686
}
87-
87+
8888
directionBuffer.Dispose();
8989
encodedBuffer.Dispose();
9090

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ static TouchupVolumeWithBoundsList GetAdjustementVolumes()
869869
touchup.skyDirection.Normalize();
870870
}
871871
}
872-
872+
873873
// Sort by volume to give priority to bigger volumes so smaller volumes are applied last
874874
touchupVolumesAndBounds.Sort((a, b) => (b.volume.ComputeVolume(b.obb).CompareTo(a.volume.ComputeVolume(a.obb))));
875875

@@ -1169,7 +1169,7 @@ class CacheEntry
11691169
CacheEntry BuildMap(in BakingCell cell)
11701170
{
11711171
var entry = m_BrickMetaPool.Get();
1172-
1172+
11731173
// Build a map from voxel to brick
11741174
// A voxel is the size of a brick at subdivision level 0
11751175
foreach (var brick in cell.bricks)
@@ -1192,7 +1192,7 @@ CacheEntry BuildMap(in BakingCell cell)
11921192

11931193
return entry;
11941194
}
1195-
1195+
11961196
public Dictionary<int, Brick> GetMap(in BakingCell cell)
11971197
{
11981198
if (!cache.TryGetValue(cell.index, out var entry))
@@ -1242,7 +1242,7 @@ static void FixSeams(NativeArray<int> positionRemap, NativeArray<Vector3> positi
12421242
float scale = m_ProfileInfo.minBrickSize / ProbeBrickPool.kBrickCellCount;
12431243
float minBrickSize = m_ProfileInfo.minBrickSize;
12441244
Brick largestBrick = default;
1245-
1245+
12461246
int numProbes = cell.probePositions.Length;
12471247
for (int probeIndex = 0; probeIndex < numProbes; ++probeIndex)
12481248
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public static Brick[] SubdivideCell(Vector3Int cellPosition, Bounds cellBounds,
239239
SubdivideSubCell(subVolume.bounds, subdivisionCtx, ctx, filteredContributors, overlappingProbeVolumes, subBrickSet);
240240
if (subBrickSet.Count == 0)
241241
continue;
242-
242+
243243
// Make sure no bricks with unwanted subdiv level are generated
244244
if (requireSubFiltering && !fastSubFiltering)
245245
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ void ProbeInvaliditySettingsGUI()
268268

269269
EditorGUILayout.Space();
270270
}
271-
271+
272272
bool RenameEvent(Rect rect, bool active, bool focused, int index, ref int renameIndex)
273273
{
274274
if (active)
@@ -398,7 +398,7 @@ void RenderingLayersSettingsGUI()
398398
else if (!supportsLayers && renderPipelineAssetType != null && renderPipelineAssetType.Name == "UniversalRenderPipelineAsset")
399399
{
400400
string message = "The current URP Asset does not support Light Layers.";
401-
401+
402402
CoreEditorUtils.DrawFixMeBox(message, MessageType.Warning, "Open", () =>
403403
{
404404
EditorUtility.OpenPropertyEditor(currentPipeline);

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,10 @@ public static bool ProbeVolumeSupportedForBuild()
4141
{
4242
bool supportProbeVolume = false;
4343

44-
using (ListPool<RenderPipelineAsset>.Get(out List<RenderPipelineAsset> rpAssets))
44+
foreach (var asset in CoreBuildData.instance.renderPipelineAssets)
4545
{
46-
if (UnityEditor.EditorUserBuildSettings.activeBuildTarget.TryGetRenderPipelineAssets<RenderPipelineAsset>(rpAssets))
47-
{
48-
foreach (var asset in rpAssets)
49-
{
50-
if (asset is IProbeVolumeEnabledRenderPipeline probeVolumeEnabledAsset)
51-
supportProbeVolume |= probeVolumeEnabledAsset.supportProbeVolume;
52-
}
53-
}
46+
if (asset is IProbeVolumeEnabledRenderPipeline probeVolumeEnabledAsset)
47+
supportProbeVolume |= probeVolumeEnabledAsset.supportProbeVolume;
5448
}
5549

5650
return supportProbeVolume;

Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeAdjustmentVolume.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public enum Mode
5757
/// <summary>Scale probe intensity.</summary>
5858
IntensityScale = 99, // make sure this appears last
5959
};
60-
60+
6161
/// <summary>The mode that adjustment volume will operate in. It determines what probes falling within the volume will do. </summary>
6262
public enum RenderingLayerMaskOperation
6363
{

Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeBrickIndex.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal class ProbeBrickIndex
3131
NativeArray<int> m_PhysicalIndexBufferData;
3232
ComputeBuffer m_DebugFragmentationBuffer;
3333
int[] m_DebugFragmentationData;
34-
34+
3535
bool m_NeedUpdateIndexComputeBuffer;
3636
int m_UpdateMinIndex = int.MaxValue;
3737
int m_UpdateMaxIndex = int.MinValue;
@@ -379,7 +379,7 @@ void MarkBrickInPhysicalBuffer(in IndirectionEntryUpdateInfo entry, Vector3Int b
379379
var entryMinIndex = entry.minValidBrickIndexForCellAtMaxRes / minBrickSize;
380380
var entryMaxIndex = entry.maxValidBrickIndexForCellAtMaxResPlusOne / minBrickSize;
381381
var sizeOfValid = (entryMaxIndex - entryMinIndex);
382-
382+
383383
if (brickSubdivLevel >= entrySubdivLevel)
384384
{
385385
brickMin = Vector3Int.zero;
@@ -407,14 +407,14 @@ void MarkBrickInPhysicalBuffer(in IndirectionEntryUpdateInfo entry, Vector3Int b
407407
brickMin -= entryMinIndex;
408408
brickMax -= entryMinIndex;
409409
}
410-
410+
411411
// Analytically compute min and max because doing it in the inner loop with Math.Min/Max is costly (not inlined)
412412
int chunkStart = entry.firstChunkIndex * kIndexChunkSize;
413413
int newMin = chunkStart + LocationToIndex(brickMin.x, brickMin.y, brickMin.z, sizeOfValid);
414414
int newMax = chunkStart + LocationToIndex(brickMax.x - 1, brickMax.y - 1, brickMax.z - 1, sizeOfValid);
415415
m_UpdateMinIndex = Math.Min(m_UpdateMinIndex, newMin);
416416
m_UpdateMaxIndex = Math.Max(m_UpdateMaxIndex, newMax);
417-
417+
418418
// Loop through all touched voxels
419419
for (int x = brickMin.x; x < brickMax.x; ++x)
420420
{
@@ -461,7 +461,7 @@ public void AddBricks(CellIndexInfo cellInfo, NativeArray<Brick> bricks, List<Ch
461461
int brickSize = ProbeReferenceVolume.CellSize(brick.subdivisionLevel);
462462
Vector3Int brickMin = brick.position;
463463
Vector3Int brickMax = brick.position + new Vector3Int(brickSize, brickSize, brickSize);
464-
464+
465465
// Find all entries that this brick touch (usually only one, but several in case of bigger bricks)
466466
foreach (var entry in cellInfo.updateInfo.entriesInfo)
467467
{

Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeBakingSet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct SerializedPerSceneCellList
148148
[SerializeField] internal int supportLayerMaskChunkSize;
149149
[SerializeField] internal int supportOffsetsChunkSize;
150150
[SerializeField] internal int supportDataChunkSize;
151-
151+
152152
internal bool bakedSkyOcclusion
153153
{
154154
get => bakedSkyOcclusionValue <= 0 ? false : true;
@@ -263,7 +263,7 @@ internal bool bakedSkyShadingDirection
263263
/// Bake sky shading direction.
264264
/// </summary>
265265
public bool skyOcclusionShadingDirection = false;
266-
266+
267267
[Serializable]
268268
internal struct ProbeLayerMask
269269
{

Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeGlobalSettings.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace UnityEngine.Rendering
44
{
55
[Serializable]
66
[SupportedOnRenderPipeline()]
7-
[Categorization.CategoryInfo(Name = "R: Probe Volume", Order = 1000), HideInInspector]
7+
[Categorization.CategoryInfo(Name = "R: Adaptive Probe Volumes", Order = 1000), HideInInspector]
88
class ProbeVolumeRuntimeResources : IRenderPipelineResources
99
{
1010
[SerializeField, HideInInspector]
@@ -23,7 +23,7 @@ class ProbeVolumeRuntimeResources : IRenderPipelineResources
2323

2424
[Serializable]
2525
[SupportedOnRenderPipeline()]
26-
[Categorization.CategoryInfo(Name = "R: Probe Volume", Order = 1000), HideInInspector]
26+
[Categorization.CategoryInfo(Name = "R: Adaptive Probe Volumes", Order = 1000), HideInInspector]
2727
class ProbeVolumeDebugResources : IRenderPipelineResources
2828
{
2929
[SerializeField, HideInInspector]
@@ -48,7 +48,7 @@ class ProbeVolumeDebugResources : IRenderPipelineResources
4848

4949
[Serializable]
5050
[SupportedOnRenderPipeline()]
51-
[Categorization.CategoryInfo(Name = "R: Probe Volume", Order = 1000), HideInInspector]
51+
[Categorization.CategoryInfo(Name = "R: Adaptive Probe Volumes", Order = 1000), HideInInspector]
5252
class ProbeVolumeBakingResources : IRenderPipelineResources
5353
{
5454
[SerializeField, HideInInspector]
@@ -82,7 +82,7 @@ class ProbeVolumeBakingResources : IRenderPipelineResources
8282

8383
[Serializable]
8484
[SupportedOnRenderPipeline()]
85-
[Categorization.CategoryInfo(Name = "Probe Volume", Order = 20)]
85+
[Categorization.CategoryInfo(Name = "Adaptive Probe Volumes", Order = 20)]
8686
class ProbeVolumeGlobalSettings : IRenderPipelineGraphicsSettings
8787
{
8888
[SerializeField, HideInInspector]

0 commit comments

Comments
 (0)