Open martinxyz opened 1 year ago
Do I understand correctly that you have some other logic in Javascript that determines which of these ~100k cell centers should be visible, and you want some way of providing that visibility information to Neuroglancer?
This isn't something for which there is existing support. Potentially you could encode the visibility as a constant in the shader, e.g using a uint array to represent a bitvector, since then you could make use of the existing mechanism to modify the shader. However, I don't know if that would be too slow.
With "constant in the shader" you mean putting the data into the shader string? Interesting idea, we could avoid modifying neuroglancer if that works.
Yes, currently we have an external widget to select the visibility of point-annotations. We'd also like to control color or size, so it will be more than one bit. Let's say a uint32 for each of the ~100k annotations.
I think now ideally, Neuroglancer would fetch the pre-computed annotation chunks as usual. Then we'd need some hook to generate/update our uint32 values for the annotation-IDs as they get rendered. (And a way to re-trigger rendering when we change them.) For this we probably would add a new webgl Buffer
instead of modifiying the chunk-data? And then access that buffer from the shader. (If this doesn't sound too special-purpose, we may contribute it as a feature if we go that route.)
I've just thought of a (maybe silly) alternative: We could send our data to a custom backend server, change the layer's URL and let neuroglancer re-fetch the annotations as usual. The backend server would generate "pre-computed" annotations on-the-fly. (There is no "loopback" data-source to avoid the backend, I think?) But this may kill interactivity, and waste bandwith to re-download data we already have. (Would you expect this to leak all the data into a cache/memory for each update?)
I was asking basically about the same thing for the backend-based solution in how to re-trigger annotation source fetching in #445. I'm closing this other issue. I know that @chrisj worked on a similar topic so maybe he wants to comment here.
We are rendering ~100k cell centers as point annotations. This work great. (Precomputed format, only one spacial index. The comments in #227 helped a lot to set it up.)
Now we would like to visualize run-time information that we maintain external of neuroglancer (still in javascript). Basically a integer per cell. (More concrete: For visualizing multiple external selection states via point annotation shader.)
Conceptually, I think a Uint64Map (Annotation-ID --> Uint64) would work. The data is updated only infrequently (not per-frame), so I don't think it needs to be in the shader. A callback with the AnnotationID for each to-be-rendered annotation would probably work, too, as an API.
To see where this goes, we have added a uint32 property to the precomputed annotations. We can use that in the shader, and we have made an ugly hack (in neuroglancer/annotation/renderlayer.ts, drawGeometryChunkData) to overwrite the already fetched precomputed data at run-time and trigger redrawNeeded. This works.
Are there maybe alternatives approaches for this that I've overlooked, or even existing features that could serve this use-case?
(We first tried just to link via segmentation layer / relationship. But it seems that for 90k selected segments we would get 90k http range-requests, which I'm pretty sure will have very bad performance.)