| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- /*
- * 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 <Atom/Features/SrgSemantics.azsli>
- ShaderResourceGroup TextureInstanceSrg : SRG_PerObject
- {
- Texture2DMS<float4> m_albedoMap;
- }
- 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;
- OUT.m_position = float4(vsInput.m_position, 1.0);
- 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;
- uint width = 0;
- uint height = 0;
- uint numberOfSamples = 0;
- TextureInstanceSrg::m_albedoMap.GetDimensions(width, height, numberOfSamples);
- float3 albedo = float3(0, 0, 0);
- // Just average the samples equally
- for (uint i = 0; i < numberOfSamples; ++i)
- {
- albedo += TextureInstanceSrg::m_albedoMap.Load(int2(width * psInput.m_uv.x, height * psInput.m_uv.y), i).rgb;
- }
- OUT.m_color = float4(albedo / numberOfSamples, 1.0);
- return OUT;
- }
|