File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed
Shaders/PostProcess/ScreenSpaceAmbientOcclusion/private Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -83,20 +83,17 @@ float ComputeAmbientOcclusionPS(in FullScreenTriangleVSOutput VSOut) : SV_Target
8383 if (IsBackground (PositionSS.z))
8484 discard ;
8585
86- // Trying to fix self-occlusion. Maybe there's a better way
86+ float3 NormalVS = mul (float4 (LoadNormalWS (ScreenCoordUV), 0.0 ), g_Camera.mView).xyz;
87+ float3 PositionVS = ScreenXYDepthToViewSpace (PositionSS, g_Camera.mProj);
88+
89+ // Fix self-occlusion
8790#if SSAO_OPTION_HALF_PRECISION_DEPTH
88- float Epsilon = 0.000005 ;
91+ float Offset = 0.005 ;
8992#else
90- float Epsilon = 0.000001 ;
91- #endif
92- #if SSAO_OPTION_INVERTED_DEPTH
93- PositionSS.z *= 1.0 + Epsilon;
94- #else
95- PositionSS.z *= 1.0 - Epsilon;
93+ float Offset = 0.00001 ;
9694#endif
95+ PositionVS += NormalVS * Offset * PositionVS.z;
9796
98- float3 NormalVS = mul (float4 (LoadNormalWS (ScreenCoordUV), 0.0 ), g_Camera.mView).xyz;
99- float3 PositionVS = ScreenXYDepthToViewSpace (PositionSS, g_Camera.mProj);
10097 float3 ViewVS = -normalize (PositionVS);
10198 float2 Xi = LoadRandomVector2D (int2 (Position));
10299
You can’t perform that action at this time.
0 commit comments