aboutsummaryrefslogtreecommitdiff
path: root/src/shader
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-02-22 22:24:30 +0100
committerAdrian Kummerlaender2019-02-22 22:24:30 +0100
commit9779fd7484f7af6d10ae28ca3763c6d938c341e3 (patch)
tree715245275169857f70d07d516bb0bc41e14fff45 /src/shader
parentf0b536ac93b3a9a49dfff8a7637f09b153a3b955 (diff)
downloadcompustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.tar
compustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.tar.gz
compustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.tar.bz2
compustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.tar.lz
compustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.tar.xz
compustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.tar.zst
compustream-9779fd7484f7af6d10ae28ca3763c6d938c341e3.zip
Tidy up wall drawing and geometry initialization
Diffstat (limited to 'src/shader')
-rw-r--r--src/shader/code/collide.glsl42
-rw-r--r--src/shader/code/vertex.glsl2
2 files changed, 26 insertions, 18 deletions
diff --git a/src/shader/code/collide.glsl b/src/shader/code/collide.glsl
index b58bec3..182f5bd 100644
--- a/src/shader/code/collide.glsl
+++ b/src/shader/code/collide.glsl
@@ -117,18 +117,37 @@ float equilibrium(float d, vec2 v, int i, int j) {
return w(i,j) * d * (1 + 3*comp(i,j,v) + 4.5*sq(comp(i,j,v)) - 1.5*sq(norm(v)));
}
+/// Disable wall interior
+
+void disableWallInterior(uint x, uint y) {
+ int wallNeighbors = 0;
+
+ for ( int i = -1; i <= 1; ++i ) {
+ for ( int j = -1; j <= 1; ++j ) {
+ const int material = getMaterial(x+i,y+j);
+ if ( material == 0 || material == 2 ) {
+ ++wallNeighbors;
+ }
+ }
+ }
+
+ if ( wallNeighbors == 9 ) {
+ setMaterial(x,y,0);
+ }
+}
+
/// Determine external influence
float getExternalPressureInflux(uint x, uint y) {
- if ( mouseState == 1 && norm(vec2(x,y) - mousePos) < 2 ) {
+ if ( mouseState == 1 && norm(vec2(x,y) - mousePos) < 3 ) {
return 1.5;
} else {
return 0.0;
}
}
-bool getExternalWallRequest(uint x, uint y) {
- if ( mouseState == 2 && norm(vec2(x,y) - mousePos) < 4 ) {
+bool isWallRequestedAt(uint x, uint y) {
+ if ( mouseState == 2 && norm(vec2(x,y) - mousePos) < 3 ) {
return true;
} else {
return false;
@@ -145,26 +164,15 @@ void main() {
return;
}
- if ( getExternalWallRequest(x,y) ) {
+ if ( isWallRequestedAt(x,y) ) {
setMaterial(x,y,2);
disableFluid(x,y);
}
const int material = getMaterial(x,y);
- if ( material == 2 ) {
- int wallNeighbors = 0;
- for ( int i = -1; i <= 1; ++i ) {
- for ( int j = -1; j <= 1; ++j ) {
- const int material = getMaterial(x+i,y+j);
- if ( material == 0 || material == 2 ) {
- ++wallNeighbors;
- }
- }
- }
- if ( wallNeighbors == 9 ) {
- setMaterial(x,y,0);
- }
+ if ( material == 2 ) { // wall
+ disableWallInterior(x,y);
}
if ( material == 1 ) { // fluid
diff --git a/src/shader/code/vertex.glsl b/src/shader/code/vertex.glsl
index 52d9403..69bbaef 100644
--- a/src/shader/code/vertex.glsl
+++ b/src/shader/code/vertex.glsl
@@ -10,7 +10,7 @@ out VS_OUT {
uniform uint nX;
uniform uint nY;
-const float displayAmplifier = 50.0;
+const float displayAmplifier = 10.0;
float unit(float x) {
return 1.0/(1.0+exp(-x));