]> git.tdb.fi Git - libs/gl.git/blobdiff - demos/forestpond/data/fluidsim_clamp.glsl
Remove the separate clamping step from forest pond fluid simulation
[libs/gl.git] / demos / forestpond / data / fluidsim_clamp.glsl
diff --git a/demos/forestpond/data/fluidsim_clamp.glsl b/demos/forestpond/data/fluidsim_clamp.glsl
deleted file mode 100644 (file)
index 93e8bbc..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-import fluidsim;
-
-#pragma MSP stage(compute)
-void main()
-{
-       ivec2 size = imageSize(clamping_out);
-       ivec2 coord = ivec2(gl_GlobalInvocationID.xy)+ivec2(1, 1);
-       if(coord.x>=size.x-1 || coord.y>=size.y-1)
-               return;
-
-       float depth = get_depth(coord);
-       vec2 velocity = texelFetch(velocity_in, coord, 0).xy;
-       float left_vx = texelFetch(velocity_in, coord-ivec2(1, 0), 0).x;
-       float down_vy = texelFetch(velocity_in, coord-ivec2(0, 1), 0).y;
-
-       // Clamping step: prevent fluid depth from going negative
-       float total_out = max(velocity.x, 0.0)+max(velocity.y, 0.0)-min(left_vx, 0.0)-min(down_vy, 0.0);
-       float scale = min(max_flow_fraction/(total_out*delta_time), depth/residual_depth);
-
-       imageStore(clamping_out, coord, vec4(clamp(scale, 0.0, 1.0), 0.0, 0.0, 0.0));
-}