[vtkusers] Black renderwindow with vtkGPUVolumeRayCastMapper/MaximumIntensityProjection

Sophonet vtk12af6bc42 at kant.sophonet.de
Wed Feb 21 07:31:03 EST 2018


Hi Sankhesh and all,

just found a related problem in the developer-list:

https://www.vtk.org/pipermail/vtk-developers/2017-May/035107.html

Indeed, when doing both, setting defaultFormat.setSamples(0) when 
setting the surface format as well as 
vtkRenderWindow->SetMultiSamples(0), the volume appears as intended. I a 
bit puzzled there seems to be little documentation about it, and that no 
error message occurs pointing the developer to the right direction... 
Nevertheless, good that things work again here.

Thanks,

     Sophonet


On 2018-02-20 16:33, Sophonet wrote:
> Hi Sankhesh,
> 
> thanks for pushing me towards the next step of testing. Indeed, the
> VTK test which I have mentioned below works. After having spent some
> time on trying to localize the problem, it seems that this is related
> to the fact that my application is using Qt (5.10 - with desktop
> OpenGL backend, which works for all my other VTK-based
> visualizations).
> 
> I have followed all the suggestions for setting up a QVTKOpenGLWidget,
> but using the same code as in the test, the four viewers remain empty
> (which is what I am observing in my application as well). Code
> snippets are below...
> 
> Any hints on how to use vtkGPUVolumeRayCastMapper in a Qt 5
> application with the OpenGL2 backend?
> 
> Thanks,
> 
>      Sophonet
> 
> ---
> void TestGPURayCastBlendModes(vtkRenderWindow *renwin)
> {
>   // The code from the corresponding function in
>   //
> https://github.com/Kitware/VTK/blob/master/Rendering/Volume/Testing/Cxx/TestGPURayCastFourComponentsMIP.cxx
>   // with minor modifications to use the given renderwindow, and after 
> removing
>   // the few testing-statements
> }
> 
> int main(int argc, char *argv[])
> {
> 	QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
> 	QApplication app(argc, argv);
> 
> 	QMainWindow *mainWindow = new QMainWindow();
> 
> 	QVTKOpenGLWidget *widget = new QVTKOpenGLWidget(mainWindow);
> 
> 	auto *renwin = vtkGenericOpenGLRenderWindow::New();
> 	widget->SetRenderWindow(renwin);
> 	mainWindow->setCentralWidget(widget);
> 
> 	mainWindow->show();
> 	TestGPURayCastBlendModes(renwin);
>         return app.exec();
> }
> 
> 
> 
> On 2018-02-19 13:38, Sankhesh Jhaveri wrote:
>> Hi,
>> 
>> Well the difference between in my suggestion was that the minimum
>> scalar value was also getting an opacity weighing ensuring that you
>> should at least see a white cube if the volume has all the same
>> values. However, it that also doesn't show you anything, perhaps
>> there's something else going on.
>> 
>> Could you try running the VTK tests to see if the volume rendering
>> ones run and pass?
>> 
>> Thanks,
>> Sankhesh
>> 
>> On Mon, Feb 19, 2018, 4:05 AM Sophonet <vtk12af6bc42 at kant.sophonet.de>
>> wrote:
>> 
>>> Hi Sankhesh,
>>> 
>>> thanks for your message - just tried your suggestion, which is
>>> basically
>>> what I have already tried in the commented part of the code below.
>>> As
>>> expected, it did not change the result, my renderwindow is still
>>> black.
>>> 
>>> Any other hint?
>>> 
>>> Best regards,
>>> 
>>> Sophonet
>>> 
>>> On 2018-02-09 17:57, Sankhesh Jhaveri wrote:
>>>> Hi Sophonet,
>>>> 
>>>> Try setting the scalar opacity function over the whole range of
>>> scalar
>>>> values.
>>>> 
>>>> Something like:
>>>> 
>>>> double * range = data->GetScalarRange();
>>>> vtkNew<vtkPiecewiseFunction> f;
>>>> f->AddPoint(range[0], 0.1);
>>>> f->AddPoint(range[1], 1.0);
>>>> property->SetScalarOpacity(f);
>>>> 
>>>> Hope that helps,
>>>> Sankhesh
>>>> 
>>>>>>>> 
>>>> On Sat, Feb 3, 2018 at 5:37 AM Sophonet
>>>> <vtk12af6bc42 at kant.sophonet.de> wrote:
>>>> 
>>>>> Hi list,
>>>>> 
>>>>> in an earlier version of my software using VTK7.x and the OpenGL
>>>>> backend, MIP rendering was working using
>>> vtkGPUVolumeRayCastMapper
>>>>> and
>>>>> MaximumIntensityProjection.
>>>>> 
>>>>> However, in VTK 8.x (e.g. VTK 8.1.0), using the OpenGL2 backend,
>>> the
>>>>> renderwindow stays black/empty - VTK does not show an error
>>> message,
>>>>> and
>>>>> the IsRenderSupported (see below) does not seem to fail.
>>>>> 
>>>>> Any hints what is wrong with the code below? By the way: I have
>>>>> added
>>>>> the volumeProperty (and the piecewise function) after following a
>>>>> current VTK test program
>>>>> 
>>>> 
>>> 
>> (https://github.com/Kitware/VTK/blob/master/Rendering/Volume/Testing/Cxx/TestGPURayCastFourComponentsMIP.cxx).
>>>>> 
>>>>> vtkimagedata is a scalar medical image (unsigned short), so
>>> nothing
>>>>> special.
>>>>> 
>>>>> Thanks,
>>>>> 
>>>>> Sophonet
>>>>> 
>>>>> vtkNew<vtkGPUVolumeRayCastMapper> mapper;
>>>>> mapper->SetInputData(vtkimagedata);
>>>>> mapper->SetBlendModeToMaximumIntensity();
>>>>> 
>>>>> vtkNew<vtkVolume> volume;
>>>>> volume->SetMapper(mapper);
>>>>> // ... connect to renderer etc.
>>>>> 
>>>>> //NOTE: The following lines from VTK's
>>>>> TestGPURayCastFourComponentsMIP.cxx did not solve the problem
>>>>> //vtkNew<vtkVolumeProperty> volumeProperty;
>>>>> //volumeProperty->IndependentComponentsOn();
>>>>> 
>>>>> //volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION);
>>>>> //volumeProperty->SetShade(1);
>>>>> 
>>>>> //vtkNew<vtkPiecewiseFunction> f;
>>>>> //f->AddPoint(0, 0.0);
>>>>> //f->AddPoint(255, 1.0);
>>>>> //volumeProperty->SetScalarOpacity(f);
>>>>> 
>>>>> //int valid =
>>>>> mapper->IsRenderSupported(vtkrenderer_->GetRenderWindow(),
>>>>> volumeProperty);
>>>>> 
>>>>> // NOTE: No exception was thrown on my system
>>>>> //if (valid == 0)
>>>>> //  throw std::runtime_error("MIP rendering is not supported");
>>>>> //volume->SetProperty(volumeProperty);
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com [1] [1]
>>>>> 
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>> 
>>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>> 
>>>>> Search the list archives at:
>>> http://markmail.org/search/?q=vtkusers
>>>>> 
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> https://vtk.org/mailman/listinfo/vtkusers
>>>> --
>>>> 
>>>> SANKHESH JHAVERI
>>>> 
>>>> _SR. RESEARCH & DEVELOPMENT ENGINEER_ | KITWARE [2] | (518)
>>> 881-4417
>>>> 
>>>>>>>> 
>>>> Links:
>>>> ------
>>>> [1] http://www.kitware.com
>>>> [2] http://www.kitware.com/
>>  --
>> 
>> SANKHESH JHAVERI
>> 
>> _SR. RESEARCH & DEVELOPMENT ENGINEER_ | KITWARE [2] | (518) 881-4417
>> 
>>>> 
>> Links:
>> ------
>> [1] http://www.kitware.com
>> [2] http://www.kitware.com/
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> 
> Search the list archives at: http://markmail.org/search/?q=vtkusers
> 
> Follow this link to subscribe/unsubscribe:
> https://vtk.org/mailman/listinfo/vtkusers


More information about the vtkusers mailing list