EditorModeDesaturation.azsl 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <EditorModeCommon.azsli>
  9. PSOutput MainPS(VSOutput IN)
  10. {
  11. PSOutput OUT;
  12. const float3 inColor = PassSrg::m_framebuffer.Sample(PassSrg::LinearSampler, IN.m_texCoord).rgb;
  13. const float mask = PassSrg::m_entityMask.Sample(PassSrg::PointSampler, IN.m_texCoord).r;
  14. // Desaturation effect
  15. const float3 luminanceWeights = float3(0.299, 0.587, 0.114);
  16. const float luminance = dot(inColor, luminanceWeights);
  17. const float3 finalEffect = lerp(inColor, luminance, PassSrg::m_desaturationAmount);
  18. // Apply the depth transition to the blend amount
  19. const float zDepth = PassSrg::m_depth.Sample(PassSrg::PointSampler, IN.m_texCoord).r;
  20. const float t = PassSrg::CalculateTransitionBlendAmountFromDepth(zDepth, mask);
  21. // Apply the visual effect to non-mask entities, leaving mask entities untouched
  22. OUT.m_color = PassSrg::CalculateFinalBlendAmountAndOutputColor(inColor, finalEffect, t);
  23. return OUT;
  24. }