[vtk-developers] UseJitteringOn() has no effect in 7.1.0.rc1

Elvis Stansvik elvis.stansvik at orexplore.com
Sat Oct 15 06:10:29 EDT 2016


2016-10-15 11:19 GMT+02:00 Elvis Stansvik <elvis.stansvik at orexplore.com>:
> 2016-10-15 11:16 GMT+02:00 Elvis Stansvik <elvis.stansvik at orexplore.com>:
>> 2016-10-14 15:54 GMT+02:00 Alvaro Sanchez <alvaro.sanchez at kitware.com>:
>>> Hi Elvis,
>>>
>>> the mapper uses a vtkPerlinNoise instance to generate the jitter noise and
>>> as far as I know there are currently no knobs exposed to tweak the amount of
>>> ray perturbation.  Are you using the GL2 backend?  It would also be good to
>>> know what features are active along with ray jittering (multiple components,
>>> etc.), so if you could provide some sample data or code would be very
>>> helpful.
>>
>> Hi again Alvaro,
>>
>> Here's a minimal test case including sample data (129 MB):
>>
>>     https://dl.dropboxusercontent.com/u/22350696/test_grain.tar.gz
>
> In case I ever take that down from Dropbox, this was the code:
>
> #include <vtkCamera.h>
> #include <vtkColorTransferFunction.h>
> #include <vtkGPUVolumeRayCastMapper.h>
> #include <vtkImageData.h>
> #include <vtkPiecewiseFunction.h>
> #include <vtkRenderer.h>
> #include <vtkRenderWindow.h>
> #include <vtkRenderWindowInteractor.h>
> #include <vtkSmartPointer.h>
> #include <vtkVolume.h>
> #include <vtkVolumeProperty.h>
> #include <vtkXMLImageDataReader.h>
>
> #include <iostream>
>
> int main(int argc, char *argv[])
> {
>     if (argc != 2) {
>         std::cerr << "Usage: test_grain <xmlfile>" << std::endl;
>         return 1;
>     }
>
>     auto reader = vtkSmartPointer<vtkXMLImageDataReader>::New();
>     reader->SetFileName(argv[1]);
>     reader->Update();
>
>     auto imageData = reader->GetOutput();
>
>     auto mapper = vtkSmartPointer<vtkGPUVolumeRayCastMapper>::New();
>     mapper->SetInputConnection(reader->GetOutputPort());
>     mapper->UseJitteringOn();
>
>     auto property = vtkSmartPointer<vtkVolumeProperty>::New();
>     property->SetInterpolationTypeToLinear();
>     property->SetScalarOpacityUnitDistance(imageData->GetSpacing()[0]);

And in case you wonder about this call to
SetScalarOpacityUnitDistance, it's because in our program we work with
two versions of the same volume data, one "low res" version (larger
spacing) which is what you see in the left view in my earlier
screenshots, and one "high res" version (smaller spacing) which is
what you see in the central view. Both versions use the same opacity
function, and to get the same look in both versions, we set the
ScalarOpacityUnitDistance to the spacing of the volume. See my recent
thread for more info [1], and especially Sankesh's second answer.

This got me thinking, could the fact that I have a quite small spacing
be a cause for the jittering to not have any noticable effect? In the
sample/test case I linked to, the spacing is 0.0002 (corresponding to
centimeters). This is just an idea, I don't know if the volume spacing
could/does have any effect on the result of enabling jittering.

Elvis

[1] http://public.kitware.com/pipermail/vtkusers/2016-September/096543.html

>     property->ShadeOff();
>
>     auto opacity = vtkSmartPointer<vtkPiecewiseFunction>::New();
>     opacity->AddPoint(0.000, 0.00);
>     opacity->AddPoint(0.800, 0.00);
>     opacity->AddPoint(2.000, 0.70);
>     opacity->AddPoint(3.500, 1.00);
>     opacity->AddPoint(20.000, 1.00);
>     property->SetScalarOpacity(opacity);
>
>     auto color = vtkSmartPointer<vtkColorTransferFunction>::New();
>     color->AddRGBPoint(0.000, 0.70, 0.70, 0.50);
>     color->AddRGBPoint(3.500, 0.00, 0.00, 0.00);
>     color->AddRGBPoint(20.000, 0.00, 0.00, 0.00);
>     property->SetColor(color);
>
>     auto volume = vtkSmartPointer<vtkVolume>::New();
>     volume->SetMapper(mapper);
>     volume->SetProperty(property);
>
>     auto renderer = vtkSmartPointer<vtkRenderer>::New();
>     renderer->SetBackground(1.0, 1.0, 1.0);
>     renderer->AddVolume(volume);
>
>     auto window = vtkSmartPointer<vtkRenderWindow>::New();
>     window->AddRenderer(renderer);
>     window->SetSize(600, 600);
>
>     auto interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
>     interactor->SetRenderWindow(window);
>
>     auto camera = renderer->GetActiveCamera();
>     camera->SetParallelProjection(true);
>     camera->SetPosition(1.0, 0.0, 0.0);
>     camera->SetViewUp(0, 0, 1);
>
>     renderer->ResetCamera();
>
>     window->Render();
>     interactor->Start();
>
>     return 0;
> }
>
> Elvis
>
>>
>> Build with:
>>
>>     cmake .
>>     make
>>
>> and run with:
>>
>>     ./test_grain rec-0300mm-0400mm.xml
>>
>> The result should be as in the attached screenshot.
>>
>> Elvis
>>
>>>
>>> Thanks!
>>> Alvaro
>>>
>>> On Fri, Oct 14, 2016 at 3:47 AM, Elvis Stansvik
>>> <elvis.stansvik at orexplore.com> wrote:
>>>>
>>>> Hi all,
>>>>
>>>> I updated our product to use VTK 7.1.0.rc1, as I was interested in
>>>> trying out vtkGPUVolumeRayCastMapper::UseJitteringOn() to get rid of
>>>> some woodgrain effects we're suffering from in our volume rendering
>>>> (mostly when the volumes are rendered very opaque).
>>>>
>>>> But turning the option on seems to have little to no effect. This is
>>>> the result with the option on:
>>>>
>>>>     https://dl.dropboxusercontent.com/u/22350696/out.ogv
>>>>
>>>> It looks about the same to me as it does with the option off.
>>>>
>>>> Are there any knobs for this option? How does it determine how much to
>>>> perturbate the rays?
>>>>
>>>> Thanks for any advise.
>>>>
>>>> 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
>>>>
>>>
>>>
>>>
>>> --
>>> Alvaro Sanchez
>>> Kitware, Inc.
>>> Senior R&D Engineer
>>> 21 Corporate Drive
>>> Clifton Park, NY 12065-8662
>>> Phone: 518-881-4901


More information about the vtk-developers mailing list