@@ -146,12 +146,14 @@ Vector3 GetSizeArray(MipLevel mip)
146146
147147 public void GenerateAOMap ( CommandBuffer cmd , Camera camera , RenderTargetIdentifier destination , RenderTargetIdentifier ? depthMap , bool invert , bool isMSAA )
148148 {
149+ bool isSinglePassStereo = camera . stereoEnabled && RuntimeUtilities . isSinglePassStereoEnabled ;
150+
149151 // Base size
150152#if UNITY_2017_3_OR_NEWER
151- m_ScaledWidths [ 0 ] = camera . scaledPixelWidth * ( RuntimeUtilities . isSinglePassStereoEnabled ? 2 : 1 ) ;
153+ m_ScaledWidths [ 0 ] = camera . scaledPixelWidth * ( isSinglePassStereo ? 2 : 1 ) ;
152154 m_ScaledHeights [ 0 ] = camera . scaledPixelHeight ;
153155#else
154- m_ScaledWidths [ 0 ] = camera . pixelWidth * ( RuntimeUtilities . isSinglePassStereoEnabled ? 2 : 1 ) ;
156+ m_ScaledWidths [ 0 ] = camera . pixelWidth * ( isSinglePassStereo ? 2 : 1 ) ;
155157 m_ScaledHeights [ 0 ] = camera . pixelHeight ;
156158#endif
157159
@@ -170,10 +172,10 @@ public void GenerateAOMap(CommandBuffer cmd, Camera camera, RenderTargetIdentifi
170172 PushDownsampleCommands ( cmd , camera , depthMap , isMSAA ) ;
171173
172174 float tanHalfFovH = CalculateTanHalfFovHeight ( camera ) ;
173- PushRenderCommands ( cmd , ShaderIDs . TiledDepth1 , ShaderIDs . Occlusion1 , GetSizeArray ( MipLevel . L3 ) , tanHalfFovH , isMSAA ) ;
174- PushRenderCommands ( cmd , ShaderIDs . TiledDepth2 , ShaderIDs . Occlusion2 , GetSizeArray ( MipLevel . L4 ) , tanHalfFovH , isMSAA ) ;
175- PushRenderCommands ( cmd , ShaderIDs . TiledDepth3 , ShaderIDs . Occlusion3 , GetSizeArray ( MipLevel . L5 ) , tanHalfFovH , isMSAA ) ;
176- PushRenderCommands ( cmd , ShaderIDs . TiledDepth4 , ShaderIDs . Occlusion4 , GetSizeArray ( MipLevel . L6 ) , tanHalfFovH , isMSAA ) ;
175+ PushRenderCommands ( cmd , ShaderIDs . TiledDepth1 , ShaderIDs . Occlusion1 , GetSizeArray ( MipLevel . L3 ) , tanHalfFovH , isMSAA , isSinglePassStereo ) ;
176+ PushRenderCommands ( cmd , ShaderIDs . TiledDepth2 , ShaderIDs . Occlusion2 , GetSizeArray ( MipLevel . L4 ) , tanHalfFovH , isMSAA , isSinglePassStereo ) ;
177+ PushRenderCommands ( cmd , ShaderIDs . TiledDepth3 , ShaderIDs . Occlusion3 , GetSizeArray ( MipLevel . L5 ) , tanHalfFovH , isMSAA , isSinglePassStereo ) ;
178+ PushRenderCommands ( cmd , ShaderIDs . TiledDepth4 , ShaderIDs . Occlusion4 , GetSizeArray ( MipLevel . L6 ) , tanHalfFovH , isMSAA , isSinglePassStereo ) ;
177179
178180 PushUpsampleCommands ( cmd , ShaderIDs . LowDepth4 , ShaderIDs . Occlusion4 , ShaderIDs . LowDepth3 , ShaderIDs . Occlusion3 , ShaderIDs . Combined3 , GetSize ( MipLevel . L4 ) , GetSize ( MipLevel . L3 ) , isMSAA ) ;
179181 PushUpsampleCommands ( cmd , ShaderIDs . LowDepth3 , ShaderIDs . Combined3 , ShaderIDs . LowDepth2 , ShaderIDs . Occlusion2 , ShaderIDs . Combined2 , GetSize ( MipLevel . L3 ) , GetSize ( MipLevel . L2 ) , isMSAA ) ;
@@ -290,7 +292,7 @@ void PushDownsampleCommands(CommandBuffer cmd, Camera camera, RenderTargetIdenti
290292 cmd . DispatchCompute ( cs , kernel , m_ScaledWidths [ ( int ) MipLevel . L6 ] , m_ScaledHeights [ ( int ) MipLevel . L6 ] , 1 ) ;
291293 }
292294
293- void PushRenderCommands ( CommandBuffer cmd , int source , int destination , Vector3 sourceSize , float tanHalfFovH , bool isMSAA )
295+ void PushRenderCommands ( CommandBuffer cmd , int source , int destination , Vector3 sourceSize , float tanHalfFovH , bool isMSAA , bool isSinglePassStereo )
294296 {
295297 // Here we compute multipliers that convert the center depth value into (the reciprocal
296298 // of) sphere thicknesses at each sample location. This assumes a maximum sample radius
@@ -309,7 +311,7 @@ void PushRenderCommands(CommandBuffer cmd, int source, int destination, Vector3
309311 // ScreenspaceDiameter: Diameter of sample sphere in pixel units
310312 // ScreenspaceDiameter / BufferWidth: Ratio of the screen width that the sphere actually covers
311313 float thicknessMultiplier = 2f * tanHalfFovH * kScreenspaceDiameter / sourceSize . x ;
312- if ( RuntimeUtilities . isSinglePassStereoEnabled )
314+ if ( isSinglePassStereo )
313315 thicknessMultiplier *= 2f ;
314316
315317 // This will transform a depth value from [0, thickness] to [0, 1].
0 commit comments