]> git.tdb.fi Git - libs/gl.git/blob - tests/glsl/parentheses.glsl
Allocate locations to interface variables
[libs/gl.git] / tests / glsl / parentheses.glsl
1 struct LightParams
2 {
3         vec3 ambient;
4         vec3 color;
5         float intensity;
6         vec3 dir;
7 };
8 uniform LightParams light;
9 uniform vec3 material_color;
10 uniform mat4 mvp;
11 uniform vec3 offset;
12 uniform sampler2D occlusion_map;
13
14 #pragma MSP stage(vertex)
15 layout(location=0) in vec4 position;
16 layout(location=1) in vec3 normal;
17 layout(location=2) in vec2 texcoord;
18 void main()
19 {
20         vec4 p = position+vec4(offset, 1.0);
21         gl_Position = mvp*p;
22         passthrough;
23 }
24
25 #pragma MSP stage(fragment)
26 layout(location=0) out vec4 frag_color;
27 void main()
28 {
29         float occlusion = float(texture(occlusion_map, texcoord));
30         vec3 light_color = light.color*light.intensity;
31         vec3 l = light.ambient+light_color*max(dot(light.dir, normalize(normal)), 0.0);
32         frag_color = vec4(material_color*l*occlusion, 1.0);
33 }
34
35 /* Expected output: vertex
36 layout(location=0) uniform mat4 mvp;
37 layout(location=4) uniform vec3 offset;
38 layout(location=0) in vec4 position;
39 layout(location=1) in vec3 normal;
40 layout(location=2) in vec2 texcoord;
41 layout(location=0) out vec3 _vs_out_normal;
42 layout(location=1) out vec2 _vs_out_texcoord;
43 void main()
44 {
45         gl_Position = mvp*(position+vec4(offset, 1.0));
46         _vs_out_normal = normal;
47         _vs_out_texcoord = texcoord;
48 }
49 */
50
51 /* Expected output: fragment
52 struct LightParams
53 {
54   vec3 ambient;
55   vec3 color;
56   float intensity;
57   vec3 dir;
58 };
59 layout(location=5) uniform LightParams light;
60 layout(location=9) uniform vec3 material_color;
61 layout(location=10) uniform sampler2D occlusion_map;
62 layout(location=0) out vec4 frag_color;
63 layout(location=1) in vec2 _vs_out_texcoord;
64 layout(location=0) in vec3 _vs_out_normal;
65 void main()
66 {
67         frag_color = vec4(material_color*(light.ambient+light.color*light.intensity*max(dot(light.dir, normalize(_vs_out_normal)), 0.0))*float(texture(occlusion_map, _vs_out_texcoord).x), 1.0);
68 }
69 */