Skip to content

Commit dfbee4c

Browse files
dakerfinetjul
authored andcommitted
fix(ImageResliceMapper): normalize slab sampling direction
Ensure the slab sampling direction is normalized before computing step sizes and traversal distances. Previously, normalWCVSOutput was used directly, which could be a non-unit vector. This caused incorrect scaling of sampling steps, leading to inconsistent sampling density and potential visual artifacts when traversing the slab.
1 parent d296bd3 commit dfbee4c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • Sources/Rendering/OpenGL/ImageResliceMapper

Sources/Rendering/OpenGL/ImageResliceMapper/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,8 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
14311431
'// Get the first and last samples',
14321432
'int numSlices = 1;',
14331433
'float scaling = min(min(spacing.x, spacing.y), spacing.z) * 0.5;',
1434-
'vec3 normalxspacing = scaling * normalWCVSOutput;',
1434+
'vec3 slabNormal = normalize(normalWCVSOutput);',
1435+
'vec3 normalxspacing = scaling * slabNormal;',
14351436
'float distTraveled = length(normalxspacing);',
14361437
'int trapezoid = 0;',
14371438
'while (distTraveled < slabThickness * 0.5)',
@@ -1441,7 +1442,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
14411442
' if (distTraveled > slabThickness * 0.5)',
14421443
' {',
14431444
' // Before stepping outside the slab, sample at the boundaries',
1444-
' normalxspacing = normalWCVSOutput * slabThickness * 0.5 / fnumSlices;',
1445+
' normalxspacing = slabNormal * slabThickness * 0.5 / fnumSlices;',
14451446
' trapezoid = slabTrapezoid;',
14461447
' }',
14471448
' vec3 worldPosNeg = vertexWCVSOutput.xyz - fnumSlices * normalxspacing * vboScaling;',

0 commit comments

Comments
 (0)