]> git.tdb.fi Git - libs/gl.git/blob - tests/glsl/return_type_conversion.glsl
Apply implicit conversion to return expressions in GLSL functions
[libs/gl.git] / tests / glsl / return_type_conversion.glsl
1 uniform Shadow
2 {
3         mat4 shadow_matrix;
4 };
5 uniform Camera
6 {
7         mat4 viewproj_matrix;
8 };
9 uniform Surface
10 {
11         vec4 color;
12 };
13 uniform mat4 model_matrix;
14 uniform sampler2DShadow shadow_map;
15
16 #pragma MSP stage(vertex)
17 layout(location=0) in vec4 position;
18 void main()
19 {
20         out vec4 world_position = model_matrix*position;
21         gl_Position = viewproj_matrix*world_position;
22 }
23
24 #pragma MSP stage(fragment)
25 layout(location=0) out vec4 frag_out;
26 float get_shadow()
27 {
28         vec3 shadow_coord = (shadow_matrix*world_position).xyz;
29         if(shadow_coord.x>=0 && shadow_coord.x<=1 && shadow_coord.y>=0 && shadow_coord.y<=1)
30                 return texture(shadow_map, shadow_coord);
31         else
32                 return 1;
33 }
34 void main()
35 {
36         frag_out = vec4(color.rgb*get_shadow(), color.a);
37 }
38
39 /* Expected output: vertex
40 layout(binding=72) uniform Camera
41 {
42         mat4 viewproj_matrix;
43 };
44 layout(location=0) uniform mat4 model_matrix;
45 layout(location=0) in vec4 position;
46 layout(location=0) out vec4 world_position;
47 void main()
48 {
49         world_position = model_matrix*position;
50         gl_Position = viewproj_matrix*world_position;
51 }
52 */
53
54 /* Expected output: fragment
55 layout(binding=71) uniform Shadow
56 {
57         mat4 shadow_matrix;
58 };
59 layout(binding=77) uniform Surface
60 {
61         vec4 color;
62 };
63 layout(location=4, binding=73) uniform sampler2DShadow shadow_map;
64 layout(location=0) out vec4 frag_out;
65 layout(location=0) in vec4 world_position;
66 float get_shadow()
67 {
68         vec3 shadow_coord = (shadow_matrix*world_position).xyz;
69         if(shadow_coord.x>=0.0&&shadow_coord.x<=1.0&&shadow_coord.y>=0.0&&shadow_coord.y<=1.0)
70                 return texture(shadow_map, shadow_coord);
71         else
72                 return 1.0;
73 }
74 void main()
75 {
76         frag_out = vec4(color.rgb*get_shadow(), color.a);
77 }
78 */