/* * 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 ShaderResourceGroup TexturedSurfaceSrg : SRG_PerObject { row_major float4x4 m_worldMatrix; row_major float4x4 m_viewProjectionMatrix; float m_alphaTestRefValue; Texture2D m_albedoMap; Sampler m_sampler { MaxAnisotropy = 16; AddressU = Wrap; AddressV = Wrap; AddressW = Wrap; }; } struct VSInput { float3 m_position : POSITION; float2 m_uv : UV0; }; struct VSOutput { float4 m_position : SV_Position; float2 m_uv : UV0; }; VSOutput MainVS(VSInput vsInput) { VSOutput OUT; float4 worldPosition = mul(TexturedSurfaceSrg::m_worldMatrix, float4(vsInput.m_position, 1.0)); OUT.m_position = mul(TexturedSurfaceSrg::m_viewProjectionMatrix, worldPosition); OUT.m_uv.x = vsInput.m_uv.x; OUT.m_uv.y = 1.0 - vsInput.m_uv.y; return OUT; } struct PSOutput { float4 m_color : SV_Target0; }; PSOutput MainPS(VSOutput psInput) { PSOutput OUT; OUT.m_color = TexturedSurfaceSrg::m_albedoMap.Sample(TexturedSurfaceSrg::m_sampler, psInput.m_uv).rgba; clip( OUT.m_color.a < TexturedSurfaceSrg::m_alphaTestRefValue ? -1 : 1 ); return OUT; }