]> git.tdb.fi Git - libs/gl.git/blob - tests/glsl/empty_conditional_removal.glsl
Remove conditional and iteration statements with no effect from GLSL
[libs/gl.git] / tests / glsl / empty_conditional_removal.glsl
1 uniform Lighting
2 {
3         vec3 light_dir;
4         mat4 shadow_matrix;
5         int shadow_enabled;
6 };
7 uniform Transform
8 {
9         mat4 vp;
10         mat4 model;
11 };
12 uniform sampler2DShadow shadow_map;
13 const bool use_light = false;
14
15 #pragma MSP stage(vertex)
16 layout(location=0) in vec4 vertex;
17 layout(location=1) in vec3 normal;
18 void main()
19 {
20         vec4 world_vertex = model*vertex;
21         out vec3 world_normal = mat3(model)*normal;
22         gl_Position = vp*world_vertex;
23         if(shadow_enabled!=0)
24         {
25                 out vec3 shadow_coord = (shadow_matrix*world_vertex).xyz;
26         }
27 }
28
29 #pragma MSP stage(fragment)
30 layout(location=0) out vec4 frag_color;
31 void main()
32 {
33         vec3 color = vec3(1.0);
34         if(use_light)
35         {
36                 float intensity = max(dot(normalize(world_normal), light_dir), 0.0);
37                 if(shadow_enabled!=0)
38                         intensity *= texture(shadow_map, shadow_coord);
39                 color *= intensity;
40         }
41         frag_color = vec4(color, 1.0);
42 }
43
44 /* Expected output: vertex
45 layout(binding=48) uniform Transform
46 {
47         mat4 vp;
48         mat4 model;
49 };
50 layout(location=0) in vec4 vertex;
51 void main()
52 {
53         gl_Position = vp*model*vertex;
54 }
55 */
56
57 /* Expected output: fragment
58 layout(location=0) out vec4 frag_color;
59 void main()
60 {
61         frag_color = vec4(vec3(1.0), 1.0);
62 }
63 */