[vtkusers] Artifacts along bounding box edges in volume rendering

Elvis Stansvik elvis.stansvik at orexplore.com
Mon Mar 13 03:32:58 EDT 2017


Den 13 mars 2017 8:10 fm skrev "Róbert Špir" <spir.robert at gmail.com>:
>
> Hi Elvis,
> this is caused by multisampling, if you set window->SetMultiSamples(0);
the
> artifact will disappear. I can reproduce it in your example on windows
with
> nvidia card.
>
> If you need antialiasing, you can try using FXAA which doesn't produce
these
> artifacts

Aha, thanks for having a look and clarifying. That makes perfect sense.

I'll give FXAA a go in a little while, when I'm back at work.

Elvis

> #include <vtkFXAAOptions.h>
>
>         vtkSmartPointer<vtkFXAAOptions> FXAAOptions =
> vtkSmartPointer<vtkFXAAOptions>::New();
>         FXAAOptions->SetRelativeContrastThreshold(0.125);
>         FXAAOptions->SetHardContrastThreshold(0.045);
>         FXAAOptions->SetSubpixelBlendLimit(0.75);
>         FXAAOptions->SetSubpixelContrastThreshold(0.25);
>         FXAAOptions->SetUseHighQualityEndpoints(true);
>         FXAAOptions->SetEndpointSearchIterations(12);
>
>         renderer->SetFXAAOptions(FXAAOptions);
>         renderer->SetUseFXAA(true);
>
> Robert
>
> -----Original Message-----
> From: vtkusers [mailto:vtkusers-bounces at vtk.org] On Behalf Of Elvis
Stansvik
> Sent: Monday, March 13, 2017 7:53 AM
> To: VTK Users <vtkusers at vtk.org>
> Subject: Re: [vtkusers] Artifacts along bounding box edges in volume
> rendering
>
> 2017-03-10 10:11 GMT+01:00 Elvis Stansvik <elvis.stansvik at orexplore.com>:
> > 2017-03-10 10:07 GMT+01:00 Elvis Stansvik <elvis.stansvik at orexplore.com
>:
> >> Hi all,
> >>
> >> I'm trying to debug a problem with artifacts appearing around the
> >> bounding box edges in my volume rendering (at certain camera angles).
> >> I can reproduce the problem with the minimal test case below. In the
> >> attached screen shot, notice the faint white artifacts along the
> >> bounding box edges.
> >>
> >> Anyone know where these come from and how I can fix it?
> >
> > I forgot to say, this is with VTK 7.1.0.
>
> Noone who knows where this comes from? Would be great if someone could
> confirm that they can reproduce it with my test case, as I'm beginning to
> suspect it might be graphics card specific (I'm on Linux, Intel graphics).
>
> Should I post to vtk-dev perhaps?
>
> Elvis
>
> >
> > Elvis
> >
> >>
> >> Thanks in advance,
> >> Elvis
> >>
> >>
> >> main.cpp:
> >>
> >> #include <algorithm>
> >>
> >> #include <vtkCamera.h>
> >> #include <vtkColorTransferFunction.h> #include
> >> <vtkGPUVolumeRayCastMapper.h> #include <vtkImageData.h> #include
> >> <vtkNew.h> #include <vtkPiecewiseFunction.h> #include <vtkRenderer.h>
> >> #include <vtkRenderWindow.h> #include <vtkRenderWindowInteractor.h>
> >> #include <vtkVolume.h> #include <vtkVolumeProperty.h>
> >>
> >> int main(int argc, char *argv[])
> >> {
> >>     vtkNew<vtkColorTransferFunction> colorFunction;
> >>     colorFunction->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
> >>     colorFunction->AddRGBPoint(1.0, 0.0, 0.0, 0.0);
> >>
> >>     vtkNew<vtkPiecewiseFunction> opacityFunction;
> >>     opacityFunction->AddPoint(0.0, 0.0);
> >>     opacityFunction->AddPoint(1.0, 1.0);
> >>
> >>     vtkNew<vtkImageData> data;
> >>     data->SetExtent(0, 200, 0, 200, 0, 200);
> >>     data->AllocateScalars(VTK_FLOAT, 1);
> >>     std::fill_n(static_cast<float *>(data->GetScalarPointer()),
> >> 8000000, 0.1);
> >>
> >>     vtkNew<vtkGPUVolumeRayCastMapper> mapper;
> >>     mapper->SetInputData(data.Get());
> >>
> >>     vtkNew<vtkVolumeProperty> property;
> >>     property->SetScalarOpacity(opacityFunction.Get());
> >>     property->SetColor(colorFunction.Get());
> >>
> >>     vtkNew<vtkVolume> volume;
> >>     volume->SetMapper(mapper.Get());
> >>     volume->SetProperty(property.Get());
> >>
> >>     vtkNew<vtkRenderer> renderer;
> >>     renderer->AddVolume(volume.Get());
> >>     renderer->SetBackground(1.0, 1.0, 1.0);
> >>
> >>     vtkNew<vtkRenderWindow> window;
> >>     window->AddRenderer(renderer.Get());
> >>
> >>     // Position camera such that artifacts appear
> >>     auto camera = renderer->GetActiveCamera();
> >>     camera->SetPosition(500.0, 220.0, 500.0);
> >>     camera->SetFocalPoint(0.0, 80.0, 0.0);
> >>     renderer->ResetCameraClippingRange();
> >>
> >>     vtkNew<vtkRenderWindowInteractor> interactor;
> >>     interactor->SetRenderWindow(window.Get());
> >>     interactor->Start();
> >>
> >>     return 0;
> >> }
> >>
> >>
> >> CMakeLists.txt:
> >>
> >> cmake_minimum_required(VERSION 3.1)
> >>
> >> project(TestCase)
> >>
> >> set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} /opt/VTK7)
> >>
> >> find_package(VTK 7.1 COMPONENTS
> >>     vtkCommonCore
> >>     vtkCommonDataModel
> >>     vtkCommonExecutionModel
> >>     vtkCommonMath
> >>     vtkInteractionStyle
> >>     vtkRenderingCore
> >>     vtkRenderingOpenGL2
> >>     vtkRenderingVolume
> >>     vtkRenderingVolumeOpenGL2
> >>     REQUIRED
> >> )
> >>
> >> add_executable(TestCase WIN32 main.cpp)
> >>
> >> target_link_libraries(TestCase PUBLIC
> >>     vtkCommonCore
> >>     vtkCommonDataModel
> >>     vtkCommonExecutionModel
> >>     vtkCommonMath
> >>     vtkInteractionStyle
> >>     vtkRenderingCore
> >>     vtkRenderingOpenGL2
> >>     vtkRenderingVolume
> >>     vtkRenderingVolumeOpenGL2
> >> )
> >>
> >> target_include_directories(TestCase PUBLIC
> >>     ${VTK_INCLUDE_DIRS}
> >> )
> >>
> >> target_compile_definitions(TestCase PUBLIC
> >>     ${VTK_DEFINITIONS}
> >> )
> >>
> >> set_target_properties(TestCase PROPERTIES
> >>     CXX_STANDARD 14
> >>     CXX_STANDARD_REQUIRED ON
> >> )
> _______________________________________________
> 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:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170313/b70804ef/attachment.html>


More information about the vtkusers mailing list