/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include #include #include #include #include #include "ReflectionScreenSpaceBlurCommon.azsli" ShaderResourceGroup PassSrg : SRG_PerPass { Texture2DMS m_depth; RWTexture2D m_input; RWTexture2D m_output; uint m_imageWidth; uint m_imageHeight; float m_outputScale; } #include // Pixel Shader struct PSOutput { float4 m_color : SV_Target0; float m_depth : SV_Depth; }; PSOutput MainPS(VSOutput IN) { // vertical blur uses coordinates from the mip0 input image uint2 halfResCoords = IN.m_position.xy * PassSrg::m_outputScale; float3 result = GaussianFilter(halfResCoords, TexelOffsetsV, PassSrg::m_input); // downsample depth, using fullscreen image coordinates float downsampledDepth = 0; if (PassSrg::m_input[halfResCoords].w > 0.0f) { uint2 fullScreenCoords = halfResCoords * 2; for (int y = -2; y < 2; ++y) { for (int x = -2; x < 2; ++x) { float depth = PassSrg::m_depth.Load(fullScreenCoords + int2(x, y), 0).r; if (depth > downsampledDepth) { downsampledDepth = depth; } } } } PSOutput OUT; OUT.m_color = float4(result, 1.0f); OUT.m_depth = downsampledDepth; return OUT; }