summaryrefslogtreecommitdiffstats
path: root/Shaders/PostProcess
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-04-29 05:01:06 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-04-29 05:01:06 +0000
commit57b79535f3ab37d8c2ebeccd681b7eb6f4ac3d80 (patch)
tree56f839c14550182437c0d47951705abb2ad9d907 /Shaders/PostProcess
parentFixed numeric issue in SmithGGXVisibilityCorrelated (diff)
downloadDiligentFX-57b79535f3ab37d8c2ebeccd681b7eb6f4ac3d80.tar.gz
DiligentFX-57b79535f3ab37d8c2ebeccd681b7eb6f4ac3d80.zip
Added ShaderUtilities.fxh with DepthToNormalizedDeviceZ() function
Diffstat (limited to 'Shaders/PostProcess')
-rw-r--r--Shaders/PostProcess/EpipolarLightScattering/private/AtmosphereShadersCommon.fxh5
1 files changed, 3 insertions, 2 deletions
diff --git a/Shaders/PostProcess/EpipolarLightScattering/private/AtmosphereShadersCommon.fxh b/Shaders/PostProcess/EpipolarLightScattering/private/AtmosphereShadersCommon.fxh
index aed1253..a20f7de 100644
--- a/Shaders/PostProcess/EpipolarLightScattering/private/AtmosphereShadersCommon.fxh
+++ b/Shaders/PostProcess/EpipolarLightScattering/private/AtmosphereShadersCommon.fxh
@@ -4,6 +4,7 @@
#include "FullScreenTriangleVSOutput.fxh"
#include "ToneMappingStructures.fxh"
#include "EpipolarLightScatteringStructures.fxh"
+#include "ShaderUtilities.fxh"
#define PI 3.1415928f
#define FLT_MAX 3.402823466e+38f
@@ -127,8 +128,8 @@ float3 ProjSpaceXYZToWorldSpace(in float3 f3PosPS, in float4x4 mProj, in float4x
// matrix and then divide by w. Consequently, the inverse transform is also
// the same.
// What differs is that in GL, NDC z is transformed from [-1,+1] to [0,1]
- // before storing in the depth buffer
- float fNDC_Z = MATRIX_ELEMENT(mProj,2,2) + MATRIX_ELEMENT(mProj,3,2) / f3PosPS.z;
+ // before storing in the depth buffer, which we will have to inverse.
+ float fNDC_Z = DepthToNormalizedDeviceZ(f3PosPS.z, mProj);
float4 ReconstructedPosWS = mul( float4(f3PosPS.xy, fNDC_Z, 1.0), mViewProjInv );
ReconstructedPosWS /= ReconstructedPosWS.w;
return ReconstructedPosWS.xyz;