[vtkusers] Artifacts along bounding box edges in volume rendering
Elvis Stansvik
elvis.stansvik at orexplore.com
Fri Mar 10 04:11:50 EST 2017
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.
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
> )
More information about the vtkusers
mailing list