From 389da8159978571e8156ff7692bc595d957e846e Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 23 Feb 2019 16:10:08 +0100 Subject: Store material in fluid buffer and improve visualization Replaces the density value which is actually not that useful for visualization. Encoding integer values as floats by casting and comparing them using exact floating point comparison is not very safe but works out for now. --- src/shader/code/stream.glsl | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/shader/code/stream.glsl') diff --git a/src/shader/code/stream.glsl b/src/shader/code/stream.glsl index a8aec1d..59aed98 100644 --- a/src/shader/code/stream.glsl +++ b/src/shader/code/stream.glsl @@ -5,7 +5,7 @@ layout (local_size_x = 1, local_size_y = 1) in; layout (std430, binding=1) buffer bufferCollide { float collideCells[]; }; layout (std430, binding=2) buffer bufferStream { float streamCells[]; }; -layout (std430, binding=4) buffer bufferGeometry { int materialCells[]; }; +layout (std430, binding=3) buffer bufferFluid { float fluidCells[]; }; /// LBM constants @@ -24,6 +24,10 @@ uint indexOfLatticeCell(uint x, uint y) { return q*nX*y + q*x; } +uint indexOfFluidVertex(uint x, uint y) { + return 3*nX*y + 3*x; +} + /// Data access float get(uint x, uint y, int i, int j) { @@ -35,17 +39,8 @@ void set(uint x, uint y, int i, int j, float v) { } int getMaterial(uint x, uint y) { - return materialCells[nX*y + x]; -} - -/// Domain description - -bool isEndOfWorld(uint x, uint y) { - return x == 0 || x == nX-1 || y == 0 || y == nY-1; -} - -bool isOuterWall(uint x, uint y) { - return x == 1 || x == nX-2 || y == 1 || y == nY-2; + const uint idx = indexOfFluidVertex(x, y); + return int(fluidCells[idx + 2]); } /// Boundary conditions @@ -74,7 +69,7 @@ void main() { return; } - if ( material == 2 ) { + if ( material == 2 || material == 3 ) { bounceBack(x,y); } -- cgit v1.2.3