diff --git a/src/components/VtkTwoView.vue b/src/components/VtkTwoView.vue index 7963ed303..85986d3aa 100644 --- a/src/components/VtkTwoView.vue +++ b/src/components/VtkTwoView.vue @@ -824,7 +824,7 @@ export default defineComponent({ opFunc.preset, opFunc.mappingRange, opFunc.shift, - opFunc.shiftAlpha, + opFunc.shiftAlpha ); if (opacityPoints) { pwf.setPoints(opacityPoints); diff --git a/src/utils/vtk-helpers.ts b/src/utils/vtk-helpers.ts index a760d778d..bb4d86b9c 100644 --- a/src/utils/vtk-helpers.ts +++ b/src/utils/vtk-helpers.ts @@ -129,7 +129,13 @@ export function getShiftedOpacityFromPreset( const [xmin, xmax] = effectiveRange; const width = xmax - xmin; - return points.map(([x, y]) => [(x - xmin) / width + shift, y - shiftAlpha]); + return points.map(([x, y]) => { + // Non-zero values should be affected by shift + // but preset values of zero should not + const shifted = y && y - shiftAlpha; + const yVal = Math.max(Math.min(shifted, 1), 0); + return [(x - xmin) / width + shift, yVal]; + }); } return null; } diff --git a/src/vtk/PiecewiseWidget/index.js b/src/vtk/PiecewiseWidget/index.js index e1725340f..d6d9ab62c 100644 --- a/src/vtk/PiecewiseWidget/index.js +++ b/src/vtk/PiecewiseWidget/index.js @@ -52,7 +52,11 @@ export function samplePiecewiseLinear( } else if (slope === -Infinity) { sampledPoints.push(0); } else { - sampledPoints.push(slope * (sx - p1[0]) + (p1[1] - shiftAlpha)); + // Non-zero values should be affected by shift + // but original values of zero should not + let value = slope * (sx - p1[0]) + p1[1]; + value = value && value - shiftAlpha; + sampledPoints.push(value); } } }