| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
- // All rights reserved.
- // Code licensed under the BSD License.
- // http://www.anki3d.org/LICENSE
- #pragma anki mutator TEXTURE_TYPE 0 1 // 0: no tex, 1: rgba tex
- #pragma anki technique vert pixel
- #include <AnKi/Shaders/Common.hlsl>
- struct VertIn
- {
- Vec2 m_position : POSITION;
- ANKI_RELAXED_PRECISION Vec4 m_color : COLOR;
- #if TEXTURE_TYPE > 0
- Vec2 m_uv : TEXCOORD;
- #endif
- };
- struct VertOut
- {
- #if TEXTURE_TYPE > 0
- Vec2 m_uv : TEXCOORD;
- #endif
- ANKI_RELAXED_PRECISION Vec4 m_color : COLOR;
- Vec4 m_svPosition : SV_POSITION;
- };
- #if ANKI_VERTEX_SHADER
- struct Constants
- {
- Vec4 m_transform; // x: x scale, y: y scale, z: x transl, w: y transl
- };
- ANKI_FAST_CONSTANTS(Constants, g_consts)
- VertOut main(VertIn input)
- {
- VertOut output;
- # if TEXTURE_TYPE > 0
- output.m_uv = input.m_uv;
- # endif
- output.m_color = input.m_color;
- const Vec2 pos = g_consts.m_transform.xy * input.m_position + g_consts.m_transform.zw;
- output.m_svPosition = Vec4(pos, 0.0, 1.0);
- return output;
- }
- #endif // ANKI_VERTEX_SHADER
- #if ANKI_PIXEL_SHADER
- # if TEXTURE_TYPE > 0
- SamplerState g_trilinearRepeatSampler : register(s0);
- Texture2D g_tex : register(t0);
- # endif
- Vec4 main(VertOut input) : SV_TARGET0
- {
- # if TEXTURE_TYPE == 0
- return input.m_color;
- # elif TEXTURE_TYPE == 1
- return input.m_color * g_tex.Sample(g_trilinearRepeatSampler, input.m_uv);
- # endif
- }
- #endif // ANKI_PIXEL_SHADER
|