From 57b79535f3ab37d8c2ebeccd681b7eb6f4ac3d80 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 28 Apr 2019 22:01:06 -0700 Subject: Added ShaderUtilities.fxh with DepthToNormalizedDeviceZ() function --- .../EpipolarLightScattering/private/AtmosphereShadersCommon.fxh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Shaders/PostProcess') 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; -- cgit v1.2.3