4 Display
Vectornaut edited this page 2024-08-27 07:07:07 +00:00

A display prototype is under development on the app-proto branch, in the app-proto/inversive-display folder. It only displays spheres so far.

Concept

Right now, we're drawing all the spheres in a single fragment shader. For each pixel, we do ray-casting to get a fragment for each sphere, and then we depth-sort the fragments to handle translucency.

Performance limits

  • Array size. As of commit a34fd0f, the SPHERE_MAX array size seems to affect frame rate a lot, even though we should only be using the first few elements of each array. Not sure whether this is coming from a depth-sorting bug, a memory handling detail, or something else.
    • The logistics of initializing the arrays and working around register limits could be the problem, as described in this forum post.
    • Commit ec48592 adds a crude frame time monitor, so we can see how changes affect timing. In commit f62f44b, we can adjust the size of the internal fragment arrays (controlled by SPHERE_MAX_INTERNAL) while keeping the size of the uniforms (controlled by SPHERE_MAX_UNIFORM) at 12. The rough measurements below confirm that the internal array size can affect frame rate a lot, even though we only use the first three spheres' worth of elements.
      SPHERE_MAX_INTERNAL Frame time (ms)
      3 16.7
      4 16.7
      5 16.7
      6 16.8
      8 19.7
      10 22.4
      12 25.1
      14 28.6
  • Shader variables. Browsers seem to limit the number of variables that fragment shaders can store. For example, see this vulnerability report and code review for Chromium. This limit doesn't seem to be part of the OpenGL standard, so it's hard to pin down.

References

This tutorial on metaballs describes various ways to pass object data into a fragment shader that draws many objects.