@@ -145,8 +145,10 @@ Vector3 GetSizeArray(MipLevel mip)
145
145
146
146
public void GenerateAOMap ( CommandBuffer cmd , Camera camera , RenderTargetIdentifier destination , RenderTargetIdentifier ? depthMap , bool invert , bool isMSAA )
147
147
{
148
+ bool isSinglePassStereo = camera . stereoEnabled && RuntimeUtilities . isSinglePassStereoEnabled ;
149
+
148
150
// Base size
149
- m_Widths [ 0 ] = camera . pixelWidth * ( RuntimeUtilities . isSinglePassStereoEnabled ? 2 : 1 ) ;
151
+ m_Widths [ 0 ] = camera . pixelWidth * ( isSinglePassStereo ? 2 : 1 ) ;
150
152
m_Heights [ 0 ] = camera . pixelHeight ;
151
153
152
154
// L1 -> L6 sizes
@@ -163,11 +165,12 @@ public void GenerateAOMap(CommandBuffer cmd, Camera camera, RenderTargetIdentifi
163
165
// Render logic
164
166
PushDownsampleCommands ( cmd , camera , depthMap , isMSAA ) ;
165
167
168
+
166
169
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 ) ;
171
174
172
175
PushUpsampleCommands ( cmd , ShaderIDs . LowDepth4 , ShaderIDs . Occlusion4 , ShaderIDs . LowDepth3 , ShaderIDs . Occlusion3 , ShaderIDs . Combined3 , GetSize ( MipLevel . L4 ) , GetSize ( MipLevel . L3 ) , isMSAA ) ;
173
176
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
284
287
cmd . DispatchCompute ( cs , kernel , m_Widths [ ( int ) MipLevel . L6 ] , m_Heights [ ( int ) MipLevel . L6 ] , 1 ) ;
285
288
}
286
289
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 )
288
291
{
289
292
// Here we compute multipliers that convert the center depth value into (the reciprocal
290
293
// 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
303
306
// ScreenspaceDiameter: Diameter of sample sphere in pixel units
304
307
// ScreenspaceDiameter / BufferWidth: Ratio of the screen width that the sphere actually covers
305
308
float thicknessMultiplier = 2f * tanHalfFovH * kScreenspaceDiameter / sourceSize . x ;
306
- if ( RuntimeUtilities . isSinglePassStereoEnabled )
309
+ if ( isSinglePassStereo )
307
310
thicknessMultiplier *= 2f ;
308
311
309
312
// This will transform a depth value from [0, thickness] to [0, 1].
0 commit comments