]> git.tdb.fi Git - libs/gl.git/blob - tests/glsl/swizzle_assignment.glsl
Add a couple more test cases
[libs/gl.git] / tests / glsl / swizzle_assignment.glsl
1 uniform sampler2D tex;
2 uniform Transform
3 {
4         mat4 model_matrix;
5         mat4 vp_matrix;
6 };
7 uniform Lighting
8 {
9         vec3 light_dir;
10         vec3 light_color;
11 };
12
13 #pragma MSP stage(vertex)
14 layout(location=0) in vec4 position;
15 layout(location=1) in vec3 normal;
16 layout(location=2) in vec2 texcoord;
17 void main()
18 {
19         passthrough;
20         out vec3 world_normal = mat3(model_matrix)*normal;
21         gl_Position = vp_matrix*model_matrix*position;
22 }
23
24 #pragma MSP stage(fragment)
25 layout(location=0) out vec4 frag_color;
26 void main()
27 {
28         frag_color = texture(tex, texcoord);
29         frag_color.rgb *= max(dot(normalize(world_normal), light_dir), 0.0)*light_color;
30 }
31
32 /* Expected output: vertex
33 layout(binding=48) uniform Transform
34 {
35   mat4 model_matrix;
36   mat4 vp_matrix;
37 };
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 vec2 _vs_out_texcoord;
42 layout(location=1) out vec3 world_normal;
43 void main()
44 {
45   _vs_out_texcoord = texcoord;
46   mat4 _temp = model_matrix;
47   world_normal = mat3(_temp[0].xyz, _temp[1].xyz, _temp[2].xyz)*normal;
48   gl_Position = vp_matrix*model_matrix*position;
49 }
50 */
51
52 /* Expected output: fragment
53 layout(location=0, binding=71) uniform sampler2D tex;
54 layout(binding=5) uniform Lighting
55 {
56   vec3 light_dir;
57   vec3 light_color;
58 };
59 layout(location=0) out vec4 frag_color;
60 layout(location=0) in vec2 _vs_out_texcoord;
61 layout(location=1) in vec3 world_normal;
62 void main()
63 {
64   frag_color = texture(tex, _vs_out_texcoord);
65   frag_color.rgb *= max(dot(normalize(world_normal), light_dir), 0.0)*light_color;
66 }
67 */