Skip to content

Commit b317eaa

Browse files
author
Manfred Cheung
committed
fix: GraphPoints shaders use valueForIndex functions
1 parent d209c20 commit b317eaa

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

src/data/shaders/GraphPoints.fs.glsl

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#version 300 es
22
precision highp float;
3-
precision highp isampler2D;
3+
precision lowp isampler2D;
44

55
in vec2 vUv;
66

@@ -9,19 +9,7 @@ out vec4 fragColor;
99
uniform sampler2D uPointTexture;
1010
uniform isampler2D uClassTexture;
1111

12-
vec4 valueForIndex(sampler2D tex, int index) {
13-
int texWidth = textureSize(tex, 0).x;
14-
int col = index % texWidth;
15-
int row = index / texWidth;
16-
return texelFetch(tex, ivec2(col, row), 0);
17-
}
18-
19-
ivec4 ivalueForIndex(isampler2D tex, int index) {
20-
int texWidth = textureSize(tex, 0).x;
21-
int col = index % texWidth;
22-
int row = index / texWidth;
23-
return texelFetch(tex, ivec2(col, row), 0);
24-
}
12+
#pragma glslify: import(../../renderer/shaders/valueForIndex.glsl)
2513

2614
void main() {
2715
vec2 texSize = vec2(textureSize(uPointTexture, 0).xy);

src/renderer/shaders/valueForIndex.glsl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
precision lowp usampler2D;
2+
precision lowp isampler2D;
23

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

25+
ivec4 ivalueForIndex(isampler2D tex, int index) {
26+
int texWidth = textureSize(tex, 0).x;
27+
int col = index % texWidth;
28+
int row = index / texWidth;
29+
return texelFetch(tex, ivec2(col, row), 0);
30+
}
31+
2432
#pragma glslify: export(valueForIndex)

0 commit comments

Comments
 (0)