| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <!--
- Copyright (C) 2009-2018, Panagiotis Christopoulos Charitos and contributors.
- All rights reserved.
- Code licensed under the BSD License.
- http://www.anki3d.org/LICENSE
- -->
- <shaderProgram>
- <shaders>
- <shader type="vert">
- <inputs>
- <input name="MAX_SPRITES" type="uint" const="1"/>
- </inputs>
- <source><![CDATA[
- #include "shaders/Common.glsl"
- // Per flare information
- struct Sprite
- {
- vec4 posScale; // xy: Position, zw: Scale
- vec4 color;
- vec4 depthPad3;
- };
- // The block contains data for all flares
- layout(std140, ANKI_UBO_BINDING(0, 0)) uniform _blk
- {
- Sprite u_sprites[MAX_SPRITES];
- };
- layout(location = 0) out vec3 out_uv;
- layout(location = 1) flat out vec4 out_color;
- out gl_PerVertex
- {
- vec4 gl_Position;
- };
- void main()
- {
- vec2 position = UV_TO_NDC(vec2(gl_VertexID & 1, gl_VertexID >> 1));
- Sprite sprite = u_sprites[gl_InstanceID];
- // Write tex coords of the 2D array texture
- out_uv = vec3((position * 0.5) + 0.5, sprite.depthPad3.x);
- vec4 posScale = sprite.posScale;
- gl_Position = vec4(position * posScale.zw + posScale.xy, 0.0, 1.0);
- out_color = sprite.color;
- }
- ]]></source>
- </shader>
- <shader type="frag">
- <source><![CDATA[
- #include "shaders/Common.glsl"
- layout(ANKI_TEX_BINDING(0, 0)) uniform sampler2DArray u_tex;
- layout(location = 0) in vec3 in_uv;
- layout(location = 1) flat in vec4 in_color;
- layout(location = 0) out vec4 out_color;
- void main()
- {
- vec4 col = texture(u_tex, in_uv);
- out_color = col * in_color;
- }
- ]]></source>
- </shader>
- </shaders>
- </shaderProgram>
|