• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 450 core
2#extension GL_ARB_shader_draw_parameters : require
3
4layout(location = 0) in vec4 in_position;
5layout(location = 1) in vec4 in_color;
6layout(location = 2) in int  in_refVertexIndex;
7
8layout(location = 0) out vec4 out_color;
9
10out gl_PerVertex {
11    vec4 gl_Position;
12};
13
14void main() {
15    vec2 perVertex         = vec2(in_position.x, in_position.y);
16    vec2 perInstance[5]    = vec2[5](vec2(0.0, 0.0), vec2(-0.3, 0.0), vec2(0.0, 0.3), vec2(0.5, 0.5), vec2(0.75, -0.8));
17    vec4 colors[4]         = vec4[4](vec4(1.0), vec4(0.0, 0.0, 1.0, 1.0), vec4(0.0, 1.0, 0.0, 1.0), vec4(0.0, 1.0, 1.0, 1.0));
18    int  baseInstanceIndex = gl_InstanceIndex - gl_BaseInstanceARB;
19
20    gl_Position = vec4(perVertex + perInstance[baseInstanceIndex], 0.0, 1.0);
21
22    if ((gl_VertexIndex - gl_BaseVertexARB) == in_refVertexIndex && gl_DrawIDARB == 0)
23        out_color = in_color * colors[baseInstanceIndex];
24    else
25        out_color = vec4(1.0, 0.0, 0.0, 1.0);
26}
27