• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 310 es
2layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
3
4layout(binding = 0, std430) readonly buffer Distribution
5{
6    vec2 distribution[];
7} _137;
8
9layout(binding = 2, std140) uniform UBO
10{
11    vec4 uModTime;
12} _166;
13
14layout(binding = 1, std430) writeonly buffer HeightmapFFT
15{
16    uint heights[];
17} _225;
18
19uvec2 workaround_mix(uvec2 a, uvec2 b, bvec2 sel)
20{
21    uint _86;
22    if (sel.x)
23    {
24        _86 = b.x;
25    }
26    else
27    {
28        _86 = a.x;
29    }
30    uint _97;
31    if (sel.y)
32    {
33        _97 = b.y;
34    }
35    else
36    {
37        _97 = a.y;
38    }
39    return uvec2(_86, _97);
40}
41
42vec2 alias(vec2 i, vec2 N)
43{
44    return mix(i, i - N, greaterThan(i, N * 0.5));
45}
46
47vec2 cmul(vec2 a, vec2 b)
48{
49    vec2 r3 = a.yx;
50    vec2 r1 = b.xx;
51    vec2 R0 = a * r1;
52    vec2 r2 = b.yy;
53    vec2 R1 = r2 * r3;
54    return R0 + vec2(-R1.x, R1.y);
55}
56
57uint pack2(vec2 v)
58{
59    return packHalf2x16(v);
60}
61
62void generate_heightmap()
63{
64    uvec2 N = uvec2(64u, 1u) * gl_NumWorkGroups.xy;
65    uvec2 i = gl_GlobalInvocationID.xy;
66    uvec2 param = N - i;
67    uvec2 param_1 = uvec2(0u);
68    bvec2 param_2 = equal(i, uvec2(0u));
69    uvec2 wi = workaround_mix(param, param_1, param_2);
70    vec2 a = _137.distribution[(i.y * N.x) + i.x];
71    vec2 b = _137.distribution[(wi.y * N.x) + wi.x];
72    vec2 param_3 = vec2(i);
73    vec2 param_4 = vec2(N);
74    vec2 k = _166.uModTime.xy * alias(param_3, param_4);
75    float k_len = length(k);
76    float w = sqrt(9.81000041961669921875 * k_len) * _166.uModTime.z;
77    float cw = cos(w);
78    float sw = sin(w);
79    vec2 param_5 = a;
80    vec2 param_6 = vec2(cw, sw);
81    a = cmul(param_5, param_6);
82    vec2 param_7 = b;
83    vec2 param_8 = vec2(cw, sw);
84    b = cmul(param_7, param_8);
85    b = vec2(b.x, -b.y);
86    vec2 res = a + b;
87    vec2 param_9 = res;
88    _225.heights[(i.y * N.x) + i.x] = pack2(param_9);
89}
90
91void main()
92{
93    generate_heightmap();
94}
95
96