Skip to content
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

Make mappings work with 8 and 16 bit segmentations #3953

Merged
merged 4 commits into from
Mar 28, 2019

Conversation

daniel-wer
Copy link
Member

@daniel-wer daniel-wer commented Mar 27, 2019

Getting a vec4 using texture2d from a 2-channel texture (as in the case of 16-bit segmentations) will return a vector like (a,a,a,b), which is why the binary search for mappings on the shader failed (as an exact match of (a,b,0,0) would be needed). I solved this by allowing a new packingDegree of 2 for 16-bit layers and by transforming the volume_color before using the mapping binary search (according to the packing degree).
Therefore, 8-bit segmentations which have a packingDegree of 4 should now work as well.

URL of deployed dev instance (used for testing):

Steps to test:

  • Open a tracing with a 16-bit or 8-bit segmentation layer and apply a mapping:
    • Either by using merger mode in a skeleton/hybrid tracing,
    • or by using the api, like webknossos.apiReady(3).then(async (api) => {api.data.setMapping(api.data.getVolumeTracingLayerName(), {1: 2, 2: 3}, {hideUnmappedIds: true})})
  • Mappings should work the same as for 32-bit segmentations

Issues:


Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

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

Thanks for delving into this! The changes look really good.

One thing, though: Can you search for const isMergerModeSupported = and adapt that code? The merger mode is currently disabled for 8 and 16 bit segmentations, but that can be undone now 🎉 :)

return vec4(bucketColor.b, bucketColor.a, bucketColor.b, bucketColor.a);
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment line here stating that the following code deals with packingDegree == 4.0? :) Took me a few seconds to figure out why there isn't a if (packingDegree == 4.0) { statement.

@@ -207,6 +207,14 @@ export const getColorForCoords: ShaderModule = {

float rgbaIndex = linearizeVec3ToIndexWithMod(offsetInBucket, bucketWidth, packingDegree);

if (packingDegree == 2.0) {
if (rgbaIndex == 0.0) {
return vec4(bucketColor.r, bucketColor.g, bucketColor.r, bucketColor.g);
Copy link
Member

Choose a reason for hiding this comment

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

Why is the pattern rgrg? Can't wrap my head around it right now :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a comment :)

@daniel-wer daniel-wer merged commit 8284d8e into master Mar 28, 2019
@daniel-wer daniel-wer deleted the fix-x-bit-mappings branch March 28, 2019 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants