[vtk-developers] Strange renderering with mixed polydata/volume with QVTKOpenGLWidget

Elvis Stansvik elvis.stansvik at orexplore.com
Mon May 22 10:31:21 EDT 2017


2017-05-22 16:25 GMT+02:00 Utkarsh Ayachit <utkarsh.ayachit at kitware.com>:
> Elvis,
>
> I am not sure what the ITK-SNAP thing is. No, I don't think setting required
> opengl version is the way to go.
>
> If I am following all your emails correctly, then the latest state is that
> my suggestion works on mac and you're going to confirm on Windows next.

Yes, that's correct. Sorry that my e-mails got a bit disorganized!

>
> If problems persist, it would be immensely helpful if you have an example
> that does the "highlight" e.g. modify TestQVTKOpenGLWidget.cxx[1] to add an
> actor for the "thing". That way I have a easy test case to reproduce your
> issue and then debug it.

The test case I sent was just that. The
vtkCubeSource/vtkPolyDataMapper in the test case was meant to mimic
the highlight/selection I have in our real application.

Right now I'm debugging some rendering problems on Windows 7 (intel)
that seems to have come from applying your setAlphaBufferSize(0)
solution (not sure yet).

As soon as I get access to the Windows 8.1 machine with nVidia
graphics again, I'll try to confirm that the workaround works there
(like it did on macOS).

Elvis

>
> Utkarsh
>
> [1]
> https://gitlab.kitware.com/vtk/vtk/blob/master/GUISupport/Qt/Testing/Cxx/TestQVTKOpenGLWidget.cxx
>
>
> On Mon, May 22, 2017 at 8:47 AM, Elvis Stansvik
> <elvis.stansvik at orexplore.com> wrote:
>>
>> 2017-05-22 13:39 GMT+02:00 Elvis Stansvik <elvis.stansvik at orexplore.com>:
>> > 2017-05-18 16:14 GMT+02:00 Elvis Stansvik
>> > <elvis.stansvik at orexplore.com>:
>> >> 2017-05-18 15:59 GMT+02:00 Utkarsh Ayachit
>> >> <utkarsh.ayachit at kitware.com>:
>> >>> For now, try doing this:
>> >>>   auto surfaceFormat = QVTKOpenGLWidget::defaultFormat()
>> >>>   surfaceFormat.setSamples(0);
>> >>>   surfaceFormat.setAlphaBufferSIze(0);
>> >>>   QSurfaceFormat::setDefaultFormat(surfaceFormat);
>> >>
>> >> Thanks for the suggestion. I tried it out on the Mac, but it looks
>> >> like it made no difference :/
>> >
>> > I'm really sorry, this must have been a PEBKAC from me, because now
>> > that I tried it again, it actually does solve the problem (!). I must
>> > have made some mistake first time I tried it.
>> >
>> > Rendering on the Mac is now correct. I will have to wait until I get
>> > access to the Windows/nVidia machine again to confirm that it solves
>> > it there too, but I'm hopeful that it does.
>> >
>> > (Note: I sent off a couple of e-mails earlier today with some
>> > screenshots from the Mac, that ended up in the moderation queue due to
>> > the screenshots being > 1000 KB).
>> >
>> > Many thanks for this tip Utkarsh.
>>
>> As a side note: I found this in the source code for ITK-SNAP [1]:
>>
>> // Starting with Qt 5.6, the OpenGL implementation uses OpenGL 2.0
>> // In this version of OpenGL, transparency is handled differently and
>> // looks wrong.
>> QSurfaceFormat gl_fmt;
>> gl_fmt.setMajorVersion(argdata.opengl_major);
>> gl_fmt.setMinorVersion(argdata.opengl_minor);
>> /*
>> gl_fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
>> gl_fmt.setRedBufferSize(1);
>> gl_fmt.setGreenBufferSize(1);
>> gl_fmt.setBlueBufferSize(1);
>> gl_fmt.setDepthBufferSize(1);
>> gl_fmt.setStencilBufferSize(0);
>> gl_fmt.setAlphaBufferSize(0);
>> */
>>
>> I'm guessing the comment is referring to the same issue I saw. Note
>> the commented setAlphaBufferSize(0). So is setting the GL version
>> explicitly like this the proper workaround?
>>
>> Elvis
>>
>> [1]
>> https://github.com/pyushkevich/itksnap/blob/master/GUI/Qt/main.cxx#L572-L574
>>
>> >
>> > Elvis
>> >
>> >>
>> >> Elvis
>> >>
>> >>>
>> >>>
>> >>> Utkarsh
>> >>>
>> >>> On Thu, May 18, 2017 at 8:57 AM, Elvis Stansvik
>> >>> <elvis.stansvik at orexplore.com> wrote:
>> >>>>
>> >>>> I'm porting our program to the new QVTKOpenGLWidget.
>> >>>>
>> >>>> In one place, we're using a semi-transparent polygonal cube to show
>> >>>> the selection of an area. We're doing volume rendering using
>> >>>> vtkGPUVolumeRayCastMapper in the same renderer, and the polygonal
>> >>>> selection marker is enclosing the volume in the X/Y dimensions.
>> >>>>
>> >>>> See the attached linux_selection_correct.png for how this is supposed
>> >>>> to look, and you'll understand what I mean. The light blue area is
>> >>>> the
>> >>>> selection marker.
>> >>>>
>> >>>> This has always worked fine, but after porting from QVTKWidget to
>> >>>> QVTKOpenGLWidget, the rendering looks strange on Windows (nvidia) and
>> >>>> macOS (2013 MBP, intel iris). See the attached
>> >>>> windows_nvidia_selection.png and macos_selection.png.
>> >>>>
>> >>>> The selection is visualized using
>> >>>>
>> >>>>   vtkCubeSource -> vtkPolyDataMapper
>> >>>>
>> >>>> and a vtkActor configured like this:
>> >>>>
>> >>>>     auto selectionColor = palette().color(QPalette::Highlight);
>> >>>>
>> >>>>     m_selectionMarkerActor->SetMapper(selectionMarkerMapper);
>> >>>>
>> >>>> m_selectionMarkerActor->GetProperty()->SetColor(selectionColor.redF(),
>> >>>>
>> >>>> selectionColor.greenF(),
>> >>>>
>> >>>> selectionColor.blueF());
>> >>>>     m_selectionMarkerActor->GetProperty()->SetOpacity(0.1);
>> >>>>     m_selectionMarkerActor->GetProperty()->SetAmbient(1.0);
>> >>>>     m_selectionMarkerActor->GetProperty()->SetDiffuse(0.0);
>> >>>>     m_selectionMarkerActor->GetProperty()->SetSpecular(0.0);
>> >>>>
>> >>>> Any idea why the rendering looks so strange on Windows/nvidia and
>> >>>> macOS/iris, respectively, when using the new widget class?
>> >>>>
>> >>>> We're using a recent VTK from Git master.
>> >>>>
>> >>>> We're doing the recommended
>> >>>>
>> >>>>
>> >>>> QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
>> >>>>
>> >>>> to set the default surface format before QApplication construction.
>> >>>>
>> >>>> In the particular QVTKOpenGLWidget used here, we modify the format
>> >>>> with
>> >>>>
>> >>>>     auto surfaceFormat = format();
>> >>>>     surfaceFormat.setSamples(0);
>> >>>>     setFormat(surfaceFormat);
>> >>>>
>> >>>> to disable multisampling.
>> >>>>
>> >>>> Very grateful for any advise on how to solve this.
>> >>>>
>> >>>> Cheers,
>> >>>> Elvis
>> >>>>
>> >>>> _______________________________________________
>> >>>> Powered by www.kitware.com
>> >>>>
>> >>>> Visit other Kitware open-source projects at
>> >>>> http://www.kitware.com/opensource/opensource.html
>> >>>>
>> >>>> Search the list archives at:
>> >>>> http://markmail.org/search/?q=vtk-developers
>> >>>>
>> >>>> Follow this link to subscribe/unsubscribe:
>> >>>> http://public.kitware.com/mailman/listinfo/vtk-developers
>> >>>>
>> >>>>
>> >>>
>
>


More information about the vtk-developers mailing list