aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.cc18
-rw-r--r--src/shader/code/collide.glsl13
2 files changed, 23 insertions, 8 deletions
diff --git a/src/main.cc b/src/main.cc
index 99e9a73..5604f3d 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -25,7 +25,7 @@
#include "timer.h"
constexpr GLuint nX = 256;
-constexpr GLuint nY = 256;
+constexpr GLuint nY = 128;
constexpr int lups = 50; // max lattice updates per second
@@ -53,11 +53,19 @@ int setupGeometry(int x, int y) {
if ( x == 0 || y == 0 || x == nX-1 || y == nY-1 ) {
return 0; // disable end of world
}
- if ( ((x == 1 || x == nX-2) && (y > 0 && y < nY-1))
- || ((y == 1 || y == nY-2) && (x > 0 && x < nX-1)) ) {
+ if ( (x == 1 || x == nX-2) && (y > 0 && y < nY-1) ) {
+ if ( x == 1 && y > nY/4 && y < 3*nY/4 ) {
+ return 5; // inflow
+ }
+ if ( x == nX-2 && y > nY/4 && y < 3*nY/4 ) {
+ return 6; // outflow
+ }
+ return 2; // bounce back outer walls
+ }
+ if ( (y == 1 || y == nY-2) && (x > 0 && x < nX-1) ) {
return 2; // bounce back outer walls
}
- return 1; // everything else shall be fluid
+ return 1; // everything else shall be bulk fluid
}
int renderWindow() {
@@ -68,7 +76,7 @@ int renderWindow() {
return -1;
}
- float world_width = 1.5*nX;
+ float world_width = 1*nX;
float world_height = getWorldHeight(window.getWidth(), window.getHeight(), world_width);
glm::mat4 MVP = getMVP(world_width, world_height);
diff --git a/src/shader/code/collide.glsl b/src/shader/code/collide.glsl
index 0ddae7b..673a285 100644
--- a/src/shader/code/collide.glsl
+++ b/src/shader/code/collide.glsl
@@ -102,7 +102,7 @@ float equilibrium(float d, vec2 v, int i, int j) {
/// Material number meaning (geometry is only changed by the interaction shader)
bool isBulkFluidCell(int material) {
- return material == 1 || material == 4;
+ return material == 1 || material == 4 || material == 5 || material == 6;
}
float getExternalMassInflux(int material) {
@@ -126,8 +126,15 @@ void main() {
const int material = getMaterial(x,y);
if ( isBulkFluidCell(material) ) {
- const float d = max(density(x,y), getExternalMassInflux(material));
- const vec2 v = velocity(x,y,d);
+ float d = max(density(x,y), getExternalMassInflux(material));
+ vec2 v = velocity(x,y,d);
+
+ if ( material == 5 ) {
+ v = vec2(0.1,0.0);
+ }
+ if ( material == 6 ) {
+ d = 1.0;
+ }
setFluid(x,y,v);