Skip to content

Commit d2aa139

Browse files
authored
Merge pull request #24 from shuding/shu/a3b6
Fix Android 12 support
2 parents 891b78b + 5c1a050 commit d2aa139

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dist
2-
node_modules
2+
node_modules
3+
.DS_Store

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cobe",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"type": "module",
55
"main": "./dist/index.esm.js",
66
"files": [

src/shader.frag

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,39 @@ vec3 nearestFibonacciLattice(vec3 p, out float m) {
7777
// float v = idx / kPhi;
7878
// float theta = fract(v) * kTau;
7979

80-
int iFracV = int(idx) * 2654435769; // signed be like nearest-to-zero fmod; 2^32/phi
81-
float fracV = float(iFracV) * by2P32;
82-
float theta = fracV * kTau;
80+
// int iFracV = int(idx) * 2654435769; // signed be like nearest-to-zero fmod; 2^32/phi
81+
// float fracV = float(iFracV) * by2P32;
82+
// float theta = fracV * kTau;
83+
84+
// https://github.com/shuding/cobe/issues/16
85+
86+
float tidx = idx;
87+
float fracV = 0.;
88+
89+
// see codegen
90+
91+
if(tidx >= 524288.) { tidx-=524288.; fracV += 0.8038937048986554; }
92+
if(tidx >= 262144.) { tidx-=262144.; fracV += 0.9019468524493277; }
93+
if(tidx >= 131072.) { tidx-=131072.; fracV += 0.9509734262246639; }
94+
if(tidx >= 65536.) { tidx-=65536.; fracV += 0.4754867131123319; }
95+
if(tidx >= 32768.) { tidx-=32768.; fracV += 0.737743356556166; }
96+
if(tidx >= 16384.) { tidx-=16384.; fracV += 0.868871678278083; }
97+
if(tidx >= 8192.) { tidx-=8192.; fracV += 0.9344358391390415; }
98+
if(tidx >= 4096.) { tidx-=4096.; fracV += 0.46721791956952075; }
99+
if(tidx >= 2048.) { tidx-=2048.; fracV += 0.7336089597847604; }
100+
if(tidx >= 1024.) { tidx-=1024.; fracV += 0.8668044798923802; }
101+
if(tidx >= 512.) { tidx-=512.; fracV += 0.4334022399461901; }
102+
if(tidx >= 256.) { tidx-=256.; fracV += 0.21670111997309505; }
103+
if(tidx >= 128.) { tidx-=128.; fracV += 0.10835055998654752; }
104+
if(tidx >= 64.) { tidx-=64.; fracV += 0.5541752799932738; }
105+
if(tidx >= 32.) { tidx-=32.; fracV += 0.7770876399966369; }
106+
if(tidx >= 16.) { tidx-=16.; fracV += 0.8885438199983184; }
107+
if(tidx >= 8.) { tidx-=8.; fracV += 0.9442719099991592; }
108+
if(tidx >= 4.) { tidx-=4.; fracV += 0.4721359549995796; }
109+
if(tidx >= 2.) { tidx-=2.; fracV += 0.2360679774997898; }
110+
if(tidx >= 1.) { tidx-=1.; fracV += 0.6180339887498949; }
111+
112+
float theta = fract(fracV) * kTau;
83113

84114
float cosphi = 1. - 2. * idx * byDots;
85115
float sinphi = sqrt(1. - cosphi * cosphi);

src/shader.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)