Skip to content

Commit 5807fe7

Browse files
committed
Achieve better entropy
1 parent e4b4df8 commit 5807fe7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/src/shaders/update-vert.glsl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#version 300 es
2-
precision mediump float;
32

43
uniform float dt;/** time delta */
54
uniform sampler2D rg; /** random rg */
@@ -19,15 +18,15 @@ out vec2 oV;
1918

2019
void main() {
2120
if(l <= 0.f) {
22-
int i = gl_VertexID;
23-
ivec2 ij = ivec2(i % 200, i / 200);
24-
vec2 rd = texelFetch(rg, ij, 0).rg;
25-
float th = aR.x + rd.r * (aR.y - aR.x);
21+
int i = gl_VertexID + 1000 * int(dt);
22+
vec2 q = texelFetch(rg, ivec2((i + 2) % 200, 0), 0).rg;
23+
vec2 r = texelFetch(rg, ivec2(i % 200, i / 200), 0).rg;
24+
float th = aR.x + r.r * (aR.y - aR.x);
2625
float x = cos(th);
2726
float y = sin(th);
2827
oP = o;
29-
oL = lR.x + rd.r * (lR.y - lR.x);
30-
oV = vec2(x, y) * (sR.x + rd.g * (sR.y - sR.x));
28+
oL = lR.x + q.r * (lR.y - lR.x);
29+
oV = vec2(x, y) * (sR.x + r.g * (sR.y - sR.x));
3130
} else {
3231
oP = p + v * dt;
3332
oL = l - dt;

0 commit comments

Comments
 (0)