| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- // 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 technique vert pixel
- #include <AnKi/Shaders/Common.hlsl>
- #include <AnKi/Shaders/Include/MiscRendererTypes.h>
- struct VertOut
- {
- Vec3 m_uv : TEXCOORD;
- Vec4 m_color : COLOR;
- Vec4 m_svPosition : SV_POSITION;
- };
- #if ANKI_VERTEX_SHADER
- // The block contains data for all flares
- StructuredBuffer<LensFlareSprite> g_sprites : register(t0);
- VertOut main(U32 svVertexId : SV_VERTEXID, U32 svInstanceId : SV_INSTANCEID)
- {
- const Vec2 position = uvToNdc(Vec2(svVertexId & 1, svVertexId >> 1));
- const LensFlareSprite sprite = g_sprites[svInstanceId];
- // Write tex coords of the 2D array texture
- VertOut output;
- output.m_uv = Vec3((position * 0.5) + 0.5, sprite.m_depthPad3.x);
- const Vec4 posScale = sprite.m_posScale;
- output.m_svPosition = Vec4(position * posScale.zw + posScale.xy, 0.0, 1.0);
- output.m_color = sprite.m_color;
- return output;
- }
- #endif // ANKI_VERTEX_SHADER
- #if ANKI_PIXEL_SHADER
- SamplerState g_trilinearRepeatSampler : register(s0);
- Texture2DArray<Vec4> g_tex : register(t1);
- Vec4 main(VertOut input) : SV_TARGET0
- {
- const Vec4 col = g_tex.Sample(g_trilinearRepeatSampler, input.m_uv);
- return col * input.m_color;
- }
- #endif
|