]> git.tdb.fi Git - libs/gl.git/blob - demos/forestpond/data/fluidsim.glsl
Implement water simulation and surface shader for forest pond
[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 clamping_in;
23 uniform sampler2D bottom_in;
24 layout(r32f) uniform image2D surface_out;
25 layout(rg32f) uniform image2D velocity_out;
26 layout(r32f) uniform image2D clamping_out;
27
28 float get_depth(ivec2 coord)
29 {
30         return texelFetch(surface_in, coord, 0).x-texelFetch(bottom_in, coord, 0).x;
31 }