aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/shader/code/collide.glsl2
-rw-r--r--src/shader/code/stream.glsl14
2 files changed, 13 insertions, 3 deletions
diff --git a/src/shader/code/collide.glsl b/src/shader/code/collide.glsl
index 3510c4e..23e98f9 100644
--- a/src/shader/code/collide.glsl
+++ b/src/shader/code/collide.glsl
@@ -44,7 +44,7 @@ float norm(vec2 v) {
/// Array indexing
uint indexOfDirection(int i, int j) {
- return 3*(j+1) + (i+1);
+ return 3*(i+1) + (j+1);
}
uint indexOfLatticeCell(uint x, uint y) {
diff --git a/src/shader/code/stream.glsl b/src/shader/code/stream.glsl
index 9b77c85..1a2abe3 100644
--- a/src/shader/code/stream.glsl
+++ b/src/shader/code/stream.glsl
@@ -13,14 +13,24 @@ uniform uint nY;
const uint q = 9;
+// Array indexing
+
+uint indexOfDirection(int i, int j) {
+ return 3*(i+1) + (j+1);
+}
+
+uint indexOfLatticeCell(uint x, uint y) {
+ return q*nX*y + q*x;
+}
+
/// Data access
float get(uint x, uint y, int i, int j) {
- return collideCells[q*nX*y + q*x + (i+1)*3 + j+1];
+ return collideCells[indexOfLatticeCell(x,y) + indexOfDirection(i,j)];
}
void set(uint x, uint y, int i, int j, float v) {
- streamCells[q*nX*y + q*x + (i+1)*3 + j+1] = v;
+ streamCells[indexOfLatticeCell(x,y) + indexOfDirection(i,j)] = v;
}
/// Actual stream kernel