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:
the splatting is run on double floats rather than single-precision floats, so in theory, splatting might be a bit slower
more typed arrays are allocated in the main memory, but very likely, hardware that can handle millions of points can also trivially handle the few megabytes of extra allocation
similarly, the position attrib buffer is duplicated - necessarily, for the double precision - and it should also be but a trivial cost in GPU memory use
the vertex shaders are set to highp but in reality, even in the past they worked in high precision mode (the standard allows mediump to be of high precision)
math in the vertex shader is slightly more demanding; but vertex shader performance is unlikely to be a bottleneck, and also, elementary operation count is about the same as with the larger matrix multiplication that's been replaced
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:
highp
but in reality, even in the past they worked in high precision mode (the standard allowsmediump
to be of high precision)See https://github.com/plotly/plotly.js/issues/995