gl-vis / gl-scatter2d

2D scatter plots
https://gl-vis.github.io/gl-scatter2d
MIT License
11 stars 5 forks source link

Double float precision for splatting and in the vertex shaders; draw/drawPick DRY etc. #1

Closed monfera closed 8 years ago

monfera commented 8 years ago

Without this, Float32 resolution causes an effective 24 bit space for splatting and in the vertex shaders, which is not enough for high resolution plotting. For example, a millisecond resolution would only be possible in the ~4 hour interval at the beginning of January 1, 1970; or the resolution between 1970 and 2016 could only be hourly, and it would also be unusably jittery on zoom/pan.

With this change, a millisecond resolution is possible for half million years, and zooming/panning introduces no jitter when zooming between a range of decades and a range of one millisecond.

Due to the significant changes, time was right to also dry up the two similar draw methods, and generally refactor the code a little bit. The code became shorter too.

Since the WebGL 1.0 standard carries only quite useless guarantees for precision - even when highp is specified - the proper operations is subject to the given hardware. It is expected that on (possibly existing) low precision hardware, the solution is at least as precise as it has been before this PR.

There are minor performance impacts, which shouldn't be noticeable:

See https://github.com/plotly/plotly.js/issues/995

etpinard commented 8 years ago

With this change, a millisecond resolution is possible for half million years

That should cover our needs :+1:

etpinard commented 8 years ago

Looks good :dancer: