123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- /*
- * 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 <EditorModeCommon.azsli>
- //! Applies a box blur of the specified kernel width in the specified direction.
- float3 Blur(const float2 uv, const float2 uvDir, const float kernelHalfWidth)
- {
- const float2 unormalizedUv = float2(uv.x * PassSrg::m_maskDimensions.x, uv.y * PassSrg::m_maskDimensions.y);
- float3 outColor = float3(0., 0., 0.);
- for(float i = -kernelHalfWidth; i <= kernelHalfWidth; i+=1.)
- {
- outColor += PassSrg::m_framebuffer.Sample(PassSrg::PointSampler, (unormalizedUv + (float2(i,i) * uvDir)) * PassSrg::m_maskDimensions.zw).rgb;
- }
- return outColor / (kernelHalfWidth * 2.0 + 1.0);
- }
- PSOutput MainPS(VSOutput IN)
- {
- PSOutput OUT;
- const float3 inColor = PassSrg::m_framebuffer.Sample(PassSrg::LinearSampler, IN.m_texCoord).rgb;
- const float mask = PassSrg::m_entityMask.Sample(PassSrg::PointSampler, IN.m_texCoord).r;
-
- // Blur effect
- float2 blurDirection = (PassSrg::m_direction == 0) ? float2(1.0, 0.0) : float2(0.0, 1.0);
- float3 finalEffect = Blur(IN.m_texCoord, blurDirection, PassSrg::m_kernelHalfWidth);
-
- // Apply the depth transition to the blend amount
- const float zDepth = PassSrg::m_depth.Sample(PassSrg::PointSampler, IN.m_texCoord).r;
- const float t = PassSrg::CalculateTransitionBlendAmountFromDepth(zDepth, mask);
-
- // Apply the visual effect to non-mask entities, leaving mask entities untouched
- OUT.m_color = PassSrg::CalculateFinalBlendAmountAndOutputColor(inColor, finalEffect, t);
- return OUT;
- }
|