Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal/master #8049

Merged
merged 64 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
be94b17
UUM-65995 - Disabled test due to instability
ElliottHUnity Mar 11, 2024
3ab94a6
[VFX] Fixed bad flex setting making all FloatField 1px height
julienamsellem Mar 12, 2024
128bad3
[2023.3][URP] CI fixes for URP PostPro project
ellioman Mar 12, 2024
0dda0b6
[URP][Metal] Improve MSL code generation for VRR
mcc-unity Mar 12, 2024
f11efe2
[VFX] Random Operator Improvements
PaulDemeulenaere Mar 12, 2024
35491ce
Support GPU occlusion culling for views with multiple subviews
simonb-unity Mar 12, 2024
2674a45
Added Additional Resources to URP Lighting docs
Richard-Horton Mar 12, 2024
3ee8733
[Jira # UUM-65676] Fix DRS issues on DoF and FSR1
Mar 12, 2024
5600a1d
Fix UUM-60651 - imported assets initialized with incorrect default ma…
kennytann Mar 12, 2024
4e55886
[Port forward] DOCG-4387/4547 Document and improve HDRP APV 2023.2
markg-unity Mar 12, 2024
be3fb64
[Port forward] DOCG-3539 Add Probe Volumes documentation to URP
markg-unity Mar 12, 2024
ab27cd3
Fixed GRD invalid state when changing rendererMode
Mar 12, 2024
ae09eb3
[HDRP] Fix warning when opening template
adrien-de-tocqueville Mar 12, 2024
f8d3cf1
Fix GSDET-14: Graphics Performance Test Framework requires it to be a…
giorgospetkakis Mar 13, 2024
b3a0629
Fix Default Resource Initialization for APV
johnpars Mar 13, 2024
60f9c32
Remove Apply and Reset mip bias in HDRP
alelievr Mar 13, 2024
31def23
Disable depth priming for cameras with depth only render targets
patrickp-unity3d Mar 13, 2024
4e3b5dc
Fix UUM-65629
kennytann Mar 13, 2024
674f537
DOCG-3358,4907,5119,4897 Add render graph system documentation
markg-unity Mar 13, 2024
f4b4a00
Edited the "Creating a new project" page so that it describes the ava…
oleks-k Mar 13, 2024
da70dcb
[VFX] Added tooltips on Control panel elements
julienamsellem Mar 13, 2024
fe85677
[Port forward] DOCG-5272 Replace APV Rendering Debugger images
markg-unity Mar 13, 2024
eac463f
[VFX] Error feedback implementation must not entangle UI and model code
julienamsellem Mar 14, 2024
e0d970a
[Core RP] Fix UUM-62724
RemyUnity Mar 14, 2024
2938c96
[APV] Add missing API to overwrite result of APV baking
adrien-de-tocqueville Mar 14, 2024
4a360ac
Fix GSDET-15: Exception in the TestSceneAssetEditor when TestSceneAss…
giorgospetkakis Mar 14, 2024
83d0284
Improve camera name displayed in Render Graph Viewer UI
arttu-peltonen Mar 15, 2024
aab6299
SpeedTree 9 - Workflow improvements
YohannVaastUnity Mar 15, 2024
e8eb370
gpudriven HDRP test stability fix
simonb-unity Mar 15, 2024
e4f6d1a
UUM-64908 Graphics/urp/fix for screencapturebridge with rendergraph
patrickp-unity3d Mar 15, 2024
8c3f50c
Fix core samples dependencies errors with Input system package
remi-chapelain Mar 15, 2024
6ceb643
[HDRP] Removed mention of unsupported tube and disc light in HDRP pat…
olivierprat Mar 15, 2024
07e54df
[VFX] Split rendering batches for exposed meshes
gabrieldelacruz Mar 17, 2024
14fe715
UUM-64943 Typo in Disable Pass Culling RenderGraph tooltip
RoseHirigoyen Mar 17, 2024
f5018c8
[VFX] UI Optimization to improve performance
julienamsellem Mar 18, 2024
c906606
[RPW] Prevent vfx graph reimport on the AssetImportWorkers
kirill-titov-u Mar 19, 2024
fc14c66
Fix DebugUI.Button not working in runtime UI
arttu-peltonen Mar 19, 2024
6be3fde
[VFX] Restore default timeout in prefab test
PaulDemeulenaere Mar 20, 2024
8ec2362
[VFX] Fix and optimize model invalidation
julienf-unity Mar 20, 2024
fc4e2ba
[VFX] Remove error popup when cancelling a drag edge with escape key
julienamsellem Mar 20, 2024
7f23d6b
Introduce GraphicsDeviceInfo and disable LightBaker tests
giorgospetkakis Mar 20, 2024
a8c1898
Fixed SRP lens flare rendering issue with Render Scale
JarkkoUnity Mar 20, 2024
1f86495
[2023.3][URP] Fixing an issue with incorrect matrix data when Scene a…
ellioman Mar 20, 2024
36123c3
Fix fullscreen material creation workflow from custom passes
alelievr Mar 20, 2024
fd3e454
Try to blind fix the NaN issue in fog
alelievr Mar 20, 2024
a13e423
DOCG-3077 Add and update URP/HDRP lens flare pages
markg-unity Mar 21, 2024
7f43a17
[content automatically redacted] touching PlatformDependent folder
Adrian1066 Mar 21, 2024
3a48e76
[VFX] Keep activation slot visible when collapsing a block
julienamsellem Mar 21, 2024
9f89323
Re-enable culling mask UI
ApoorvaJ Mar 21, 2024
65ce0e8
[VFX] Hide eye dropper from the ColorField
JMargevics Mar 21, 2024
cf6361f
SpeedTree 9 Shader error when opening a project
YohannVaastUnity Mar 21, 2024
8275544
Update package validation version 2023.3 to 6000.0 + Add Missing Plat…
giorgospetkakis Mar 21, 2024
177c2b6
Fix Render Graph Viewer warnings on HDRP due to duplicate pass names
arttu-peltonen Mar 21, 2024
b67f093
Add change indicator to Color Curves component
arttu-peltonen Mar 22, 2024
6825230
Fix URP & HDRP material UI leaking LabelWidth state
arttu-peltonen Mar 22, 2024
1faefc5
Fix opening "Project Settings > Graphics" caused RG Viewer to become …
arttu-peltonen Mar 22, 2024
7ae738d
[6000][UUM-67306] Fix macOS flickering for 2D Renderer
kennytann Mar 22, 2024
20c0523
URP: Ensure ScriptableRendererFeatures are compiled before validating…
amsXYZ Mar 23, 2024
5a94418
Fix UUM-43568 - Discrepancy between the Render Texture and the actual…
EvgeniiG Mar 23, 2024
b270818
[2023.3][URP] Fixing a NullReferenceException when logging an error i…
ellioman Mar 23, 2024
c819ba2
[VFX] Add support for more HLSL function prototype declaration
julienamsellem Mar 23, 2024
d7cde5b
Move motion rendering order back to after opaques.
eh-unity Mar 23, 2024
3e21143
Fix ref image and modify comparison settings
alelievr Mar 24, 2024
f6b9768
Fixed recorder with DRS
alelievr Mar 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,43 @@ void MainRayGenShader(

RayGenExecute(dispatchInfo);
}

#pragma kernel EncodeShadingDirection

StructuredBuffer<float3> _SkyShadingPrecomputedDirection;
StructuredBuffer<float3> _SkyShadingDirections;
RWStructuredBuffer<uint> _SkyShadingIndices;

uint _ProbeCount;

uint LinearSearchClosestDirection(float3 direction)
{
int indexMax = 255;
float bestDot = -10.0f;
int bestIndex = 0;

for (int index=0; index< indexMax; index++)
{
float currentDot = dot(direction, _SkyShadingPrecomputedDirection[index]);
if (currentDot > bestDot)
{
bestDot = currentDot;
bestIndex = index;
}
}
return bestIndex;
}

[numthreads(64, 1, 1)]
void EncodeShadingDirection(uint probeId : SV_DispatchThreadID)
{
if (probeId >= _ProbeCount)
return;

uint bestDirectionIndex = 255;
float norm = length(_SkyShadingDirections[probeId]);
if (norm > 0.0001f)
bestDirectionIndex = LinearSearchClosestDirection(_SkyShadingDirections[probeId] / norm);

_SkyShadingIndices[probeId] = bestDirectionIndex;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,8 @@ int _BackFaceCulling;
int _BakeSkyShadingDirection;

StructuredBuffer<float3> _ProbePositions;
StructuredBuffer<float3> _SkyShadingPrecomputedDirection;
RWStructuredBuffer<float4> _SkyOcclusionOut;
RWStructuredBuffer<float3> _SkyShadingOut;
RWStructuredBuffer<uint> _SkyShadingDirectionIndexOut;


uint LinearSearchClosestDirection(float3 direction)
{
int indexMax = 255;
float bestDot = -10.0f;
int bestIndex = 0;

for (int index=0; index< indexMax; index++)
{
float currentDot = dot(direction, _SkyShadingPrecomputedDirection[index]);
if (currentDot > bestDot)
{
bestDot = currentDot;
bestIndex = index;
}
}
return bestIndex;
}


void RayGenExecute(UnifiedRT::DispatchInfo dispatchInfo)
{
Expand Down Expand Up @@ -168,23 +146,5 @@ void RayGenExecute(UnifiedRT::DispatchInfo dispatchInfo)
// The 1.125f exponent comes from experimental testing. It's the value that works the best when trying to match a bake and deringing done with the lightmapper, but it has no theoretical explanation.
// In the future, we should replace these custom windowing and deringing operations with the ones used in the lightmapper to implement a more academical solution.
_SkyOcclusionOut[probeId].yzw *= lerp(1.0f, radianceToIrradianceFactor, pow(windowL1, 1.125f));


// Normalize computed direction
if (_BakeSkyShadingDirection > 0)
{
uint bestDirectionIndex = 255;
float norm = length(_SkyShadingOut[probeId]);
if (norm > 0.0001f)
{
_SkyShadingOut[probeId] /= norm;
bestDirectionIndex = LinearSearchClosestDirection(_SkyShadingOut[probeId]);
}
else
{
_SkyShadingOut[probeId] = float3(0.0f, 0.0f, 0.0f);
}
_SkyShadingDirectionIndexOut[probeId] = bestDirectionIndex;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ static void DrawBakingHelpers(SerializedProbeAdjustmentVolume p, Editor owner)
using (new EditorGUI.DisabledScope(bakingSet == null))
{
if (GUILayout.Button(Styles.s_PreviewLighting))
ProbeGIBaking.BakeAdjustmentVolume(bakingSet, ptv);
AdaptiveProbeVolumes.BakeAdjustmentVolume(bakingSet, ptv);

ProbeVolumeLightingTab.BakeAPVButton();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System.Collections.Generic;
using UnityEditor;

using Cell = UnityEngine.Rendering.ProbeReferenceVolume.Cell;

namespace UnityEngine.Rendering
{
partial class ProbeGIBaking
partial class AdaptiveProbeVolumes
{
static ComputeShader dilationShader;
static int dilationKernel = -1;
Expand All @@ -16,6 +19,13 @@ static void InitDilationShaders()
}
}

static void GetProbeAndChunkIndex(int globalProbeIndex, out int chunkIndex, out int chunkProbeIndex)
{
var chunkSizeInProbeCount = ProbeBrickPool.GetChunkSizeInProbeCount();
chunkIndex = globalProbeIndex / chunkSizeInProbeCount;
chunkProbeIndex = globalProbeIndex - chunkIndex * chunkSizeInProbeCount;
}

[GenerateHLSL(needAccessors = false)]
struct DilatedProbe
{
Expand Down Expand Up @@ -97,10 +107,7 @@ internal void ToSphericalHarmonicsShaderConstants(ProbeReferenceVolume.Cell cell
if (cellChunkData.skyOcclusionDataL0L1.Length != 0)
WriteToShaderSkyOcclusion(SO_L0L1, cellChunkData.skyOcclusionDataL0L1, index * 4);
if (cellChunkData.skyShadingDirectionIndices.Length != 0)
{
var directions = DynamicSkyPrecomputedDirections.GetPrecomputedDirections();
cellChunkData.skyShadingDirectionIndices[index] = (byte)LinearSearchClosestDirection(directions, SO_Direction);
}
cellChunkData.skyShadingDirectionIndices[index] = (byte)SkyOcclusionBaker.EncodeSkyShadingDirection(SO_Direction);
}
}

Expand Down Expand Up @@ -167,6 +174,112 @@ public void Dispose()
static readonly int _DilationParameters2 = Shader.PropertyToID("_DilationParameters2");
static readonly int _OutputProbes = Shader.PropertyToID("_OutputProbes");

// Can definitively be optimized later on.
// Also note that all the bookkeeping of all the reference volumes will likely need to change when we move to
// proper UX.
internal static void PerformDilation()
{
var prv = ProbeReferenceVolume.instance;
var perSceneDataList = prv.perSceneDataList;
if (perSceneDataList.Count == 0) return;
SetBakingContext(perSceneDataList);

List<Cell> tempLoadedCells = new List<Cell>();

if (m_BakingSet.hasDilation)
{
var dilationSettings = m_BakingSet.settings.dilationSettings;

// Make sure all assets are loaded.
prv.PerformPendingOperations();

// TODO: This loop is very naive, can be optimized, but let's first verify if we indeed want this or not.
for (int iterations = 0; iterations < dilationSettings.dilationIterations; ++iterations)
{
// Try to load all available cells to the GPU. Might not succeed depending on the memory budget.
prv.LoadAllCells();

// Dilate all cells
List<Cell> dilatedCells = new List<Cell>(prv.cells.Values.Count);
bool everythingLoaded = !prv.hasUnloadedCells;

if (everythingLoaded)
{
foreach (var cell in prv.cells.Values)
{
if (m_CellsToDilate.ContainsKey(cell.desc.index))
{
PerformDilation(cell, m_BakingSet);
dilatedCells.Add(cell);
}
}
}
else
{
// When everything does not fit in memory, we are going to dilate one cell at a time.
// To do so, we load the cell and all its neighbours and then dilate.
// This is an inefficient use of memory but for now most of the time is spent in reading back the result anyway so it does not introduce any performance regression.

// Free All memory to make room for each cell and its neighbors for dilation.
prv.UnloadAllCells();

foreach (var cell in prv.cells.Values)
{
if (!m_CellsToDilate.ContainsKey(cell.desc.index))
continue;

var cellPos = cell.desc.position;
// Load the cell and all its neighbors before doing dilation.
for (int x = -1; x <= 1; ++x)
{
for (int y = -1; y <= 1; ++y)
{
for (int z = -1; z <= 1; ++z)
{
Vector3Int pos = cellPos + new Vector3Int(x, y, z);
if (m_CellPosToIndex.TryGetValue(pos, out var cellToLoadIndex))
{
if (prv.cells.TryGetValue(cellToLoadIndex, out var cellToLoad))
{
if (prv.LoadCell(cellToLoad))
{
tempLoadedCells.Add(cellToLoad);
}
else
Debug.LogError($"Not enough memory to perform dilation for cell {cell.desc.index}");
}
}
}
}
}

PerformDilation(cell, m_BakingSet);
dilatedCells.Add(cell);

// Free memory again.
foreach (var cellToUnload in tempLoadedCells)
prv.UnloadCell(cellToUnload);
tempLoadedCells.Clear();
}
}

// Now write back the assets.
WriteDilatedCells(dilatedCells);

AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

// Reload data
foreach (var sceneData in perSceneDataList)
{
sceneData.QueueSceneRemoval();
sceneData.QueueSceneLoading();
}
prv.PerformPendingOperations();
}
}
}

static void PerformDilation(ProbeReferenceVolume.Cell cell, ProbeVolumeBakingSet bakingSet)
{
InitDilationShaders();
Expand Down Expand Up @@ -235,5 +348,36 @@ static void PerformDilation(ProbeReferenceVolume.Cell cell, ProbeVolumeBakingSet
data.ExtractDilatedProbes();
data.Dispose();
}

// NOTE: This is somewhat hacky and is going to likely be slow (or at least slower than it could).
// It is only a first iteration of the concept that won't be as impactful on memory as other options.
internal static void RevertDilation()
{
if (m_BakingSet == null)
{
if (ProbeReferenceVolume.instance.perSceneDataList.Count == 0) return;
SetBakingContext(ProbeReferenceVolume.instance.perSceneDataList);
}

var dilationSettings = m_BakingSet.settings.dilationSettings;
var blackProbe = new SphericalHarmonicsL2();

int chunkSizeInProbes = ProbeBrickPool.GetChunkSizeInProbeCount();
foreach (var cell in ProbeReferenceVolume.instance.cells.Values)
{
for (int i = 0; i < cell.data.validity.Length; ++i)
{
if (dilationSettings.enableDilation && dilationSettings.dilationDistance > 0.0f && cell.data.validity[i] > dilationSettings.dilationValidityThreshold)
{
GetProbeAndChunkIndex(i, out var chunkIndex, out var index);

var cellChunkData = GetCellChunkData(cell.data, chunkIndex);

WriteToShaderCoeffsL0L1(blackProbe, cellChunkData.shL0L1RxData, cellChunkData.shL1GL1RyData, cellChunkData.shL1BL1RzData, index * 4);
WriteToShaderCoeffsL2(blackProbe, cellChunkData.shL2Data_0, cellChunkData.shL2Data_1, cellChunkData.shL2Data_2, cellChunkData.shL2Data_3, index * 4);
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Jobs;
using System;

namespace UnityEngine.Rendering
{
partial class ProbeGIBaking
partial class AdaptiveProbeVolumes
{
// We use this scratch memory as a way of spoofing the texture.
static DynamicArray<float> s_Validity_locData = new DynamicArray<float>();
Expand Down
Loading
Loading