@@ -146,12 +146,14 @@ Vector3 GetSizeArray(MipLevel mip)
146
146
147
147
public void GenerateAOMap ( CommandBuffer cmd , Camera camera , RenderTargetIdentifier destination , RenderTargetIdentifier ? depthMap , bool invert , bool isMSAA )
148
148
{
149
+ bool isSinglePassStereo = camera . stereoEnabled && RuntimeUtilities . isSinglePassStereoEnabled ;
150
+
149
151
// Base size
150
152
#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 ) ;
152
154
m_ScaledHeights [ 0 ] = camera . scaledPixelHeight ;
153
155
#else
154
- m_ScaledWidths [ 0 ] = camera . pixelWidth * ( RuntimeUtilities . isSinglePassStereoEnabled ? 2 : 1 ) ;
156
+ m_ScaledWidths [ 0 ] = camera . pixelWidth * ( isSinglePassStereo ? 2 : 1 ) ;
155
157
m_ScaledHeights [ 0 ] = camera . pixelHeight ;
156
158
#endif
157
159
@@ -170,10 +172,10 @@ public void GenerateAOMap(CommandBuffer cmd, Camera camera, RenderTargetIdentifi
170
172
PushDownsampleCommands ( cmd , camera , depthMap , isMSAA ) ;
171
173
172
174
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 ) ;
177
179
178
180
PushUpsampleCommands ( cmd , ShaderIDs . LowDepth4 , ShaderIDs . Occlusion4 , ShaderIDs . LowDepth3 , ShaderIDs . Occlusion3 , ShaderIDs . Combined3 , GetSize ( MipLevel . L4 ) , GetSize ( MipLevel . L3 ) , isMSAA ) ;
179
181
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
290
292
cmd . DispatchCompute ( cs , kernel , m_ScaledWidths [ ( int ) MipLevel . L6 ] , m_ScaledHeights [ ( int ) MipLevel . L6 ] , 1 ) ;
291
293
}
292
294
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 )
294
296
{
295
297
// Here we compute multipliers that convert the center depth value into (the reciprocal
296
298
// 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
309
311
// ScreenspaceDiameter: Diameter of sample sphere in pixel units
310
312
// ScreenspaceDiameter / BufferWidth: Ratio of the screen width that the sphere actually covers
311
313
float thicknessMultiplier = 2f * tanHalfFovH * kScreenspaceDiameter / sourceSize . x ;
312
- if ( RuntimeUtilities . isSinglePassStereoEnabled )
314
+ if ( isSinglePassStereo )
313
315
thicknessMultiplier *= 2f ;
314
316
315
317
// This will transform a depth value from [0, thickness] to [0, 1].
0 commit comments