aboutsummaryrefslogtreecommitdiff
path: root/src/shader/code
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-11-08 23:02:47 +0100
committerAdrian Kummerlaender2019-11-08 23:02:47 +0100
commitd864699c5ddd744ee7376c0d752b6bbb771429a2 (patch)
tree9dd8973b17a0617ce595c2b92ec1d0faa8388083 /src/shader/code
parent35e2c7a949dedf3221887ffdc14dddb4c5e84f4c (diff)
downloadcompustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.tar
compustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.tar.gz
compustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.tar.bz2
compustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.tar.lz
compustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.tar.xz
compustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.tar.zst
compustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.zip
Update lattice multiple times per frame
Controlled by `--lupf` _Lattice updates per frame_ MLUPS are now calculated and displayed. While performance is still bad compared to a optimized GPU implementation (such as [1] or [2]) this improves the situation. [1]: https://tree.kummerlaender.eu/projects/symlbm_playground/ [2]: https://code.kummerlaender.eu/boltzgen/about/
Diffstat (limited to 'src/shader/code')
-rw-r--r--src/shader/code/collide.glsl14
-rw-r--r--src/shader/code/extra.glsl2
-rw-r--r--src/shader/code/vertex.glsl2
3 files changed, 9 insertions, 9 deletions
diff --git a/src/shader/code/collide.glsl b/src/shader/code/collide.glsl
index 0f9b2bd..ef1ba93 100644
--- a/src/shader/code/collide.glsl
+++ b/src/shader/code/collide.glsl
@@ -1,7 +1,7 @@
static const std::string COLLIDE_SHADER_CODE = R"(
#version 430
-layout (local_size_x = 1, local_size_y = 1) in;
+layout (local_size_x = 32, local_size_y = 1) in;
layout (std430, binding=1) buffer bufferCollide { float collideCells[]; };
layout (std430, binding=2) buffer bufferStream { float streamCells[]; };
@@ -32,7 +32,7 @@ const float latticeCharVelocity = 0.005;
/// Unit conversion
-const float resolution = max(nX,nY);
+const float resolution = min(nX,nY);
const float convLength = physCharLength / resolution;
const float convTime = latticeCharVelocity / physCharVelocity * physCharLength / resolution;
const float convVelocity = convLength / convTime;
@@ -110,7 +110,7 @@ int getMaterial(uint x, uint y) {
float density(uint x, uint y) {
const uint idx = indexOfLatticeCell(x, y);
- float d = 0.;
+ float d = 0.f;
for ( int i = 0; i < q; ++i ) {
d += collideCells[idx + i];
}
@@ -118,7 +118,7 @@ float density(uint x, uint y) {
}
vec2 velocity(uint x, uint y, float d) {
- return 1./d * vec2(
+ return 1.f/d * vec2(
get(x,y, 1, 0) - get(x,y,-1, 0) + get(x,y, 1, 1) - get(x,y,-1,-1) + get(x,y, 1,-1) - get(x,y,-1,1),
get(x,y, 0, 1) - get(x,y, 0,-1) + get(x,y, 1, 1) - get(x,y,-1,-1) - get(x,y, 1,-1) + get(x,y,-1,1)
);
@@ -127,7 +127,7 @@ 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)));
+ return w(i,j) * d * (1.f + 3.f*comp(i,j,v) + 4.5f*sq(comp(i,j,v)) - 1.5f*sq(norm(v)));
}
/// Material number meaning (geometry is only changed by the interaction shader)
@@ -179,10 +179,10 @@ void main() {
if ( isBulkFluidCell(material) ) {
if ( isInflowCell(material) ) {
- v = vec2(min(float(iT)/5000.0*latticeCharVelocity, latticeCharVelocity), 0.0);
+ v = vec2(min(float(iT)/100.f*latticeCharVelocity, latticeCharVelocity), 0.f);
}
if ( isOutflowCell(material) ) {
- d = 1.0;
+ d = 1.f;
}
if ( show_quality ) {
diff --git a/src/shader/code/extra.glsl b/src/shader/code/extra.glsl
index b8483ae..4b149fb 100644
--- a/src/shader/code/extra.glsl
+++ b/src/shader/code/extra.glsl
@@ -9,7 +9,7 @@ layout (std430, binding=4) buffer bufferExtra { float extraCells[]; };
uniform uint nX;
uniform uint nY;
-const float convLength = 1.0 / float(max(nX,nY));
+const float convLength = 1.0 / float(min(nX,nY));
/// Array indexing
diff --git a/src/shader/code/vertex.glsl b/src/shader/code/vertex.glsl
index 6ad54cf..10abf0c 100644
--- a/src/shader/code/vertex.glsl
+++ b/src/shader/code/vertex.glsl
@@ -58,7 +58,7 @@ float restrictedCurl(float curl) {
if ( abs(curl) < 1.0 ) {
return 0.5;
} else {
- return 0.5 + 0.5*min(1.0, curl / (50*palette_factor));
+ return 0.5 + 0.5*min(1.0, curl / sq(palette_factor));
}
}