2016-03-02 17:09:16 +00:00
|
|
|
#version 310 es
|
|
|
|
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
|
|
|
|
2017-01-21 09:07:38 +00:00
|
|
|
layout(binding = 0, std430) readonly buffer Distribution
|
2016-03-02 17:09:16 +00:00
|
|
|
{
|
|
|
|
vec2 distribution[];
|
2018-03-12 12:09:25 +00:00
|
|
|
} _137;
|
2016-03-02 17:09:16 +00:00
|
|
|
|
|
|
|
layout(binding = 2, std140) uniform UBO
|
|
|
|
{
|
|
|
|
vec4 uModTime;
|
2018-03-12 12:09:25 +00:00
|
|
|
} _166;
|
2016-03-02 17:09:16 +00:00
|
|
|
|
2017-01-21 09:07:38 +00:00
|
|
|
layout(binding = 1, std430) writeonly buffer HeightmapFFT
|
2016-03-02 17:09:16 +00:00
|
|
|
{
|
|
|
|
uint heights[];
|
2018-03-12 12:09:25 +00:00
|
|
|
} _225;
|
2016-03-02 17:09:16 +00:00
|
|
|
|
|
|
|
uvec2 workaround_mix(uvec2 a, uvec2 b, bvec2 sel)
|
|
|
|
{
|
2018-03-12 12:09:25 +00:00
|
|
|
uint _86;
|
2016-03-02 17:09:16 +00:00
|
|
|
if (sel.x)
|
|
|
|
{
|
2018-03-12 12:09:25 +00:00
|
|
|
_86 = b.x;
|
2016-03-02 17:09:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-12 12:09:25 +00:00
|
|
|
_86 = a.x;
|
2016-03-02 17:09:16 +00:00
|
|
|
}
|
2018-03-12 12:09:25 +00:00
|
|
|
uint _97;
|
2016-03-02 17:09:16 +00:00
|
|
|
if (sel.y)
|
|
|
|
{
|
2018-03-12 12:09:25 +00:00
|
|
|
_97 = b.y;
|
2016-03-02 17:09:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-12 12:09:25 +00:00
|
|
|
_97 = a.y;
|
2016-03-02 17:09:16 +00:00
|
|
|
}
|
2019-07-24 09:10:18 +00:00
|
|
|
return uvec2(_86, _97);
|
2016-03-02 17:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vec2 alias(vec2 i, vec2 N)
|
|
|
|
{
|
2016-12-05 09:22:54 +00:00
|
|
|
return mix(i, i - N, greaterThan(i, N * 0.5));
|
2016-03-02 17:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vec2 cmul(vec2 a, vec2 b)
|
|
|
|
{
|
|
|
|
vec2 r3 = a.yx;
|
|
|
|
vec2 r1 = b.xx;
|
2016-12-05 09:22:54 +00:00
|
|
|
vec2 R0 = a * r1;
|
2016-03-02 17:09:16 +00:00
|
|
|
vec2 r2 = b.yy;
|
2016-12-05 09:22:54 +00:00
|
|
|
vec2 R1 = r2 * r3;
|
|
|
|
return R0 + vec2(-R1.x, R1.y);
|
2016-03-02 17:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint pack2(vec2 v)
|
|
|
|
{
|
|
|
|
return packHalf2x16(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
void generate_heightmap()
|
|
|
|
{
|
2016-12-05 09:22:54 +00:00
|
|
|
uvec2 N = uvec2(64u, 1u) * gl_NumWorkGroups.xy;
|
2016-03-02 17:09:16 +00:00
|
|
|
uvec2 i = gl_GlobalInvocationID.xy;
|
2016-12-05 09:22:54 +00:00
|
|
|
uvec2 param = N - i;
|
2016-03-02 17:09:16 +00:00
|
|
|
uvec2 param_1 = uvec2(0u);
|
|
|
|
bvec2 param_2 = equal(i, uvec2(0u));
|
|
|
|
uvec2 wi = workaround_mix(param, param_1, param_2);
|
2018-03-12 12:09:25 +00:00
|
|
|
vec2 a = _137.distribution[(i.y * N.x) + i.x];
|
|
|
|
vec2 b = _137.distribution[(wi.y * N.x) + wi.x];
|
2016-03-02 17:09:16 +00:00
|
|
|
vec2 param_3 = vec2(i);
|
|
|
|
vec2 param_4 = vec2(N);
|
2018-03-12 12:09:25 +00:00
|
|
|
vec2 k = _166.uModTime.xy * alias(param_3, param_4);
|
2016-03-02 17:09:16 +00:00
|
|
|
float k_len = length(k);
|
2018-03-12 12:09:25 +00:00
|
|
|
float w = sqrt(9.81000041961669921875 * k_len) * _166.uModTime.z;
|
2016-03-02 17:09:16 +00:00
|
|
|
float cw = cos(w);
|
|
|
|
float sw = sin(w);
|
|
|
|
vec2 param_5 = a;
|
|
|
|
vec2 param_6 = vec2(cw, sw);
|
|
|
|
a = cmul(param_5, param_6);
|
|
|
|
vec2 param_7 = b;
|
|
|
|
vec2 param_8 = vec2(cw, sw);
|
|
|
|
b = cmul(param_7, param_8);
|
2016-12-05 09:22:54 +00:00
|
|
|
b = vec2(b.x, -b.y);
|
|
|
|
vec2 res = a + b;
|
2016-03-02 17:09:16 +00:00
|
|
|
vec2 param_9 = res;
|
2018-03-12 12:09:25 +00:00
|
|
|
_225.heights[(i.y * N.x) + i.x] = pack2(param_9);
|
2016-03-02 17:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
generate_heightmap();
|
|
|
|
}
|
|
|
|
|