]> git.sesse.net Git - nageru/blob - futatabi/sor.vert
Set CEF autoplay policy to be more lenient.
[nageru] / futatabi / sor.vert
1 #version 450 core
2 #extension GL_ARB_shader_viewport_layer_array : require
3
4 layout(location=0) in vec2 position;
5 out vec3 tc, tc_left, tc_down;
6 out vec3 equation_tc_assuming_left, equation_tc_assuming_right;
7 out float element_x_idx;
8 out float element_sum_idx;
9
10 uniform sampler2DArray diff_flow_tex, diffusivity_tex;
11 uniform usampler2DArray equation_red_tex;
12
13 void main()
14 {
15         // The result of glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0) is:
16         //
17         //   2.000  0.000  0.000 -1.000
18         //   0.000  2.000  0.000 -1.000
19         //   0.000  0.000 -2.000 -1.000
20         //   0.000  0.000  0.000  1.000
21         gl_Position = vec4(2.0 * position.x - 1.0, 2.0 * position.y - 1.0, -1.0, 1.0);
22         gl_Layer = gl_InstanceID;
23
24         tc = vec3(position, gl_InstanceID);
25         tc_left = vec3(tc.x - 0.5f / textureSize(diffusivity_tex, 0).x, tc.y, gl_InstanceID);
26         tc_down = vec3(tc.x, tc.y - 0.5f / textureSize(diffusivity_tex, 0).y, gl_InstanceID);
27
28         // The equation textures have half the horizontal width, so we need to adjust the texel centers.
29         // It becomes extra tricky since the SOR texture might be of odd size, and then
30         // the equation texture is not exactly half the size.
31         vec2 element_idx = position * textureSize(diff_flow_tex, 0).xy - 0.5f;
32         float equation_texel_number_assuming_left = element_idx.x / 2.0f;
33         float equation_texel_number_assuming_right = (element_idx.x - 1.0f) / 2.0f;
34         equation_tc_assuming_left.x = (equation_texel_number_assuming_left + 0.5f) / textureSize(equation_red_tex, 0).x;
35         equation_tc_assuming_right.x = (equation_texel_number_assuming_right + 0.5f) / textureSize(equation_red_tex, 0).x;
36         equation_tc_assuming_left.y = tc.y;
37         equation_tc_assuming_right.y = tc.y;
38         equation_tc_assuming_left.z = gl_InstanceID;
39         equation_tc_assuming_right.z = gl_InstanceID;
40
41         element_x_idx = element_idx.x;
42         element_sum_idx = element_idx.x + element_idx.y;
43 }