aboutsummaryrefslogtreecommitdiff
path: root/src/shader/code
diff options
context:
space:
mode:
authorAdrian Kummerlaender2018-12-19 21:12:39 +0100
committerAdrian Kummerlaender2018-12-19 21:12:39 +0100
commit5220729b8078c0b12dfbd403fb443c969362547b (patch)
tree084da1282c813657e1f36855bc7b97602975e405 /src/shader/code
parent762fb7fa5304a8e96757c091667d157f4a0bd311 (diff)
downloadcompustream-5220729b8078c0b12dfbd403fb443c969362547b.tar
compustream-5220729b8078c0b12dfbd403fb443c969362547b.tar.gz
compustream-5220729b8078c0b12dfbd403fb443c969362547b.tar.bz2
compustream-5220729b8078c0b12dfbd403fb443c969362547b.tar.lz
compustream-5220729b8078c0b12dfbd403fb443c969362547b.tar.xz
compustream-5220729b8078c0b12dfbd403fb443c969362547b.tar.zst
compustream-5220729b8078c0b12dfbd403fb443c969362547b.zip
Extract equilibrium function
Diffstat (limited to 'src/shader/code')
-rw-r--r--src/shader/code/collide.glsl9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/shader/code/collide.glsl b/src/shader/code/collide.glsl
index 7b5534a..3510c4e 100644
--- a/src/shader/code/collide.glsl
+++ b/src/shader/code/collide.glsl
@@ -94,6 +94,12 @@ vec2 velocity(uint x, uint y, float d) {
);
}
+/// Equilibrium distribution
+
+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)));
+}
+
/// Determine external influence
float getExternalPressureInflux(uint x, uint y) {
@@ -121,8 +127,7 @@ void main() {
for ( int i = -1; i <= 1; ++i ) {
for ( int j = -1; j <= 1; ++j ) {
- const float eq = w(i,j) * d * (1 + 3*comp(i,j,v) + 4.5*sq(comp(i,j,v)) - 1.5*sq(norm(v)));
- set(x,y,i,j, get(x,y,i,j) + omega * (eq - get(x,y,i,j)));
+ set(x,y,i,j, get(x,y,i,j) + omega * (equilibrium(d,v,i,j) - get(x,y,i,j)));
}
}
}