diff options
author | Adrian Kummerlaender | 2018-12-19 21:05:58 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2018-12-19 21:05:58 +0100 |
commit | 762fb7fa5304a8e96757c091667d157f4a0bd311 (patch) | |
tree | 65500d44e715899f6d80547edfdb36a05b7b7683 /src/shader/code | |
parent | 8df8940bced82cad259bc8144aa3668871222d22 (diff) | |
download | compustream-762fb7fa5304a8e96757c091667d157f4a0bd311.tar compustream-762fb7fa5304a8e96757c091667d157f4a0bd311.tar.gz compustream-762fb7fa5304a8e96757c091667d157f4a0bd311.tar.bz2 compustream-762fb7fa5304a8e96757c091667d157f4a0bd311.tar.lz compustream-762fb7fa5304a8e96757c091667d157f4a0bd311.tar.xz compustream-762fb7fa5304a8e96757c091667d157f4a0bd311.tar.zst compustream-762fb7fa5304a8e96757c091667d157f4a0bd311.zip |
Loopify density function
…seems to be correctly unrolled during compilation. Or at least no
performance impact is visible.
Diffstat (limited to 'src/shader/code')
-rw-r--r-- | src/shader/code/collide.glsl | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/shader/code/collide.glsl b/src/shader/code/collide.glsl index 75bfd35..7b5534a 100644 --- a/src/shader/code/collide.glsl +++ b/src/shader/code/collide.glsl @@ -80,15 +80,11 @@ void setFluid(uint x, uint y, vec2 v, float d) { float density(uint x, uint y) { const uint idx = indexOfLatticeCell(x, y); - return collideCells[idx + 0] - + collideCells[idx + 1] - + collideCells[idx + 2] - + collideCells[idx + 3] - + collideCells[idx + 4] - + collideCells[idx + 5] - + collideCells[idx + 6] - + collideCells[idx + 7] - + collideCells[idx + 8]; + float d = 0.; + for ( int i = 0; i < q; ++i ) { + d += collideCells[idx + i]; + } + return d; } vec2 velocity(uint x, uint y, float d) { |