Skip to content

Commit 743602d

Browse files
authored
Fix issue with MultiScaleVO and Single Pass Stereo
Fixes an issue with MultiScaleVO showing incorrectly if XR and single pass stereo is enabled for a project, but the current camera not actually doing stereo rendering, like the scene view or when the HMD isn't active, or for "social" camera views.
1 parent 891a586 commit 743602d

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

PostProcessing/Runtime/Effects/MultiScaleVO.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,10 @@ Vector3 GetSizeArray(MipLevel mip)
145145

146146
public void GenerateAOMap(CommandBuffer cmd, Camera camera, RenderTargetIdentifier destination, RenderTargetIdentifier? depthMap, bool invert, bool isMSAA)
147147
{
148+
bool isSinglePassStereo = camera.stereoEnabled && RuntimeUtilities.isSinglePassStereoEnabled;
149+
148150
// Base size
149-
m_Widths[0] = camera.pixelWidth * (RuntimeUtilities.isSinglePassStereoEnabled ? 2 : 1);
151+
m_Widths[0] = camera.pixelWidth * (isSinglePassStereo ? 2 : 1);
150152
m_Heights[0] = camera.pixelHeight;
151153

152154
// L1 -> L6 sizes
@@ -163,11 +165,12 @@ public void GenerateAOMap(CommandBuffer cmd, Camera camera, RenderTargetIdentifi
163165
// Render logic
164166
PushDownsampleCommands(cmd, camera, depthMap, isMSAA);
165167

168+
166169
float tanHalfFovH = CalculateTanHalfFovHeight(camera);
167-
PushRenderCommands(cmd, ShaderIDs.TiledDepth1, ShaderIDs.Occlusion1, GetSizeArray(MipLevel.L3), tanHalfFovH, isMSAA);
168-
PushRenderCommands(cmd, ShaderIDs.TiledDepth2, ShaderIDs.Occlusion2, GetSizeArray(MipLevel.L4), tanHalfFovH, isMSAA);
169-
PushRenderCommands(cmd, ShaderIDs.TiledDepth3, ShaderIDs.Occlusion3, GetSizeArray(MipLevel.L5), tanHalfFovH, isMSAA);
170-
PushRenderCommands(cmd, ShaderIDs.TiledDepth4, ShaderIDs.Occlusion4, GetSizeArray(MipLevel.L6), tanHalfFovH, isMSAA);
170+
PushRenderCommands(cmd, ShaderIDs.TiledDepth1, ShaderIDs.Occlusion1, GetSizeArray(MipLevel.L3), tanHalfFovH, isMSAA, isSinglePassStereo);
171+
PushRenderCommands(cmd, ShaderIDs.TiledDepth2, ShaderIDs.Occlusion2, GetSizeArray(MipLevel.L4), tanHalfFovH, isMSAA, isSinglePassStereo);
172+
PushRenderCommands(cmd, ShaderIDs.TiledDepth3, ShaderIDs.Occlusion3, GetSizeArray(MipLevel.L5), tanHalfFovH, isMSAA, isSinglePassStereo);
173+
PushRenderCommands(cmd, ShaderIDs.TiledDepth4, ShaderIDs.Occlusion4, GetSizeArray(MipLevel.L6), tanHalfFovH, isMSAA, isSinglePassStereo);
171174

172175
PushUpsampleCommands(cmd, ShaderIDs.LowDepth4, ShaderIDs.Occlusion4, ShaderIDs.LowDepth3, ShaderIDs.Occlusion3, ShaderIDs.Combined3, GetSize(MipLevel.L4), GetSize(MipLevel.L3), isMSAA);
173176
PushUpsampleCommands(cmd, ShaderIDs.LowDepth3, ShaderIDs.Combined3, ShaderIDs.LowDepth2, ShaderIDs.Occlusion2, ShaderIDs.Combined2, GetSize(MipLevel.L3), GetSize(MipLevel.L2), isMSAA);
@@ -284,7 +287,7 @@ void PushDownsampleCommands(CommandBuffer cmd, Camera camera, RenderTargetIdenti
284287
cmd.DispatchCompute(cs, kernel, m_Widths[(int)MipLevel.L6], m_Heights[(int)MipLevel.L6], 1);
285288
}
286289

287-
void PushRenderCommands(CommandBuffer cmd, int source, int destination, Vector3 sourceSize, float tanHalfFovH, bool isMSAA)
290+
void PushRenderCommands(CommandBuffer cmd, int source, int destination, Vector3 sourceSize, float tanHalfFovH, bool isMSAA, bool isSinglePassStereo)
288291
{
289292
// Here we compute multipliers that convert the center depth value into (the reciprocal
290293
// of) sphere thicknesses at each sample location. This assumes a maximum sample radius
@@ -303,7 +306,7 @@ void PushRenderCommands(CommandBuffer cmd, int source, int destination, Vector3
303306
// ScreenspaceDiameter: Diameter of sample sphere in pixel units
304307
// ScreenspaceDiameter / BufferWidth: Ratio of the screen width that the sphere actually covers
305308
float thicknessMultiplier = 2f * tanHalfFovH * kScreenspaceDiameter / sourceSize.x;
306-
if (RuntimeUtilities.isSinglePassStereoEnabled)
309+
if (isSinglePassStereo)
307310
thicknessMultiplier *= 2f;
308311

309312
// This will transform a depth value from [0, thickness] to [0, 1].

0 commit comments

Comments
 (0)