]> git.tdb.fi Git - libs/gl.git/blob - tests/glsl/return_type_conversion.glsl
Fix GLSL test cases so they pass the basic tests
[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 layout(push_constant) uniform Transform
14 {
15         mat4 model_matrix;
16 };
17 uniform sampler2DShadow shadow_map;
18
19 #pragma MSP stage(vertex)
20 layout(location=0) in vec4 position;
21 void main()
22 {
23         out vec4 world_position = model_matrix*position;
24         gl_Position = viewproj_matrix*world_position;
25 }
26
27 #pragma MSP stage(fragment)
28 layout(location=0) out vec4 frag_out;
29 float get_shadow()
30 {
31         vec3 shadow_coord = (shadow_matrix*world_position).xyz;
32         if(shadow_coord.x>=0 && shadow_coord.x<=1 && shadow_coord.y>=0 && shadow_coord.y<=1)
33                 return texture(shadow_map, shadow_coord);
34         else
35                 return 1;
36 }
37 void main()
38 {
39         frag_out = vec4(color.rgb*get_shadow(), color.a);
40 }
41
42 // Target API: Vulkan
43
44 /* Expected output: vertex
45 layout(set=0, binding=24) uniform Camera
46 {
47         mat4 viewproj_matrix;
48 };
49 layout(push_constant) uniform Transform
50 {
51         mat4 model_matrix;
52 };
53 layout(location=0) in vec4 position;
54 layout(location=0) out vec4 world_position;
55 void main()
56 {
57         world_position = model_matrix*position;
58         gl_Position = viewproj_matrix*world_position;
59 }
60 */
61
62 /* Expected output: fragment
63 layout(set=0, binding=35) uniform Shadow
64 {
65         mat4 shadow_matrix;
66 };
67 layout(set=0, binding=65) uniform Surface
68 {
69         vec4 color;
70 };
71 layout(set=0, binding=73) uniform sampler2DShadow shadow_map;
72 layout(location=0) out vec4 frag_out;
73 layout(location=0) in vec4 world_position;
74 float get_shadow()
75 {
76         vec3 shadow_coord = (shadow_matrix*world_position).xyz;
77         if(shadow_coord.x>=0.0&&shadow_coord.x<=1.0&&shadow_coord.y>=0.0&&shadow_coord.y<=1.0)
78                 return texture(shadow_map, shadow_coord);
79         else
80                 return 1.0;
81 }
82 void main()
83 {
84         frag_out = vec4(color.rgb*get_shadow(), color.a);
85 }
86 */