]> git.tdb.fi Git - libs/gl.git/blob - tests/glsl/dead_loop_removal.glsl
7cfba086b23fdcc5bbb5d5af5e59391ad5806d62
[libs/gl.git] / tests / glsl / dead_loop_removal.glsl
1 const int n_lights = 0;
2 struct LightParams
3 {
4         vec3 direction;
5         vec3 color;
6 };
7 uniform LightParams lights[n_lights];
8 uniform vec3 ambient;
9 uniform mat4 model_matrix;
10 uniform mat4 vp_matrix;
11
12 #pragma MSP stage(vertex)
13 layout(location=0) in vec4 position;
14 layout(location=1) in vec3 normal;
15 void main()
16 {
17         out vec3 world_normal = mat3(model_matrix)*normal;
18         gl_Position = vp_matrix*model_matrix*position;
19 }
20
21 #pragma MSP stage(fragment)
22 layout(location=0) out vec4 frag_color;
23 void main()
24 {
25         vec3 color = ambient;
26         for(int i=0; i<n_lights; ++i)
27                 color += max(dot(normalize(world_normal), lights[i].direction), 0.0)*lights[i].color;
28         frag_color = vec4(color, 1.0);
29 }
30
31 /* Expected output: vertex
32 uniform mat4 model_matrix;
33 uniform mat4 vp_matrix;
34 layout(location=0) in vec4 position;
35 void main()
36 {
37   gl_Position = vp_matrix*model_matrix*position;
38 }
39 */
40
41 /* Expected output: fragment
42 uniform vec3 ambient;
43 layout(location=0) out vec4 frag_color;
44 void main()
45 {
46   frag_color = vec4(ambient, 1.0);
47 }
48 */