]> git.sesse.net Git - nageru/blob - equations.vert
Split the equation texture in two, which speeds up SOR by ~30%.
[nageru] / equations.vert
1 #version 450 core
2
3 layout(location=0) in vec2 position;
4 out vec2 tc0, tc_left0, tc_down0;
5 out vec2 tc1, tc_left1, tc_down1;
6 out float line_offset;
7
8 uniform sampler2D diffusivity_tex;
9
10 void main()
11 {
12         // The result of glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0) is:
13         //
14         //   2.000  0.000  0.000 -1.000
15         //   0.000  2.000  0.000 -1.000
16         //   0.000  0.000 -2.000 -1.000
17         //   0.000  0.000  0.000  1.000
18         gl_Position = vec4(2.0 * position.x - 1.0, 2.0 * position.y - 1.0, -1.0, 1.0);
19
20         const vec2 half_texel = 0.5f / textureSize(diffusivity_tex, 0);
21
22         vec2 tc = position;
23         vec2 tc_left = vec2(tc.x - half_texel.x, tc.y);
24         vec2 tc_down = vec2(tc.x, tc.y - half_texel.y);
25
26         // Adjust for different texel centers.
27         tc0 = vec2(tc.x - half_texel.x, tc.y);
28         tc_left0 = vec2(tc_left.x - half_texel.x, tc_left.y);
29         tc_down0 = vec2(tc_down.x - half_texel.x, tc_down.y);
30
31         tc1 = vec2(tc.x + half_texel.x, tc.y);
32         tc_left1 = vec2(tc_left.x + half_texel.x, tc_left.y);
33         tc_down1 = vec2(tc_down.x + half_texel.x, tc_down.y);
34
35         line_offset = position.y * textureSize(diffusivity_tex, 0).y - 0.5f;
36 }