Conversation
2adea07 to
ddeafb8
Compare
|
I've added support for segment properties here: https://github.com/seung-lab/neuroglancer/tree/cj-color-shader-share It is still rough, some slice view segmentation rendering options are left out for now, but it would be great to have some feedback on the format of the user shader so we could potentially start using this before the implementation is settled. I will add an example link of h01 with no auth requirement in the following comment. Here is a short link requiring authentication that showcases coloring segments by their tags. https://cj-color-shader-share-dot-neuroglancer-dot-seung-lab.ue.r.appspot.com/#!middleauth+https://global.daf-apis.com/nglstate/api/v1/5748761140658176 I decided to try to get the color computation for all the various output(3d/2d/html) running on as much of the same code as possible. That means I used the approach necessary for slice view, having each draw call have access to all the segment properties. I have one texture that is a map from segment id to segment property index which is used to determine if we have segment property info for that segment as well as used as an index to read from the individual texture for each segment property. For now I have each tag on it's own texture for simplicity but it could be optimized later to use bit flags. Textures only exist if they are actively used by the user shader. My goal is for One difficulty is the fact that segment properties allow an id to be any string. With the h01 dataset for instance, there are property ids with a forward slash. Annotation properties are restricted to the regular expression The approach to use the same rendering logic between all three allows for the possibility of meshes that combine multiple segments, which could be used in the future for base segment coloring. It can also be used to efficiently calculate automaticLayerBarColors if we expand I should try to reuse code that generates the segment query property histograms for the invlerp control. |
|
I wrote some documentation here that explains the format of the user shader: |
|
I didn't think you would have time to review the code due to the voxel painting PR but I opened up this PR here #871 so you can more easily take a look at it, it has some test deployment code |
But using skeleton properties in the segment shader might not be possible, have to override it in the skeleton shader
…r to segment color user shader
ddeafb8 to
2c0d5a1
Compare
|
I'm not qualified to comment on the implementation decisions, but I'm cheering on this PR in general! I took a quick look at the example link above. Here are a few questions, which may or may not be premature at this stage:
|
Thanks!
My assumption is that "colors linked to" should link the segment color shader as well. It currently doesn't so I'll work on that.
Yes, there is a type
String properties were unintentionally left out, we should be able to do that. |
e4127a2 to
36d1832
Compare
| get isReady() { | ||
| return this.loadingCounter === 0; | ||
| } | ||
| isReadyWatchable: WatchableValueInterface<boolean> = new WatchableValue( |
There was a problem hiding this comment.
segmentColorShaderControlState needs to way to differentiate between the lack of a segment property source and it not being loaded yet. I fixed it by waiting for layer.IsReady. If using isReady is the right way to handle it, I think the best fix is to convert loadingCounter and isReady to watchable/derivedwatchable values.
|
I added support for string segment properties using this temporary syntax
Just a little simpler to implement, especially when either the key or value are invalid since the result can just be replaced with I realized while working on string properties that segment property identifiers are not guaranteed to be unique. This color shader could just support the "first" property with the passed in identifier. I've been also thinking of how the invlerp control seems like the most natural way to interact with segment properties. We could add a property ui control. Something like
You would then get a dropdown that listed all the segment properties:
With this uicontrol, we could remove the new syntax I added which we do string preprocessing, it would also no longer require property identifiers to be unique to be fully supported. |
|
For whatever my opinion is worth, that all sounds great to me! I like the idea of a dropdown. Tangentially, I think it would also be a great addition for other shaders, especially annotation shaders. Hopefully whatever you implement here will be conceptually similar (from a user's perspective) to whatever gets implemented for other shaders (if such a feature is implemented). |
|
is there a way to support stuart's ask for having a standalone string property that can be initialized with values from the shader code? or is that a seperate feature? |



Rather than transpiling the shader to javascript, I setup a basic shader to render onto an offscreen canvas, and using gl.readPixels to get the value back into javascript. glsl-transpiler assumes a node environment, rather than modify or use polyfills, this seemed like a simpler solution. I also have a prototype for calculating multiple segment colors with one render pass, outputting a pixel per segment, I noted in the code that
get automaticLayerBarColorswould be a great place to use that.It doesn't have much purpose yet, I need to re-add my segmentaton property shader additions, but I wanted to get feedback on if this readPixels approach is preferable.