fix(vtkOpenGLImageCPRMapper): projectionScaledDirection should have vtkImageData direction matrix#3508
Merged
Merged
Conversation
finetjul
reviewed
May 18, 2026
Member
finetjul
left a comment
There was a problem hiding this comment.
LGTM
Can you please rebase and squash all your commits ?
…tkImageData direction matrix
Contributor
Author
|
Done. I rebased on the latest master and squashed the commits into one. |
Member
|
FYI @bruyeret |
|
🎉 This PR is included in version 36.0.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
vtkOpenGLImageCPRMapperalready usesMCTCMatrixto transform CPR samplepositions from model coordinates to texture coordinates. That matrix is built
from
image.getWorldToIndex(), so it includes thevtkImageDatadirectionmatrix.
However, the projection slab direction was still converted to texture space by
dividing by
volumeSizeMC:That only accounts for volume size. It does not account for image direction,
so CPR projection sampling can follow the wrong texture-space direction for
oriented images, including flipped or rotated
vtkImageData.Results
Before this change, the CPR sample position used
MCTCMatrix, but theprojection direction used a separate size-only conversion. This could make the
projection slab sample along the wrong axis or sign when
vtkImageDatadirection is not identity.
After this change, both the CPR sample position and the projection slab
direction are transformed through
MCTCMatrix. Positions usew = 1.0, whiledirection vectors use
w = 0.0so the image orientation and spacing areapplied without applying translation.
Changes
Transform the projection slab direction with
MCTCMatrixusingw = 0.0so image orientation is applied to direction vectors without applying
translation.
Replace the size-only
projectionDirection / volumeSizeMCconversion with(MCTCMatrix * vec4(projectionDirection, 0.0)).xyzso projection samplingfollows the correct direction for oriented
vtkImageData.Remove the
volumeSizeMCshader uniform and its CPU-side setup because theprojection direction conversion now comes directly from
MCTCMatrix.Documentation and TypeScript definitions were updated to match those changes
PR and Code Checklist
npm run reformatto have correctly formatted codeTesting
You can run
npm run example ImageCPRMapperand you can see the result is the same as modified.Both commands completed without errors.