123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /*
- * Modifications 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
- *
- */
- //
- // Copyright (c) 2019 Advanced Micro Devices, Inc. All rights reserved.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // THE SOFTWARE.
- //
- #include <Atom/Features/SrgSemantics.azsli>
- //!------------------------------ SRG Structure --------------------------------
- //! Per pass SRG that holds the dynamic shared read-write buffer shared
- //! across all dispatches and draw calls. It is used for all the dynamic buffers
- //! that can change between passes due to the application of skinning, simulation
- //! and physics affect.
- //! Once the compute pases are done, it is read by the rendering shaders.
- ShaderResourceGroup PassSrg : SRG_PerPass_WithFallback
- {
- // Originally: [[vk::binding(0, 0)]] Texture2DArray<uint> FragmentDepthsTexture : register(t0, space0);
- Texture2DArray<uint> m_fragmentDepthsTexture;
- }
- //------------------------------------------------------------------------------
- #include <HairFullScreenUtils.azsli> // provides the Vertex Shader
- //!=============================================================================
- //! Resolve Depth - Second Pass of ShortCut
- //! Full-screen pass that writes the farthest of the stored K near depths so it
- //! could be used for depth culling during the following geometry shading pass.
- //!=============================================================================
- float HairShortCutResolveDepthPS(VSOutput input) : SV_Depth
- {
- // Blend the layers of fragments from back to front
- int2 vScreenAddress = int2(input.m_position.xy);
- // Write farthest depth value for culling in the next pass.
- // It may be the initial value of 1.0 if there were not enough fragments to write all depths, but then culling not important.
- const int farthestDepthIndex = 2;
- uint uDepth = PassSrg::m_fragmentDepthsTexture[uint3(vScreenAddress, farthestDepthIndex)];
- // The following line is writing the depth into the actual depth buffer
- return asfloat(uDepth);
- }
|