]> git.tdb.fi Git - libs/gl.git/blob - tests/glsl/generated_name_reuse.glsl
Fix a GLSL testcase
[libs/gl.git] / tests / glsl / generated_name_reuse.glsl
1 uniform LightParameters
2 {
3         vec3 ambient;
4         vec4 light_position;
5 };
6 uniform mat4 model;
7 uniform mat4 view_proj;
8 layout(constant_id=auto) const bool use_light = true;
9 layout(constant_id=auto) const bool use_ambient = true;
10
11 #pragma MSP stage(vertex)
12 layout(location=0) in vec4 vertex;
13 layout(location=1) in vec3 normal;
14 void main()
15 {
16         out vec4 world_vertex = model*vertex;
17         out vec3 world_normal = mat3(model)*normal;
18         gl_Position = view_proj*world_vertex;
19 }
20
21 #pragma MSP stage(fragment)
22 layout(location=0) out vec4 frag_color;
23 vec4 get_light_position()
24 {
25         return light_position;
26 }
27 float get_light_intensity(vec3 dir)
28 {
29         return max(dot(dir, normalize(world_normal)), 0.0);
30 }
31 vec3 get_ambient()
32 {
33         return ambient;
34 }
35 void main()
36 {
37         vec3 color = vec3(0.0);
38         if(use_light)
39         {
40                 vec4 light_pos = get_light_position();
41                 vec3 dir = normalize(light_pos.xyz-world_vertex.xyz*light_pos.w);
42                 color += get_light_intensity(dir);
43         }
44         if(use_ambient)
45                 color += get_ambient();
46         frag_color = vec4(color, 1.0);
47 }
48
49 // Compile mode: module
50
51 /* Expected output: vertex
52 layout(location=0) uniform mat4 model;
53 layout(location=4) uniform mat4 view_proj;
54 layout(location=0) in vec4 vertex;
55 layout(location=1) in vec3 normal;
56 layout(location=0) out vec4 world_vertex;
57 layout(location=1) out vec3 world_normal;
58 void main()
59 {
60         world_vertex = model*vertex;
61         world_normal = mat3(model[0].xyz, model[1].xyz, model[2].xyz)*normal;
62         gl_Position = view_proj*world_vertex;
63 }
64 */
65
66 /* Expected output: fragment
67 layout(binding=57) uniform LightParameters
68 {
69         vec3 ambient;
70         vec4 light_position;
71 };
72 layout(constant_id=669465691) const bool use_light = true;
73 layout(constant_id=1735871551) const bool use_ambient = true;
74 layout(location=0) out vec4 frag_color;
75 layout(location=1) in vec3 world_normal;
76 layout(location=0) in vec4 world_vertex;
77 void main()
78 {
79         vec3 color = vec3(0.0);
80         if(use_light)
81         {
82                 vec4 _return = light_position;
83                 color += max(dot(normalize(_return.xyz-world_vertex.xyz*_return.w), normalize(world_normal)), 0.0);
84         }
85         if(use_ambient)
86                 color += ambient;
87         frag_color = vec4(color, 1.0);
88 }
89 */