Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 25, 2016

Conversation

monfera
Copy link
Member

@monfera monfera commented Oct 13, 2016

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

See plotly/plotly.js#995

@monfera monfera changed the title Preserve double float precision for splatting [WIP] Preserve double float precision for splatting Oct 13, 2016
@monfera monfera force-pushed the 64-bit branch 2 times, most recently from 95f72ee to 9e16bda Compare October 15, 2016 09:51
…nifying draw and pickDraw; local code changes
@monfera monfera changed the title [WIP] Preserve double float precision for splatting Double float precision for splatting and in the vertex shaders; draw/drawPick DRY etc. Oct 15, 2016
@etpinard
Copy link
Member

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

That should cover our needs 👍

@@ -0,0 +1,7 @@
#pragma glslify: export(pfx)
vec4 pfx(vec2 scaleHi, vec2 scaleLo, vec2 translateHi, vec2 translateLo, vec2 positionHi, vec2 positionLo) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nicely done.

@etpinard
Copy link
Member

Looks good 💃

@monfera monfera merged commit 2e6fa7d into gl-vis:master Oct 25, 2016
monfera added a commit that referenced this pull request Oct 25, 2016
Double float shaders; draw/pickDraw unification
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants