]> git.sesse.net Git - nageru/blob - futatabi/equations.vert
Log a warning when we kill a client that is not keeping up.
[nageru] / futatabi / equations.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 tc0, tc_left0, tc_down0;
6 out vec3 tc1, tc_left1, tc_down1;
7 out float line_offset;
8
9 uniform sampler2DArray diffusivity_tex;
10
11 void main()
12 {
13         // The result of glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0) is:
14         //
15         //   2.000  0.000  0.000 -1.000
16         //   0.000  2.000  0.000 -1.000
17         //   0.000  0.000 -2.000 -1.000
18         //   0.000  0.000  0.000  1.000
19         gl_Position = vec4(2.0 * position.x - 1.0, 2.0 * position.y - 1.0, -1.0, 1.0);
20         gl_Layer = gl_InstanceID;
21
22         const vec2 half_texel = 0.5f / textureSize(diffusivity_tex, 0).xy;
23
24         vec2 tc = position;
25         vec2 tc_left = vec2(tc.x - half_texel.x, tc.y);
26         vec2 tc_down = vec2(tc.x, tc.y - half_texel.y);
27
28         // Adjust for different texel centers.
29         tc0 = vec3(tc.x - half_texel.x, tc.y, gl_InstanceID);
30         tc_left0 = vec3(tc_left.x - half_texel.x, tc_left.y, gl_InstanceID);
31         tc_down0 = vec3(tc_down.x - half_texel.x, tc_down.y, gl_InstanceID);
32
33         tc1 = vec3(tc.x + half_texel.x, tc.y, gl_InstanceID);
34         tc_left1 = vec3(tc_left.x + half_texel.x, tc_left.y, gl_InstanceID);
35         tc_down1 = vec3(tc_down.x + half_texel.x, tc_down.y, gl_InstanceID);
36
37         line_offset = position.y * textureSize(diffusivity_tex, 0).y - 0.5f;
38 }