diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Utils/CopyDepthPass.hlsl b/Packages/com.unity.render-pipelines.universal/Shaders/Utils/CopyDepthPass.hlsl index 2a3b3b606e0..6698a7f5712 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Utils/CopyDepthPass.hlsl +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Utils/CopyDepthPass.hlsl @@ -17,21 +17,19 @@ #if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED) #define DEPTH_TEXTURE_MS(name, samples) Texture2DMSArray name #define DEPTH_TEXTURE(name) TEXTURE2D_ARRAY_FLOAT(name) -#define LOAD(uv, sampleIndex) LOAD_TEXTURE2D_ARRAY_MSAA(_CameraDepthAttachment, uv, unity_StereoEyeIndex, sampleIndex) -#define SAMPLE(uv) SAMPLE_TEXTURE2D_ARRAY(_CameraDepthAttachment, sampler_CameraDepthAttachment, uv, unity_StereoEyeIndex).r +#define LOAD_MSAA(coord, sampleIndex) LOAD_TEXTURE2D_ARRAY_MSAA(_CameraDepthAttachment, coord, unity_StereoEyeIndex, sampleIndex) +#define LOAD(coord) LOAD_TEXTURE2D_ARRAY(_CameraDepthAttachment, coord, unity_StereoEyeIndex) #else #define DEPTH_TEXTURE_MS(name, samples) Texture2DMS name #define DEPTH_TEXTURE(name) TEXTURE2D_FLOAT(name) -#define LOAD(uv, sampleIndex) LOAD_TEXTURE2D_MSAA(_CameraDepthAttachment, uv, sampleIndex) -#define SAMPLE(uv) SAMPLE_DEPTH_TEXTURE(_CameraDepthAttachment, sampler_CameraDepthAttachment, uv) +#define LOAD_MSAA(coord, sampleIndex) LOAD_TEXTURE2D_MSAA(_CameraDepthAttachment, coord, sampleIndex) +#define LOAD(coord) LOAD_TEXTURE2D(_CameraDepthAttachment, coord) #endif #if MSAA_SAMPLES == 1 DEPTH_TEXTURE(_CameraDepthAttachment); - SAMPLER(sampler_CameraDepthAttachment); #else DEPTH_TEXTURE_MS(_CameraDepthAttachment, MSAA_SAMPLES); - float4 _CameraDepthAttachment_TexelSize; #endif #if UNITY_REVERSED_Z @@ -42,17 +40,17 @@ #define DEPTH_OP max #endif -float SampleDepth(float2 uv) +float SampleDepth(float2 pixelCoords) { + int2 coord = int2(pixelCoords); #if MSAA_SAMPLES == 1 - return SAMPLE(uv); + return LOAD(coord).r; #else - int2 coord = int2(uv * _CameraDepthAttachment_TexelSize.zw); float outDepth = DEPTH_DEFAULT_VALUE; UNITY_UNROLL for (int i = 0; i < MSAA_SAMPLES; ++i) - outDepth = DEPTH_OP(LOAD(coord, i), outDepth); + outDepth = DEPTH_OP(LOAD_MSAA(coord, i), outDepth); return outDepth; #endif } @@ -64,7 +62,7 @@ float frag(Varyings input) : SV_Target #endif { UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); - return SampleDepth(input.texcoord); + return SampleDepth(input.positionCS.xy); } #endif