Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
RohanFredriksson authored Jun 4, 2023
1 parent cf6fac4 commit 51edd4a
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# glsl-arbitrary-arithmetic
# GLSL Arbitrary Precision Arithmetic
An arbitrary-precision arithmetic library for the OpenGL Shading Language (GLSL)

```glsl
void main() {
uint c_r[ARRAY_SIZE];
uint c_i[ARRAY_SIZE];
uint z_r[ARRAY_SIZE];
uint z_i[ARRAY_SIZE];
load(c_r, -0.75);
load(c_i, 0.1);
zero(z_r);
zero(z_i);
uint nz_r[ARRAY_SIZE];
uint nz_i[ARRAY_SIZE];
int iterations = 64;
for (int k = 0; k < iterations; k++) {
uint tmp[ARRAY_SIZE];
uint radius[ARRAY_SIZE];
mul(z_r, z_r, tmp);
mul(z_i, z_i, radius);
add(radius, tmp, radius);
if (radius[1] > 4) {
return vec3(1.0, 1.0, 1.0) * (float(k) / float(iterations));
}
mul(z_i, z_i, nz_r);
negate(nz_r);
mul(z_r, z_r, tmp);
add(nz_r, tmp, nz_r);
add(nz_r, c_r, nz_r);
load(nz_i, 2.0);
mul(nz_i, z_r, nz_i);
mul(nz_i, z_i, nz_i);
add(nz_i, c_i, nz_i);
assign(z_r, nz_r);
assign(z_i, nz_i);
}
return vec3(0.0, 0.0, 0.0);
}
```

0 comments on commit 51edd4a

Please sign in to comment.