aboutsummaryrefslogtreecommitdiff
path: root/src/shader/code/collide.glsl
diff options
context:
space:
mode:
authorAdrian Kummerlaender2018-12-18 17:04:18 +0100
committerAdrian Kummerlaender2018-12-18 17:04:18 +0100
commitfed710754296111a51b1b99b40a3c5e5dc873895 (patch)
tree1354a3bca2de3f52dc28bccdd633cfbc71ee5ae8 /src/shader/code/collide.glsl
parent556f6cea377f6e8620d05081946f8b469b8a1339 (diff)
downloadcompustream-fed710754296111a51b1b99b40a3c5e5dc873895.tar
compustream-fed710754296111a51b1b99b40a3c5e5dc873895.tar.gz
compustream-fed710754296111a51b1b99b40a3c5e5dc873895.tar.bz2
compustream-fed710754296111a51b1b99b40a3c5e5dc873895.tar.lz
compustream-fed710754296111a51b1b99b40a3c5e5dc873895.tar.xz
compustream-fed710754296111a51b1b99b40a3c5e5dc873895.tar.zst
compustream-fed710754296111a51b1b99b40a3c5e5dc873895.zip
Purify collide shader
i.e. move fluid vertex placement to appropriate vertex shader. Do not amplify or shift fluid moments in any way prior to passing it to the display pipeline.
Diffstat (limited to 'src/shader/code/collide.glsl')
-rw-r--r--src/shader/code/collide.glsl17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/shader/code/collide.glsl b/src/shader/code/collide.glsl
index cef2549..cbddfa9 100644
--- a/src/shader/code/collide.glsl
+++ b/src/shader/code/collide.glsl
@@ -7,8 +7,6 @@ layout (std430, binding=1) buffer bufferCollide{ float collideCells[]; };
layout (std430, binding=2) buffer bufferStream{ float streamCells[]; };
layout (std430, binding=3) buffer bufferFluid{ float fluidCells[]; };
-const float displayAmplifier = 10.;
-
/// LBM constants
uniform uint nX;
@@ -26,8 +24,8 @@ const float omega = 1/tau;
/// Vector utilities
-float comp(int x, int y, vec2 v) {
- return x*v.x + y*v.y;
+float comp(int i, int j, vec2 v) {
+ return i*v.x + j*v.y;
}
float sq(float x) {
@@ -68,9 +66,9 @@ void set(uint x, uint y, int i, int j, float v) {
void setFluid(uint x, uint y, vec2 v, float d) {
const uint idx = indexOfFluidVertex(x, y);
- fluidCells[idx + 0] = float(x) - nX/2;
- fluidCells[idx + 1] = float(y) - nY/2;
- fluidCells[idx + 2] = displayAmplifier * norm(v);
+ fluidCells[idx + 0] = v.x;
+ fluidCells[idx + 1] = v.y;
+ fluidCells[idx + 2] = norm(v);
}
/// Moments
@@ -101,6 +99,10 @@ void main() {
const uint x = gl_GlobalInvocationID.x;
const uint y = gl_GlobalInvocationID.y;
+ if ( !(x < nX && y < nY) ) {
+ return;
+ }
+
const float d = density(x,y);
const vec2 v = velocity(x,y,d);
@@ -112,6 +114,5 @@ void main() {
set(x,y,i,j, get(x,y,i,j) + omega * (eq - get(x,y,i,j)));
}
}
-
}
)";