]> git.tdb.fi Git - libs/gl.git/blob - tests/glsl/parentheses.glsl
Resolve and validate the parameters of constructors in GLSL
[libs/gl.git] / tests / glsl / parentheses.glsl
1 struct LightParams
2 {
3         uniform vec3 ambient;
4         uniform vec3 color;
5         uniform float intensity;
6         uniform 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 uniform mat4 mvp;
37 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 out vec3 _vs_out_normal;
42 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   uniform vec3 ambient;
55   uniform vec3 color;
56   uniform float intensity;
57   uniform vec3 dir;
58 };
59 uniform LightParams light;
60 uniform vec3 material_color;
61 uniform sampler2D occlusion_map;
62 layout(location=0) out vec4 frag_color;
63 in vec2 _vs_out_texcoord;
64 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 */