Skip to content

Commit

Permalink
Merge pull request #8042 from Unity-Technologies/internal/2023.2/staging
Browse files Browse the repository at this point in the history
Internal/2023.2/staging
  • Loading branch information
UnityAljosha authored Mar 11, 2024
2 parents 6daa9bf + df602a8 commit fc4c55d
Show file tree
Hide file tree
Showing 111 changed files with 10,129 additions and 1,154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ static void PerformDilation(ProbeReferenceVolume.Cell cell, ProbeDilationSetting
cmd.SetComputeBufferParam(dilationShader, dilationKernel, _OutputProbes, data.outputProbes);
cmd.SetComputeBufferParam(dilationShader, dilationKernel, _NeedDilating, data.needDilatingBuffer);

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

cmd.SetComputeVectorParam(dilationShader, _DilationParameters, new Vector4(probeCount, settings.dilationValidityThreshold, settings.dilationDistance, ProbeReferenceVolume.instance.MinBrickSize()));
cmd.SetComputeVectorParam(dilationShader, _DilationParameters2, new Vector4(settings.squaredDistWeighting ? 1 : 0, 0, 0, 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,12 +598,23 @@ public Vector2Int GetLastScaledSize()
/// This allows the caller to directly compare the float result safely with the floating point target resolution.
/// </param>
/// <returns>Returns the resolved low res multiplier based on the low transparency threshold settings.</returns>
public float GetLowResMultiplier(float targetLowRes)
public float GetLowResMultiplier(float targetLowRes) => GetLowResMultiplier(targetLowRes, m_CachedSettings.lowResTransparencyMinimumThreshold );

/// <summary>
/// Returns the resolved low res multiplier based on the a low res threshold.
/// </summary>
/// <param name="targetLowRes"> the target low resolution.
/// If by any chance thresholding is disabled or clamped, the exact same resolution is returned.
/// This allows the caller to directly compare the float result safely with the floating point target resolution.
/// </param>
/// <param name="minimumThreshold"> The custom threshold used to clamp the effect's resolution. </param>
/// <returns>Returns the resolved low res multiplier based on the minimumThreshold threshold settings.</returns>
public float GetLowResMultiplier(float targetLowRes, float minimumThreshold)
{
if (!m_Enabled)
return targetLowRes;

float thresholdPercentage = Math.Min(m_CachedSettings.lowResTransparencyMinimumThreshold / 100.0f, targetLowRes);
float thresholdPercentage = Math.Min(minimumThreshold / 100.0f, targetLowRes);
float targetPercentage = targetLowRes * m_CurrentFraction;
if (targetPercentage >= thresholdPercentage)
return targetLowRes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,8 @@ public struct GlobalDynamicResolutionSettings

/// <summary>The minimum percentage threshold allowed to render ray tracing effects at half resolution. When the resolution percentage falls below this threshold, HDRP will render ray tracing effects at full resolution.</summary>
public float rayTracingHalfResThreshold;

/// <summary>The minimum percentage threshold allowed to clamp low resolution for SSGI (Screen Space Global Illumination). When the resolution percentage falls below this threshold, HDRP will clamp the low resolution to this percentage.</summary>
public float lowResSSGIMinimumThreshold;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ class RenderFragmentationOverlayPassData
/// <param name="debugOverlay"></param>
public void RenderFragmentationOverlay(RenderGraph renderGraph, TextureHandle colorBuffer, TextureHandle depthBuffer, DebugOverlay debugOverlay)
{
if (!probeVolumeDebug.displayIndexFragmentation)
if (!m_ProbeReferenceVolumeInit || !probeVolumeDebug.displayIndexFragmentation)
return;

using (var builder = renderGraph.AddRenderPass<RenderFragmentationOverlayPassData>("APVFragmentationOverlay", out var passData))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,26 @@ internal void RegisterPerSceneData(ProbeVolumePerSceneData data)
perSceneDataList.Add(data);
}

/// <summary>
/// Set the currently active baking set.
/// Can be used when loading additively two scenes belonging to different baking sets to control which one is active
/// </summary>
/// <param name="bakingSet">The baking set to load.</param>
public void SetActiveBakingSet(ProbeVolumeBakingSet bakingSet)
{
if (m_CurrentBakingSet == bakingSet)
return;

foreach (var data in perSceneDataList)
data.QueueSceneRemoval();

UnloadBakingSet();
SetBakingSetAsCurrent(bakingSet);

foreach (var data in perSceneDataList)
data.QueueSceneLoading();
}

void SetBakingSetAsCurrent(ProbeVolumeBakingSet bakingSet)
{
m_CurrentBakingSet = bakingSet;
Expand All @@ -797,39 +817,31 @@ internal void RegisterBakingSet(ProbeVolumePerSceneData data)
{
SetBakingSetAsCurrent(sceneData.GetBakingSetForScene(data.sceneGUID));
}
else
{
Debug.Assert(perSceneDataList.Count > 0);
var sceneBakingSet = sceneData.GetBakingSetForScene(data.sceneGUID); // It can be null if the scene was never added to a baking set and we are baking in single scene mode, in that case we don't have a baking set for it yet and we need to skip
}

internal void UnloadBakingSet()
{
// Need to make sure everything is unloaded before killing the baking set ref (we need it to unload cell CPU data).
PerformPendingOperations();

if (sceneBakingSet != null && !string.IsNullOrEmpty(data.sceneGUID) && sceneBakingSet != m_CurrentBakingSet)
{
Debug.LogError("Trying to load a scene from a different baking set than the currently loaded scenes.");
// TODO manage this error (since it's done late because of stupid random init order, the PerSceneData is already in the system...)
}
if (m_CurrentBakingSet != null)
m_CurrentBakingSet.Cleanup();
m_CurrentBakingSet = null;
m_CurrGlobalBounds = new Bounds();

// Restart pool from zero to avoid unnecessary memory consumption when going from a big to a small scene.
if (m_ScratchBufferPool != null)
{
m_ScratchBufferPool.Cleanup();
m_ScratchBufferPool = null;
}
}

internal void UnregisterPerSceneData(ProbeVolumePerSceneData data)
{
perSceneDataList.Remove(data);
if (perSceneDataList.Count == 0)
{
// Need to make sure everything is unloaded before killing the baking set ref (we need it to unload cell CPU data).
PerformPendingOperations();

if (m_CurrentBakingSet != null)
m_CurrentBakingSet.Cleanup();
m_CurrentBakingSet = null;
m_CurrGlobalBounds = new Bounds();

// Restart pool from zero to avoid unnecessary memory consumption when going from a big to a small scene.
if (m_ScratchBufferPool != null)
{
m_ScratchBufferPool.Cleanup();
m_ScratchBufferPool = null;
}
}
UnloadBakingSet();
}

internal float indexFragmentationRate { get => m_Index.fragmentationRate; }
Expand Down Expand Up @@ -1223,25 +1235,21 @@ internal void AddPendingSceneLoading(string sceneGUID)

if (m_CurrentBakingSet != null && bakingSet != m_CurrentBakingSet)
{
Debug.LogError($"Trying to load Probe Volume data for a scene from a different baking set than currently loaded ones. " +
$"Please make sure all loaded scenes are in the same baking set.");
// Trying to load data for a scene from a different baking set than currently loaded ones.
// This should not throw an error, but it's not supported
return;
}

// If we don't have any loaded asset yet, we need to verify the other queued assets.
// Only need to check one entry here, they should all have the same baking set by construction.
if (m_PendingScenesToBeLoaded.Count != 0)
{
foreach(var scene in m_PendingScenesToBeLoaded.Keys)
{
var toBeLoadedBakingSet = sceneData.GetBakingSetForScene(scene);
if (bakingSet != toBeLoadedBakingSet)
{
Debug.LogError($"Trying to load Probe Volume data for a scene from a different baking set from other scenes that are being loaded. " +
$"Please make sure all loaded scenes are in the same baking set.");
return;
}

// Only need to check one entry here, they should all have the same baking set by construction.
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ namespace Threading
TYPE PrefixProduct(TYPE v); \
TYPE ReadLaneAt(TYPE v, uint i); \
TYPE ReadLaneFirst(TYPE v); \
TYPE ReadLaneShuffle(TYPE v, uint i); \

// Currently just support scalars.
DECLARE_API_FOR_TYPE(uint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ namespace Threading
TYPE Wave::PrefixProduct (TYPE v) { EMULATED_WAVE_PREFIX(TYPE, *, (TYPE)1) } \
TYPE Wave::ReadLaneAt(TYPE v, uint i) { GroupMemoryBarrierWithGroupSync(); g_Scratch[indexG] = asuint(v); GroupMemoryBarrierWithGroupSync(); return as##TYPE(g_Scratch[offset + i]); } \
TYPE Wave::ReadLaneFirst(TYPE v) { return ReadLaneAt(v, 0u); } \
TYPE Wave::ReadLaneShuffle(TYPE v, uint i) { return ReadLaneAt(v, i); } \

// Currently just support scalars.
DEFINE_API_FOR_TYPE(uint)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#ifndef THREADING_SM6_IMPL
#define THREADING_SM6_IMPL

// If a special definition for WaveReadLaneShuffle is not provided, we assume that the WaveReadLaneAt function is capable
// of handling a lane index value that varies per lane.
#if !defined(WaveReadLaneShuffle)
#define WaveReadLaneShuffle WaveReadLaneAt
#endif

namespace Threading
{
// Currently we only cover scalar types as at the time of writing this utility library we only needed emulation for those.
Expand Down Expand Up @@ -34,7 +28,6 @@ namespace Threading
TYPE Wave::PrefixProduct(TYPE v) { return WavePrefixProduct(v); } \
TYPE Wave::ReadLaneAt(TYPE v, uint i) { return WaveReadLaneAt(v, i); } \
TYPE Wave::ReadLaneFirst(TYPE v) { return WaveReadLaneFirst(v); } \
TYPE Wave::ReadLaneShuffle(TYPE v, uint i) { return WaveReadLaneShuffle(v, i); } \

// Currently just support scalars.
DEFINE_API_FOR_TYPE(uint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ void kReadLaneAtShuffle(Group group)

const uint laneValue = DATA & (wave.GetLaneCount() - 1);

const uint result = (wave.ReadLaneShuffle(laneValue, laneValue) == laneValue);
const uint result = (wave.ReadLaneAt(laneValue, laneValue) == laneValue);

_Output.Store(OUTPUT_ADDR, result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,17 @@ These settings control the draw distance and resolution of the decals atlas that
### Light Probe Lighting
Use these settings in the **Quality** > **HDRP** menu to configure [Probe Volumes](probevolumes.md).

| **Property** | **Description** |
|---------------------------------|-----------------------------------------------------------------|
| **Light Probe System** | &#8226; **Light Probe Groups (Legacy)**: Use the same [Light Probe Group system](https://docs.unity3d.com/Manual/class-LightProbeGroup.html) as the Built-In Render Pipeline. <br/> &#8226; **Probe Volumes**: Use [Probe Volumes](probevolumes.md). |
| **Memory Budget** | Limits the width and height of the textures that store baked Global Illumination data, which determines the amount of memory Unity sets aside to store baked Probe Volume data. These textures have a fixed depth.<br/>Options: <br/>&#8226; **Memory Budget Low**<br/>&#8226; **Memory Budget Medium**<br/>&#8226; **Memory Budget High** |
| **Scenario Blending Memory Budget** | Limits the width and height of the textures that Unity uses to blend between Lighting Scenarios. This determines the amount of memory Unity sets aside to store Lighting Scenario blending data, and store data while doing the blending operation. These textures have a fixed depth. <br/>Options: <br/> &#8226; **Memory Budget Low**<br/> &#8226; **Memory Budget Medium**<br/> &#8226; **Memory Budget High** | |
| **SH Bands** | Determines the [spherical harmonics (SH) bands](https://docs.unity3d.com/Manual/LightProbes-TechnicalInformation.html) Unity uses to store probe data. L2 provides more precise results, but uses more system resources.<br/>Options: <br/>&#8226; **Spherical Harmonics L1** (default)<br/> &#8226; **Spherical Harmonics L2** |
| **Enable Streaming** | Enable to use [streaming](probevolumes-streaming.md). |
| **Estimated GPU Memory Cost** | Indicates the amount of Global Illumination and scenario blending texture data associated with Probe Volumes in your project.|
| **Property** | **Sub-property** | **Description** |
|-|-|-|
| **Light Probe System** || &#8226; **Light Probe Groups (Legacy)**: Use the same [Light Probe Group system](https://docs.unity3d.com/Manual/class-LightProbeGroup.html) as the Built-In Render Pipeline. <br/> &#8226; **Probe Volumes**: Use [Probe Volumes](probevolumes.md). |
| **Memory Budget** || Limits the width and height of the textures that store baked Global Illumination data, which determines the amount of memory Unity sets aside to store baked Probe Volume data. These textures have a fixed depth.<br/>Options: <br/>&#8226; **Memory Budget Low**<br/>&#8226; **Memory Budget Medium**<br/>&#8226; **Memory Budget High** |
| **SH Bands** || Determines the [spherical harmonics (SH) bands](https://docs.unity3d.com/Manual/LightProbes-TechnicalInformation.html) Unity uses to store probe data. L2 provides more precise results, but uses more system resources.<br/>Options: <br/>&#8226; **Spherical Harmonics L1** (default)<br/> &#8226; **Spherical Harmonics L2** |
| **Lighting Scenarios** || Enable to use Lighting Scenarios. Refer to [Bake different lighting setups using Lighting Scenarios](probevolumes-bakedifferentlightingsetups.md) for more information. |
|| **Scenario Blending** | Enable blending between different Lighting Scenarios. This uses more memory and makes rendering slower. |
|| **Scenario Blending Memory Budget** | Limits the width and height of the textures that Unity uses to blend between Lighting Scenarios. This determines the amount of memory Unity sets aside to store Lighting Scenario blending data, and store data while doing the blending operation. These textures have a fixed depth. <br/>Options: <br/> &#8226; **Memory Budget Low**<br/> &#8226; **Memory Budget Medium**<br/> &#8226; **Memory Budget High** |
| **Enable GPU Streaming** || Enable to stream Probe Volume data from CPU memory to GPU memory at runtime. Refer to [Streaming Probe Volumes](probevolumes-streaming.md) for more information. |
| **Enable Disk Streaming** || Enable to stream Probe Volume data from disk to CPU memory at runtime. [Streaming Probe Volumes](probevolumes-streaming.md) for more information. |
| **Estimated GPU Memory Cost** || Indicates the amount of texture data used by Probe Volumes in your project. This includes textures used both for Global Illumination and Lighting Scenario blending. |

### Cookies

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,18 @@
* [Use contact shadows](Override-Contact-Shadows.md)
* [Use micro shadows](Override-Micro-Shadows.md)
* [Probe Volumes](probevolumes.md)
* [Understand Probe Volumes](probevolumes-concept.md)
* [Understanding probe volumes](probevolumes-concept.md)
* [Use Probe Volumes](probevolumes-use.md)
* [Display and adjust Probe Volumes](probevolumes-showandadjust.md)
* [Fix issues with Probe Volumes](probevolumes-fixissues.md)
* [Display Probe Volumes](probevolumes-showandadjust.md)
* [Configure the size and density of Probe Volumes](probevolumes-changedensity.md)
* [Bake multiple scenes together with Baking Sets](probevolumes-usebakingsets.md)
* [Bake different lighting setups with Lighting Scenarios](probevolumes-bakedifferentlightingsetups)
* [Streaming](probevolumes-streaming.md)
* [Probe Volume settings and properties](probevolumes-settings.md)
* [Fix issues with Probe Volumes](probevolumes-fixissues.md)
* [Probe Volume Inspector window reference](probevolumes-inspector-reference.md)
* [Probe Volumes panel reference](probevolumes-lighting-panel-reference.md)
* [Probe Volumes Options Override reference](probevolumes-options-override-reference.md)
* [Probe Adjustment Volume component reference](probevolumes-adjustment-volume-component-reference.md)
* [Ray tracing](ray-tracing.md)
* [Set up ray tracing](Ray-Tracing-Getting-Started.md)
* [Implement ray tracing with shader graph](SGNode-Raytracing-Quality.md)
Expand Down
Loading

0 comments on commit fc4c55d

Please sign in to comment.