Skip to content

Commit 8b2c5d5

Browse files
ludovic-theobaldEvergreen
authored andcommitted
[VFX] Fix Volumetric Fog Output with multiple outputs
When using multiple Volumetric Fog Outputs in a single system, the buffers `outputBuffer` and `maxSliceCount` were shared between the outputs, which was incorrect. It was leading to GPU hangs on some platforms, and to an excessive amount of slices being drawn on all platforms. This PR makes sure that each output is working on its own set of buffers. Renderdoc screenshots of the draw calls: - Before : the quad count is the same of both draw calls and is the sum of the two required quad count for each output ->Wrong ![image](https://media.github.cds.internal.unity3d.com/user/2768/files/58ce7d7c-b618-4428-8c8e-31d5e4ac2f78) - After : the quad count is different for each draw call and matches the number of required slices for each output -> Correct ![image](https://media.github.cds.internal.unity3d.com/user/2768/files/532e4d8d-3a4f-43ac-b4cb-2fcab81ca758)
1 parent 6067db0 commit 8b2c5d5

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

Packages/com.unity.visualeffectgraph/Editor/Data/VFXDataParticle.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,25 @@ public override void FillDescs(
998998
groupIndex++;
999999
}
10001000

1001+
if (needsIndirectBuffer)
1002+
{
1003+
// Assign a task group to tasks coming from an output without VFXOutputUpdate but that have an indirect buffer
1004+
foreach (var output in indirectOutputHasTaskDependency)
1005+
{
1006+
bool incrementGroupIndex = false;
1007+
foreach (var task in compiledData.contextToCompiledData[output].tasks)
1008+
{
1009+
if (taskGroups.ContainsKey(task)) //output already handled through its VFXOutputUpdate above.
1010+
break;
1011+
incrementGroupIndex = true;
1012+
taskGroups[task] = groupIndex;
1013+
}
1014+
1015+
if (incrementGroupIndex)
1016+
groupIndex++;
1017+
}
1018+
}
1019+
10011020
// Allocate the buffers based on their binding order in the tasks
10021021
uint prefixIndex = 0;
10031022
foreach (var context in m_Contexts)

Packages/com.unity.visualeffectgraph/Runtime/Utilities/SDF/MeshToSDFBaker.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,12 @@ void InitTextures()
349349

350350
CreateRenderTextureIfNeeded(ref m_textureVoxel, rtDesc4Channels);
351351
CreateRenderTextureIfNeeded(ref m_textureVoxelBis, rtDesc4Channels);
352-
m_RayMaps = new RenderTexture[2];
353-
m_SignMaps = new RenderTexture[2];
352+
353+
if(m_RayMaps == null)
354+
m_RayMaps = new RenderTexture[2];
355+
if(m_SignMaps == null)
356+
m_SignMaps = new RenderTexture[2];
357+
354358
for (int i = 0; i < 2; i++)
355359
{
356360
CreateRenderTextureIfNeeded(ref m_RayMaps[i], rtDesc4Channels);

0 commit comments

Comments
 (0)