diff --git a/tomviz/modules/ModuleVolume.cxx b/tomviz/modules/ModuleVolume.cxx index 96596ef21..edca11334 100644 --- a/tomviz/modules/ModuleVolume.cxx +++ b/tomviz/modules/ModuleVolume.cxx @@ -62,6 +62,7 @@ vtkStandardNewMacro(SmartVolumeMapper) { // NOTE: Due to a bug in vtkMultiVolume, a gradient opacity function must be // set or the shader will fail to compile. + // (likely fixed in https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8909) m_gradientOpacity->AddPoint(0.0, 1.0); connect(&HistogramManager::instance(), &HistogramManager::histogram2DReady, this, [=](vtkSmartPointer image, @@ -81,6 +82,12 @@ vtkStandardNewMacro(SmartVolumeMapper) this->updateColorMap(); emit this->renderNeeded(); }); + + // NOTE: Due to a bug in vtkMultiVolume, a gradient opacity function must + // be set or the shader will fail to compile. + // (likely fixed in https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8909) + connect(&VolumeManager::instance(), &VolumeManager::usingMultiVolumeChanged, + this, &ModuleVolume::updateColorMap); } ModuleVolume::~ModuleVolume() @@ -371,9 +378,20 @@ void ModuleVolume::updateColorMap() int propertyMode = vtkVolumeProperty::TF_1D; const Module::TransferMode mode = getTransferMode(); switch (mode) { - case (Module::SCALAR): - m_volumeProperty->SetGradientOpacity(m_gradientOpacity); + case (Module::SCALAR): { + // NOTE: Due to a bug in vtkMultiVolume, a gradient opacity function must + // be set or the shader will fail to compile. + // (likely fixed in + // https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8909) + bool usingMultiVolume = + VolumeManager::instance().usingMultiVolume(this->view()); + if (usingMultiVolume) { + m_volumeProperty->SetGradientOpacity(m_gradientOpacity); + } else { + m_volumeProperty->SetGradientOpacity(nullptr); + } break; + } case (Module::GRADIENT_1D): m_volumeProperty->SetGradientOpacity(gradientOpacityMap()); break; diff --git a/tomviz/modules/VolumeManager.cxx b/tomviz/modules/VolumeManager.cxx index 1bc65ddd4..e6135022b 100644 --- a/tomviz/modules/VolumeManager.cxx +++ b/tomviz/modules/VolumeManager.cxx @@ -90,6 +90,8 @@ void VolumeManager::onModuleAdded(Module* module) viewVolumes->auxProperty->SetScalarOpacity(viewVolumes->auxOpacity); // NOTE: Due to a bug in vtkMultiVolume, a gradient opacity function must // be set or the shader will fail to compile. + // (likely fixed in + // https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8909) viewVolumes->auxProperty->SetGradientOpacity( viewVolumes->auxGradientOpacity); viewVolumes->auxVolume->SetProperty(viewVolumes->auxProperty); @@ -243,6 +245,15 @@ bool VolumeManager::allowMultiVolume(vtkSMViewProxy* view) const return this->d->views[view]->usingMultiVolume; } +bool VolumeManager::usingMultiVolume(vtkSMViewProxy* view) const +{ + if (!this->d->views.contains(view)) { + return false; + } + + return this->d->views[view]->usingMultiVolume; +} + int VolumeManager::volumeCount(vtkSMViewProxy* view) const { if (!this->d->views.contains(view)) { diff --git a/tomviz/modules/VolumeManager.h b/tomviz/modules/VolumeManager.h index 36ea91689..e9130c37c 100644 --- a/tomviz/modules/VolumeManager.h +++ b/tomviz/modules/VolumeManager.h @@ -30,6 +30,7 @@ class VolumeManager : public QObject static VolumeManager& instance(); void allowMultiVolume(bool allow, vtkSMViewProxy* view); bool allowMultiVolume(vtkSMViewProxy* view) const; + bool usingMultiVolume(vtkSMViewProxy* view) const; int volumeCount(vtkSMViewProxy* view) const; signals: