aboutsummaryrefslogtreecommitdiff
path: root/src/shader/code/stream.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader/code/stream.glsl')
-rw-r--r--src/shader/code/stream.glsl14
1 files changed, 12 insertions, 2 deletions
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