Skip to content

Commit e4b4df8

Browse files
committed
Simplify
1 parent a78e960 commit e4b4df8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/src/shaders/update-vert.glsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ out vec2 oV;
1919

2020
void main() {
2121
if(l <= 0.f) {
22-
ivec2 ij = ivec2(gl_VertexID % 512, gl_VertexID / 512);
22+
int i = gl_VertexID;
23+
ivec2 ij = ivec2(i % 200, i / 200);
2324
vec2 rd = texelFetch(rg, ij, 0).rg;
2425
float th = aR.x + rd.r * (aR.y - aR.x);
2526
float x = cos(th);

lib/src/simulator.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,18 @@ const simulate = (
206206

207207
const rgNoiseTexture = gl.createTexture();
208208
gl.bindTexture(gl.TEXTURE_2D, rgNoiseTexture);
209+
gl.activeTexture(gl.TEXTURE0);
210+
209211
gl.texImage2D(
210212
gl.TEXTURE_2D,
211213
0,
212214
gl.RG8,
213-
512,
214-
512,
215+
200,
216+
200,
215217
0,
216218
gl.RG,
217219
gl.UNSIGNED_BYTE,
218-
randomRGData(512, 512),
220+
randomRGData(200, 200),
219221
);
220222

221223
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.MIRRORED_REPEAT);
@@ -262,9 +264,6 @@ const simulate = (
262264
// skipcq: JS-0339 -- set in default options
263265
const speedRange = options.speedRange!;
264266
setUpdateUniform(U_SPEED_RANGE, speedRange[0], speedRange[1]);
265-
gl.activeTexture(gl.TEXTURE0);
266-
gl.bindTexture(gl.TEXTURE_2D, rgNoiseTexture);
267-
setUpdateUniform(U_RANDOM_RG, 0);
268267

269268
gl.bindVertexArray(vertexArrayObjects[readIndex]);
270269
gl.bindBufferBase(gl.TRANSFORM_FEEDBACK_BUFFER, 0, buffers[writeIndex]);

0 commit comments

Comments
 (0)