Skip to content

Commit

Permalink
fix: GraphPoints shaders use valueForIndex functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Manfred Cheung committed Sep 14, 2023
1 parent d209c20 commit b317eaa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/data/shaders/GraphPoints.fs.glsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#version 300 es
precision highp float;
precision highp isampler2D;
precision lowp isampler2D;

in vec2 vUv;

Expand All @@ -9,19 +9,7 @@ out vec4 fragColor;
uniform sampler2D uPointTexture;
uniform isampler2D uClassTexture;

vec4 valueForIndex(sampler2D tex, int index) {
int texWidth = textureSize(tex, 0).x;
int col = index % texWidth;
int row = index / texWidth;
return texelFetch(tex, ivec2(col, row), 0);
}

ivec4 ivalueForIndex(isampler2D tex, int index) {
int texWidth = textureSize(tex, 0).x;
int col = index % texWidth;
int row = index / texWidth;
return texelFetch(tex, ivec2(col, row), 0);
}
#pragma glslify: import(../../renderer/shaders/valueForIndex.glsl)

void main() {
vec2 texSize = vec2(textureSize(uPointTexture, 0).xy);
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/shaders/valueForIndex.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
precision lowp usampler2D;
precision lowp isampler2D;

vec4 valueForIndex(sampler2D tex, int index) {
int texWidth = textureSize(tex, 0).x;
Expand All @@ -21,4 +22,11 @@ uint uivalueForIndex(usampler2D tex, int index) {
return texelFetch(tex, ivec2(col, row), 0)[0];
}

ivec4 ivalueForIndex(isampler2D tex, int index) {
int texWidth = textureSize(tex, 0).x;
int col = index % texWidth;
int row = index / texWidth;
return texelFetch(tex, ivec2(col, row), 0);
}

#pragma glslify: export(valueForIndex)

0 comments on commit b317eaa

Please sign in to comment.