diff --git a/src/layer/multi_channel_setup.ts b/src/layer/multi_channel_setup.ts index e1f5da1872..6229eb4562 100644 --- a/src/layer/multi_channel_setup.ts +++ b/src/layer/multi_channel_setup.ts @@ -60,11 +60,12 @@ type MakeLayerFn = ( const MULTICHANNEL_FRAGMENT_MAIN = `#uicontrol invlerp contrast #uicontrol vec3 color color void main() { - float contrast_value = contrast(); if (VOLUME_RENDERING) { + float contrast_value = contrast(true /* with trilinear interpolation */); emitRGBA(vec4(color * contrast_value, contrast_value)); } else { + float contrast_value = contrast(); emitRGB(color * contrast_value); } } diff --git a/src/webgl/shader_ui_controls.ts b/src/webgl/shader_ui_controls.ts index 57cc69c942..e8a86217df 100644 --- a/src/webgl/shader_ui_controls.ts +++ b/src/webgl/shader_ui_controls.ts @@ -782,6 +782,15 @@ export function addControlsToBuilder( float ${uName}() { return ${uName}(getDataValue(${builderValue.channel.join(",")})); } +float ${uName}(bool interpolate) { + if (interpolate) { + return ${uName}(getInterpolatedDataValue(${builderValue.channel.join(",")})); + } + else { + return ${uName}(getDataValue(${builderValue.channel.join(",")})); + } +} + `, ]; builder.addFragmentCode(code); diff --git a/src/widget/transfer_function.ts b/src/widget/transfer_function.ts index b0ad6ff4ef..847badae86 100644 --- a/src/widget/transfer_function.ts +++ b/src/widget/transfer_function.ts @@ -1857,6 +1857,14 @@ vec4 ${name}(${shaderType} inputValue) { vec4 ${name}() { return ${name}(getDataValue(${channel.join(",")})); } +vec4 ${name}(bool interpolate) { + if (interpolate) { + return ${name}(getInterpolatedDataValue(${channel.join(",")})); + } + else { + return ${name}(getDataValue(${channel.join(",")})); + } +} `; if (dataType !== DataType.UINT64 && dataType !== DataType.FLOAT32) { const scalarType = DATA_TYPE_SIGNED[dataType] ? "int" : "uint";