Skip to content

Commit 605383d

Browse files
authored
Merge pull request #7 from flekschas/increase-floating-point-precision
Increase floating point precision
2 parents ec7e88f + 7681c38 commit 605383d

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
## v0.7.4
99

10+
- Increase floating point precision (#5)
1011
- Fix a rare glitch in the lasso selection where the lasso would be drawn with a far away point
1112
- Smoothify lasso by lowering the min delay and min dist
1213
- Update 2D camera and many dev packages

src/point.vs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const VERTEX_SHADER = `
2-
precision mediump float;
2+
precision highp float;
33

44
uniform sampler2D colorTex;
55
uniform float colorTexRes;
@@ -29,7 +29,7 @@ void main() {
2929
float stateRowIndex = floor((stateIndex + eps) / stateTexRes);
3030
vec2 stateTexIndex = vec2(
3131
(stateIndex / stateTexRes) - stateRowIndex + eps,
32-
stateRowIndex / stateTexRes
32+
stateRowIndex / stateTexRes + eps
3333
);
3434

3535
vec4 state = texture2D(stateTex, stateTexIndex);
@@ -47,13 +47,13 @@ void main() {
4747
eps = 0.5 / colorTexRes;
4848
float colorLinearIndex = colorIndex + globalState;
4949
// Need to add cEps here to avoid floating point issue that can lead to
50-
// dramatic changes in which color is loaded as floor(3/2.9) = 1 but
50+
// dramatic changes in which color is loaded as floor(3/2.9999) = 1 but
5151
// floor(3/3.0001) = 0!
5252
float colorRowIndex = floor((colorLinearIndex + eps) / colorTexRes);
5353

5454
vec2 colorTexIndex = vec2(
5555
(colorLinearIndex / colorTexRes) - colorRowIndex + eps,
56-
colorRowIndex / colorTexRes
56+
colorRowIndex / colorTexRes + eps
5757
);
5858

5959
color = texture2D(colorTex, colorTexIndex);

0 commit comments

Comments
 (0)