Repository navigation
Conversation
LABELMAP_EDGE_PROJECTION_BLEND read each voxel's segment with int(), which truncates. A label sampled a hair under its whole number (25 as 24.99...) became the segment below it, so a segment's projected outline took that segment's color, or vanished for segment 1. Round the label instead, as the WebGPU edge projection already does.
2 of 3 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
LABELMAP_EDGE_PROJECTION_BLENDreads a voxel's segment from the volume's second component withint(value.g), in four places ofvtkVolumeFS.glsl(twice on the center ray, twice incheckOnEdgeForNeighbor()).int()truncates, so a label that comes back a hair under its whole number becomes the segment below it. The center ray reads the label throughgetTextureValue(), a filtered texture sample (at the voxel's center when the component forces nearest interpolation), whilecheckOnEdgeForNeighbor()fetches the texel exactly.In an application using this blend mode (a two-component float volume, image and labels, with
setForceNearestInterpolation(1, true); Chrome on macOS, Apple silicon), several segments were outlined in the color of the segment numbered one below them, 25 in 24's color for example. Adding 0.5 before theint(), through a shader replacement, fixed every case. We haven't pinned down why the sampled label came back under its whole number there, but truncation turns any such error into the segment below, and rounding absorbs it.The WebGPU edge projection already rounds (
i32(round(sample.y * labelScale))inVolumePassFSQ), as do the WebGLImageResliceMapper's slab label outlines (int(... * 255.0 + 0.5)).Results
The new test draws three segments whose labels are stored a hair off their whole number, 0.99, 2.01 and 2.99, colored red, green and blue:
The test fails on master (6.88% of the pixels differ, against a tolerance of 1.5%) and passes with the change, both with SwiftShader, as in CI, and on an Apple GPU, which render it identically.
Changes
vtkVolumeFS.glsl: the four reads of the segment label inLABELMAP_EDGE_PROJECTION_BLENDround,int(round(x.g)), instead of truncating. No API change; the code is only compiled for that blend mode.testLabelmapEdgeProjection, with its baseline, inRendering/Core/VolumeMapper/test: the first test of this blend mode in the WebGL volume mapper. Skipped without WebGL, as the change is WebGL-only.PR Checklist