]> git.tdb.fi Git - libs/gl.git/blob - demos/forestpond/data/fluidsim.glsl
0f58a9b225e815963f2dc194f1835dc2a94650e0
[libs/gl.git] / demos / forestpond / data / fluidsim.glsl
1 #pragma MSP stage(compute)
2 layout(local_size_x=8, local_size_y=8) in;
3
4 uniform Params
5 {
6         float delta_time;
7         float velocity_damping;
8         float gravity;
9         float max_flow_fraction;
10         float residual_depth;
11         ivec2 drop_pos;
12         float drop_time;
13 };
14
15 layout(push_constant) uniform Time
16 {
17         float time;
18 };
19
20 uniform sampler2D surface_in;
21 uniform sampler2D velocity_in;
22 uniform sampler2D bottom_in;
23 layout(r32f) uniform image2D surface_out;
24 layout(rg32f) uniform image2D velocity_out;
25
26 vec2 get_depth(ivec2 coord)
27 {
28         float surface = texelFetch(surface_in, coord, 0).x;
29         float bottom = texelFetch(bottom_in, coord, 0).x;
30         return vec2(surface, surface-bottom);
31 }
32
33 vec4 get_data(ivec2 coord)
34 {
35         vec2 velocity = texelFetch(velocity_in, coord, 0).xy;
36         return vec4(velocity, get_depth(coord));
37 }