| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /*
- * 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 TriangleInstanceSrg : SRG_PerDraw
- {
- column_major float4x4 m_objectMatrix;
- }
- struct VSInput
- {
- float3 m_position : POSITION;
- float4 m_color : COLOR0;
- };
- struct VSOutput
- {
- float4 m_position : SV_Position;
- float4 m_color : COLOR0;
- };
- // Red: normal draw mode (rgb = rgb). The Red corner appears on top
- // Green: shift the colors so Green is on top (the top vertex is (1, 0, 0) so the green color should come from .r
- // Blue: shift the colors so Blue is on top (the top vertex is (1, 0, 0) so the blue color should come from .r
- // White: ignore original colors and draw everything white
- option enum class DrawMode { Red, Green, Blue, White} o_drawMode;
- VSOutput MainVS(VSInput vsInput)
- {
- VSOutput OUT;
- OUT.m_position = mul(float4(vsInput.m_position, 1.0), TriangleInstanceSrg::m_objectMatrix);
- OUT.m_color = vsInput.m_color;
- return OUT;
- }
- struct PSOutput
- {
- float4 m_color : SV_Target0;
- };
- PSOutput MainPS(VSOutput vsOutput)
- {
- PSOutput OUT;
-
- switch (o_drawMode)
- {
- case DrawMode::Red:
- OUT.m_color = vsOutput.m_color.rgba;
- break;
- case DrawMode::Green:
- OUT.m_color = vsOutput.m_color.brga;
- break;
- case DrawMode::Blue:
- OUT.m_color = vsOutput.m_color.gbra;
- break;
- case DrawMode::White:
- OUT.m_color = float4(1, 1, 1, vsOutput.m_color.a);
- break;
- }
- // Simple tonemapping:
- OUT.m_color.rgb = pow(OUT.m_color.rgb, 1.0/2.2);
- return OUT;
- }
|