Hello Aashish,

Sorry for the late reply, I was busy last week.

Thanks for the update, and your work on this topic.
Yes I have seen that your change have been merged concerning the
ReductionFactor. Nevertheless, I am still getting a smaller frame rate with
the new backend. To highlight this, please find attached a very simple
application that loads a volume (
https://www.dropbox.com/s/ptqwi0ebv75kt35/volume.zip) and does volume
rendering while displaying the frame rate. This is pretty much what we show
to the user in our application, and in this condition, on my machine the
FPS are around 25 with the opengl1 backend
<http://picpaste.com/pics/Bench-OGL1.1446644265.png>, and 15 with the new
backend <http://picpaste.com/pics/Bench-OGL2.1446644630.png>, from this
week VTK master
It is very simple to test, just need change the VTK_DIR to an OpenGL1 or
OpenGL2 build, and place the volume.mhd and raw in the execution path.
Also you will find attached a small text file that summarizes the test that
have been done here.

I think the real reason why it appears slower with the OGL2 version is that
we try to have control on the "MaximalImageSampleDistance". If I remove the
line l_gpu_mapper->SetMaximumImageSampleDistance( 2. ); I get the same
frame rate with each backend. BUT, the new backend does decimate a lot more
the volume, leading to a very blurred image during rendering, and that's
not what we want :/

Again, thanks for paying attention to this problem, I hope this little
application and test case can help you to adjust the parameters...

Simon

PS : I did not get a chance to check the difference on Paraview, but I
believe the result will be the same as the attached example is really
simple.

2015-11-03 19:44 GMT+01:00 Aashish Chaudhary <[email protected]>
:

> Hi Simon,
>
> the branch has been merged into VTK master. I am not sure when Paraview is
> going to update the VTK, but you can do it manually if needed. We are also
> going to run our bench marking again to be sure since recently lot many
> changes went into the VTK / volume rendering. Please feel free to ping me
> again if it does not solve your issue.
>
> Looking forward to your feedback.
>
> - Aashish
>
> On Mon, Nov 2, 2015 at 8:02 AM, Aashish Chaudhary <
> [email protected]> wrote:
>
>> Hi Simon,
>>
>> I found the reason behind the appeared performance you were getting. We
>> have this code in volume rendering that when you interact changes the
>> sampling distance and in the newer code we were too conservative compare to
>> the last version. That's why you were getting better quality when you move
>> your mouse but lower frame rates. I pushed a branch in VTK to address the
>> issue. Would it be possible for you to build Paraview with VTK master?  It
>> may take 3-4 days or longer for Paraview's VTK to get updated.
>>
>> Thanks,
>> Aashish
>>
>> On Wed, Oct 28, 2015 at 11:59 AM, Aashish Chaudhary <
>> [email protected]> wrote:
>>
>>> Hi Simon,
>>>
>>> I am just finishing up a ParaView5 related parallel volume rendering bug
>>> (pushing a branch today to VTK). This is next on my list.
>>>
>>> - Aashish
>>>
>>> On Wed, Oct 28, 2015 at 11:57 AM, Simon ESNEAULT <
>>> [email protected]> wrote:
>>>
>>>> Hello Aashish
>>>>
>>>> Did you get a chance to try to load the dataset on Windows ?
>>>> Can I do anything to help you investigate ? Should I feel a bug, that
>>>> may act as a reminder ?
>>>> Have a nice day
>>>> Simon
>>>>
>>>>
>>>> 2015-10-27 18:26 GMT+01:00 Aashish Chaudhary <
>>>> [email protected]>:
>>>>
>>>>> Thanks Simon. This is really strange since we are not seeing it on Mac
>>>>> and Linux (but both has dedicated cards).
>>>>>
>>>>> I will look into it soon.
>>>>>
>>>>> - aashish
>>>>>
>>>>> On Tue, Oct 27, 2015 at 1:03 PM, Simon ESNEAULT <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Ok, thank you very much fort digging into this.
>>>>>> I've done some test and I believe I can see a similar slowdown
>>>>>> happening on OSX, with a MacBook pro retina 13" from 2013, Intel Iris 
>>>>>> 5100
>>>>>> graphics.
>>>>>> Good luck in the investigation, I you need more details, do not
>>>>>> hesitate to ask
>>>>>> Simon
>>>>>>
>>>>>> 2015-10-27 17:37 GMT+01:00 Aashish Chaudhary <
>>>>>> [email protected]>:
>>>>>>
>>>>>>> Ah, thanks. I will get back to you on this since on Linux I don't
>>>>>>> any issue so it has to be Windows specific thing.
>>>>>>>
>>>>>>> - Aashish
>>>>>>>
>>>>>>> On Tue, Oct 27, 2015 at 10:36 AM, Simon ESNEAULT <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> I tried with that one from yesterday and today's version
>>>>>>>> (4.4.0-209-gc399648)
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Simon
>>>>>>>>
>>>>>>>> 2015-10-27 15:19 GMT+01:00 Aashish Chaudhary <
>>>>>>>> [email protected]>:
>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>>>
>>>>>>>>> And when did you download this version?
>>>>>>>>> ParaView-latest-Qt4-OpenGL2-Windows-64bit.exe
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Aashish
>>>>>>>>>
>>>>>>>>> On Tue, Oct 27, 2015 at 10:17 AM, Simon ESNEAULT <
>>>>>>>>> [email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> Yes, I tried with and without the shading. Without shading
>>>>>>>>>> enabled, the new Opengl2 is also slower when zoomed in (in the 
>>>>>>>>>> described
>>>>>>>>>> condition). With shading enabled, the difference in speed between 
>>>>>>>>>> the two
>>>>>>>>>> version seems even bigger.
>>>>>>>>>> I got the version from the nightly build download section of
>>>>>>>>>> paraview website (it is still available). And I've just tried with 
>>>>>>>>>> that one
>>>>>>>>>> labeled "ParaView-latest-Qt4-OpenGL2-Windows-64bit.exe" with the same
>>>>>>>>>> results.
>>>>>>>>>>
>>>>>>>>>> About the FPS, it is difficult to give an exact number, because
>>>>>>>>>> it depends of the condition (zoomed or not etc...) but yes, this is 
>>>>>>>>>> the
>>>>>>>>>> idea.
>>>>>>>>>> In our software, I've exposed the frame rate using this example :
>>>>>>>>>> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/FrameRate
>>>>>>>>>> And the frame rate is around 15/20 for the first backend, and
>>>>>>>>>> around 6/8 for the new backend, on the same dataset (the one 
>>>>>>>>>> provided for
>>>>>>>>>> example), with the same mapper parameters
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>> Simon
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 2015-10-27 14:48 GMT+01:00 Aashish Chaudhary <
>>>>>>>>>> [email protected]>:
>>>>>>>>>>
>>>>>>>>>>> Hi Simon,
>>>>>>>>>>>
>>>>>>>>>>> This is helpful but just missing few more bits:
>>>>>>>>>>>
>>>>>>>>>>> 1) Did you try without the shading and see how the performance
>>>>>>>>>>> compares?
>>>>>>>>>>>
>>>>>>>>>>> 2) ParaView 4.4.0-193-gec96423 --> Where did you get this one
>>>>>>>>>>> from (ParaView download page or did you built yourself?)
>>>>>>>>>>>
>>>>>>>>>>> Also, so on your system the old mapper is running 30FPS and the
>>>>>>>>>>> new one at 15-20 FPS as per your summary.
>>>>>>>>>>>
>>>>>>>>>>> Thanks,
>>>>>>>>>>> - Aashish
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Tue, Oct 27, 2015 at 9:43 AM, Simon ESNEAULT <
>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hello Aashish,
>>>>>>>>>>>>
>>>>>>>>>>>> Sorry for the late answer, I was busy this morning.
>>>>>>>>>>>> Thanks for testing with the DataSet.
>>>>>>>>>>>> I agree the performance is still quite good with the new
>>>>>>>>>>>> backend, and I also get something like 15/20 fps on windows on an 
>>>>>>>>>>>> HD
>>>>>>>>>>>> screen. But when compared to the old one, and in some condition 
>>>>>>>>>>>> (when
>>>>>>>>>>>> zoomed especially), it looks really slower to me
>>>>>>>>>>>> The two tested version are :
>>>>>>>>>>>> - ParaView 4.4.0 64 bits final version for the old backend
>>>>>>>>>>>> - ParaView 4.4.0-193-gec96423 64 bits, for the OpenGL2 backend.
>>>>>>>>>>>> on a windows 7 box, Xeon E3-1220 v3 CPU, 16GB ram and Nvidia
>>>>>>>>>>>> Quadro K420
>>>>>>>>>>>>
>>>>>>>>>>>> To highlight the difference, here is what I do :
>>>>>>>>>>>> - Launch both version on the same computer at the same time
>>>>>>>>>>>> - Load the above dataset on each
>>>>>>>>>>>> - Select volume rendering
>>>>>>>>>>>> - Adjust the transfer function data range to [100-750] (the
>>>>>>>>>>>> default "Cool to Warm" is fine)
>>>>>>>>>>>> - Set the view direction to +Y
>>>>>>>>>>>> - Adjust the Y of the camera position to -300
>>>>>>>>>>>>
>>>>>>>>>>>> And start interacting ...
>>>>>>>>>>>> Dunno if there is an easy way to print out the Frame Rate in
>>>>>>>>>>>> Paraview, but the new version seems really twice slower in these
>>>>>>>>>>>> conditions... We can see it does not scale in the same way, the 
>>>>>>>>>>>> old backend
>>>>>>>>>>>> seems more aggressive on the image sample reduction, hence the
>>>>>>>>>>>> interactivity is better.
>>>>>>>>>>>> Shading enable or not does not change much
>>>>>>>>>>>>
>>>>>>>>>>>> I'm aware of the DesiredUpdateRate thing, we use to play with
>>>>>>>>>>>> this with the old backend to fine tune the interactivity, although 
>>>>>>>>>>>> what's
>>>>>>>>>>>> really inside was never clear to me
>>>>>>>>>>>>
>>>>>>>>>>>> I hope that there is enough information for you to reproduce
>>>>>>>>>>>> this, do not hesitate to ask for some more information.
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks a lot for your help
>>>>>>>>>>>> Simon
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> 2015-10-27 14:10 GMT+01:00 Aashish Chaudhary <
>>>>>>>>>>>> [email protected]>:
>>>>>>>>>>>>
>>>>>>>>>>>>> Dear Simon,
>>>>>>>>>>>>>
>>>>>>>>>>>>> Checking again. Wondering if you can provide some more detail
>>>>>>>>>>>>> on the binary you are using and whether or not without shading the
>>>>>>>>>>>>> rendering performance comparable to older version.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks,
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Mon, Oct 26, 2015 at 3:12 PM, Aashish Chaudhary <
>>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Simon,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I used your dataset on paraview master as of today on my
>>>>>>>>>>>>>> Linux box running Ubuntu 14.04 and NVIDA Quadro card and I am 
>>>>>>>>>>>>>> getting about
>>>>>>>>>>>>>> 15-20 FPS with shading on with 1920x1080 resolution.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Are you on the proper 4.4 or using RC1/RC2? I checked the
>>>>>>>>>>>>>> shading performance fix was in 4.4 but not in RC's. I don't have 
>>>>>>>>>>>>>> access to
>>>>>>>>>>>>>> Windows box right away but I will try there too.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> NOTE: You might get multiple emails because of the attachment
>>>>>>>>>>>>>> size issue. Sorry about that.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thanks,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Mon, Oct 26, 2015 at 2:45 PM, Aashish Chaudhary <
>>>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Mon, Oct 26, 2015 at 2:13 PM, Simon ESNEAULT <
>>>>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Hello Aashish,
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Thanks for the quick answer
>>>>>>>>>>>>>>>> We are using a vtkImageData, 512x512x591 with short element
>>>>>>>>>>>>>>>> (you can find the dataset here :
>>>>>>>>>>>>>>>> https://www.dropbox.com/s/ptqwi0ebv75kt35/volume.zip). So
>>>>>>>>>>>>>>>> I think it's all about GPU volume raycast mapper.
>>>>>>>>>>>>>>>> The new mapper does bring low resolution, but when compared
>>>>>>>>>>>>>>>> to the old one, it seems less "low resolution" during 
>>>>>>>>>>>>>>>> interaction than the
>>>>>>>>>>>>>>>> old one
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Right, so that's why its not a exact comparison. What
>>>>>>>>>>>>>>> happens is that depending on what is interactive, (you can set 
>>>>>>>>>>>>>>> the desired
>>>>>>>>>>>>>>> update rate in VTK, not exposed in ParaView I believe),  it 
>>>>>>>>>>>>>>> will do
>>>>>>>>>>>>>>> interactive but with higher resolution (smaller sample 
>>>>>>>>>>>>>>> distance).  If they
>>>>>>>>>>>>>>> both have the same sample distance, then the new mapper should 
>>>>>>>>>>>>>>> out perform
>>>>>>>>>>>>>>> the old one, however, there is another thing we need to 
>>>>>>>>>>>>>>> consider here which
>>>>>>>>>>>>>>> is shading.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Shading is enabled, gradient opacity disabled
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Can you disable the shading and see if now they both
>>>>>>>>>>>>>>> (opengl1 and 2) equally better? We already pushed a fix for it 
>>>>>>>>>>>>>>> but not sure
>>>>>>>>>>>>>>> if that you have in your build.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Don't know if you need a minimal example, but I believe the
>>>>>>>>>>>>>>>> GPURenderDemo used with this dataset is enough to highlight 
>>>>>>>>>>>>>>>> the slow down.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Yes, I will use this dataset. Thanks.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>>>>> Simon
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> 2015-10-26 18:57 GMT+01:00 Aashish Chaudhary <
>>>>>>>>>>>>>>>> [email protected]>:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Also,
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Do you have shading enabled? We fixed a bug with shading
>>>>>>>>>>>>>>>>> that was causing the slow performance a while back. I don't 
>>>>>>>>>>>>>>>>> remember if
>>>>>>>>>>>>>>>>> that was included in 4.4 or not ( I can check ).
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> - Aashish
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> On Mon, Oct 26, 2015 at 1:53 PM, Aashish Chaudhary <
>>>>>>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Simon,
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> What kind of dataset you are using? Depending on the data
>>>>>>>>>>>>>>>>>> type you might be using
>>>>>>>>>>>>>>>>>> the GPU one or the unstructured renderer. The performance
>>>>>>>>>>>>>>>>>> we measured is related to the GPU ray cast mapper
>>>>>>>>>>>>>>>>>> and will apply only to the vtkImageData inputs.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Also, helpful would be is if you can tell if the new
>>>>>>>>>>>>>>>>>> mapper is bringing low resolution when you interact with the 
>>>>>>>>>>>>>>>>>> volume (and
>>>>>>>>>>>>>>>>>> whether or not it happens with old mapper).
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Thanks,
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> On Mon, Oct 26, 2015 at 1:47 PM, Simon ESNEAULT <
>>>>>>>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Hi All,
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> We are trying to make the switch to the new OpenGL2
>>>>>>>>>>>>>>>>>>> backend for our application, and although the switch was 
>>>>>>>>>>>>>>>>>>> easy (thanks for
>>>>>>>>>>>>>>>>>>> not breaking the API ;) ), we can see a significant 
>>>>>>>>>>>>>>>>>>> slowdown on the GPU
>>>>>>>>>>>>>>>>>>> volume rendering part, especially during interaction. 
>>>>>>>>>>>>>>>>>>> Typically we dropped
>>>>>>>>>>>>>>>>>>> from 15/20 fps to 7/8 fps, on the same machine (Win32, 
>>>>>>>>>>>>>>>>>>> Nvidia Quadro K420),
>>>>>>>>>>>>>>>>>>> with the same code around.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> This slow down can be seen in ParaView, if you compare
>>>>>>>>>>>>>>>>>>> the latest 4.4 OpenGL2 build with the classic 4.4 build 
>>>>>>>>>>>>>>>>>>> while volume
>>>>>>>>>>>>>>>>>>> rendering a big enough volume (512^3)
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> The blog post here
>>>>>>>>>>>>>>>>>>> http://www.kitware.com/blog/home/post/976
>>>>>>>>>>>>>>>>>>> claims that the new GPU volume rendering implementation
>>>>>>>>>>>>>>>>>>> should be faster than the old one, is there some more 
>>>>>>>>>>>>>>>>>>> detailed explanation
>>>>>>>>>>>>>>>>>>> somewhere ? Are there some important parameters that can 
>>>>>>>>>>>>>>>>>>> make the
>>>>>>>>>>>>>>>>>>> difference ?
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Thanks,
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Simon
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> PS : The polygonal rendering seems a lot faster with the
>>>>>>>>>>>>>>>>>>> new backend !
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>>>>>>>>>>> Simon Esneault
>>>>>>>>>>>>>>>>>>> Rennes, France
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>>>>>>>>> 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
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> *| Aashish Chaudhary | Technical Leader         | Kitware
>>>>>>>>>>>>>>>>>> Inc.            *
>>>>>>>>>>>>>>>>>> *| http://www.kitware.com/company/team/chaudhary.html
>>>>>>>>>>>>>>>>>> <http://www.kitware.com/company/team/chaudhary.html>*
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> *| Aashish Chaudhary | Technical Leader         | Kitware
>>>>>>>>>>>>>>>>> Inc.            *
>>>>>>>>>>>>>>>>> *| http://www.kitware.com/company/team/chaudhary.html
>>>>>>>>>>>>>>>>> <http://www.kitware.com/company/team/chaudhary.html>*
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>>>>>>>> Simon Esneault
>>>>>>>>>>>>>>>> Rennes, France
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> *| Aashish Chaudhary | Technical Leader         | Kitware
>>>>>>>>>>>>>>> Inc.            *
>>>>>>>>>>>>>>> *| http://www.kitware.com/company/team/chaudhary.html
>>>>>>>>>>>>>>> <http://www.kitware.com/company/team/chaudhary.html>*
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> *| Aashish Chaudhary | Technical Leader         | Kitware
>>>>>>>>>>>>>> Inc.            *
>>>>>>>>>>>>>> *| http://www.kitware.com/company/team/chaudhary.html
>>>>>>>>>>>>>> <http://www.kitware.com/company/team/chaudhary.html>*
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> *| Aashish Chaudhary | Technical Leader         | Kitware
>>>>>>>>>>>>> Inc.            *
>>>>>>>>>>>>> *| http://www.kitware.com/company/team/chaudhary.html
>>>>>>>>>>>>> <http://www.kitware.com/company/team/chaudhary.html>*
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>>
>>>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>>>> Simon Esneault
>>>>>>>>>>>> Rennes, France
>>>>>>>>>>>>
>>>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> *| Aashish Chaudhary | Technical Leader         | Kitware Inc.
>>>>>>>>>>>           *
>>>>>>>>>>> *| http://www.kitware.com/company/team/chaudhary.html
>>>>>>>>>>> <http://www.kitware.com/company/team/chaudhary.html>*
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>> Simon Esneault
>>>>>>>>>> Rennes, France
>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> *| Aashish Chaudhary | Technical Leader         | Kitware Inc.
>>>>>>>>>         *
>>>>>>>>> *| http://www.kitware.com/company/team/chaudhary.html
>>>>>>>>> <http://www.kitware.com/company/team/chaudhary.html>*
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> ------------------------------------------------------------------
>>>>>>>> Simon Esneault
>>>>>>>> Rennes, France
>>>>>>>> ------------------------------------------------------------------
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> *| Aashish Chaudhary | Technical Leader         | Kitware Inc.
>>>>>>>       *
>>>>>>> *| http://www.kitware.com/company/team/chaudhary.html
>>>>>>> <http://www.kitware.com/company/team/chaudhary.html>*
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> ------------------------------------------------------------------
>>>>>> Simon Esneault
>>>>>> Rennes, France
>>>>>> ------------------------------------------------------------------
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>>
>>>>>
>>>>> *| Aashish Chaudhary | Technical Leader         | Kitware Inc.
>>>>>     *
>>>>> *| http://www.kitware.com/company/team/chaudhary.html
>>>>> <http://www.kitware.com/company/team/chaudhary.html>*
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> ------------------------------------------------------------------
>>>> Simon Esneault
>>>> Rennes, France
>>>> ------------------------------------------------------------------
>>>>
>>>
>>>
>>>
>>> --
>>>
>>>
>>>
>>> *| Aashish Chaudhary | Technical Leader         | Kitware Inc.
>>>   *
>>> *| http://www.kitware.com/company/team/chaudhary.html
>>> <http://www.kitware.com/company/team/chaudhary.html>*
>>>
>>
>>
>>
>> --
>>
>>
>>
>> *| Aashish Chaudhary | Technical Leader         | Kitware Inc.
>> *
>> *| http://www.kitware.com/company/team/chaudhary.html
>> <http://www.kitware.com/company/team/chaudhary.html>*
>>
>
>
>
> --
>
>
>
> *| Aashish Chaudhary | Technical Leader         | Kitware Inc.            *
> *| http://www.kitware.com/company/team/chaudhary.html
> <http://www.kitware.com/company/team/chaudhary.html>*
>



-- 
------------------------------------------------------------------
Simon Esneault
Rennes, France
------------------------------------------------------------------
cmake_minimum_required( VERSION 2.8.5 FATAL_ERROR )

project( VolumeRenderingBenchmark )

find_package( VTK REQUIRED )
include( ${VTK_USE_FILE} )

if( VTK_RENDERING_BACKEND STREQUAL "OpenGL2" )
        message( STATUS "Using new OpenGL2 backend" )
        add_definitions( -DVTK_WAS_BUILT_WITH_OPENGL2 )
else()
        message( STATUS "Using old OpenGL1 backend" )
endif()

add_executable( VolumeRenderingBenchmark MACOSX_BUNDLE 
VolumeRenderingBenchmark.cxx )
target_link_libraries( VolumeRenderingBenchmark ${VTK_LIBRARIES} )

#include "vtkCallbackCommand.h"
#include "vtkCamera.h"
#include "vtkColorTransferFunction.h"
#include "vtkGPUVolumeRaycastMapper.h"
#include "vtkImageData.h"
#include "vtkImageResample.h"
#include "vtkInteractorStyle.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkMath.h"
#include "vtkMetaImageReader.h"
#include "vtkPiecewiseFunction.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkTextActor.h"
#include "vtkTextProperty.h"
#include "vtkVolume.h"
#include "vtkVolumeProperty.h"

#include <numeric>
#include <sstream>


// Helper class for the FPS callback
class vtkFPSCallback : public vtkCommand{
protected:
        vtkTextActor* m_fps_text_actor;
        std::vector<double> m_vec_fps;
        std::vector<double> m_vec_total_fps;
        double m_fps;

public:
        static vtkFPSCallback *New(){ return new vtkFPSCallback; }
        vtkFPSCallback() : m_fps( 0. ){}

        void SetTextActor( vtkTextActor* a_actor ){ m_fps_text_actor = a_actor; 
}
        void Execute( vtkObject* a_caller, unsigned long vtkNotUsed( a_event ), 
void *a_call_data ){
                vtkRenderer* l_renderer = static_cast<vtkRenderer*>( a_caller );

                double l_time = l_renderer->GetLastRenderTimeInSeconds();
                double l_fps = static_cast<int>( 1.0 / l_time );

                m_vec_fps.push_back( l_fps );
                m_vec_total_fps.push_back( l_fps );
                if( m_vec_fps.size() == 10 ){
                        // compute mean
                        m_fps = std::accumulate( m_vec_fps.begin(), 
m_vec_fps.end(), 0. ) / 10.;
                        // manual round
                        m_fps = (double)( (int)( m_fps*100. ) ) / 100.;
                        m_vec_fps.clear();
                }

                std::ostringstream l_oss;
#ifdef VTK_WAS_BUILT_WITH_OPENGL2
                l_oss << "OpenGL2 : ";
#else
                l_oss << "OpenGL1 : ";
#endif
                l_oss << m_fps;
                l_oss << " FPS";

                m_fps_text_actor->SetInput( l_oss.str().c_str() );
        }

        double getMeanFPS(){
                return std::accumulate( m_vec_total_fps.begin(), 
m_vec_total_fps.end(), 0. ) / m_vec_total_fps.size();
        }
};


int main( int argc, char *argv[] ){

        // Read volume
        vtkMetaImageReader* l_reader = vtkMetaImageReader::New();
        l_reader->SetFileName( "volume.mhd" );
        l_reader->Update();

        // reduce to 80 Megavoxels
        double l_nb_voxels = l_reader->GetOutput()->GetNumberOfPoints();
        double l_target = 80000000;
        double l_ratio = std::pow( l_target / l_nb_voxels, 1. / 3. );
        vtkImageResample* l_resample = vtkImageResample::New();
        l_resample->SetInputConnection( l_reader->GetOutputPort() );
        l_resample->SetInterpolationModeToLinear();
        for( int i = 0; i < 3; i++ )
                l_resample->SetAxisMagnificationFactor( i, l_ratio );

        // Setup rendering stuff
        vtkRenderer* l_renderer = vtkRenderer::New();
        l_renderer->SetBackground( 0.3, 0.3, 0.3 );

        vtkRenderWindow* l_render_windows = vtkRenderWindow::New();
        l_render_windows->AddRenderer( l_renderer );
        l_render_windows->SetSize( 900, 900 );

        vtkInteractorStyleTrackballCamera* l_trackball = 
vtkInteractorStyleTrackballCamera::New();

        vtkRenderWindowInteractor* l_iren = vtkRenderWindowInteractor::New();
        l_iren->SetInteractorStyle( l_trackball );
        l_iren->SetRenderWindow( l_render_windows );
        l_iren->GetInteractorStyle()->SetDefaultRenderer( l_renderer );
        l_iren->SetDesiredUpdateRate( 25 );

        // Make sure we have an opengl context
        l_render_windows->Render();

        // Setup GPU volume raycast mapper
        vtkGPUVolumeRayCastMapper* l_gpu_mapper = 
vtkGPUVolumeRayCastMapper::New();
        l_gpu_mapper->SetMaxMemoryInBytes( std::pow( 1024, 3 ) );
        l_gpu_mapper->SetMaximumImageSampleDistance( 2. );
        l_gpu_mapper->SetInputConnection( l_resample->GetOutputPort() );

        // Setup Volume property
        // Window/Level
        double wl = 260;
        double ww = 270;

        // Color function
        vtkColorTransferFunction* l_color = vtkColorTransferFunction::New();
        l_color->SetColorSpaceToRGB();
        l_color->AddRGBPoint( wl - ww / 2, 0, 0, 0 );
        l_color->AddRGBPoint( wl - ww / 2 + 94 * ( ww / 255.0 ), 1., 21. / 
255.0, 27. / 255.0 );
        l_color->AddRGBPoint( wl - ww / 2 + 147 * ( ww / 255.0 ), 1., 176. / 
255.0, 9. / 255.0 );
        l_color->AddRGBPoint( wl - ww / 2 + 201 * ( ww / 255.0 ), 1., 241. / 
255.0, 39. / 255.0 );
        l_color->AddRGBPoint( wl - ww / 2 + 255 * ( ww / 255.0 ), 1, 1, 1. );
        l_color->Build();

        // Opacity function
        vtkPiecewiseFunction* l_opacity = vtkPiecewiseFunction::New();
        l_opacity->AddPoint( wl - ww / 2, 0 );
        l_opacity->AddPoint( wl + ww / 2, 1 );

        // Volume property, light, shading
        vtkVolumeProperty* l_volume_property = vtkVolumeProperty::New();
        l_volume_property->SetColor( l_color );
        l_volume_property->SetScalarOpacity( l_opacity );
        l_volume_property->SetInterpolationTypeToLinear();
        l_volume_property->ShadeOn();
        l_volume_property->SetAmbient( 0.15 );
        l_volume_property->SetDiffuse( 0.8 );
        l_volume_property->SetSpecular( 0.25 );
        l_volume_property->SetSpecularPower( 40 );

        // Put everything together
        vtkVolume* l_volume = vtkVolume::New();
        l_volume->SetProperty( l_volume_property );
        l_volume->SetMapper( l_gpu_mapper );

        // setup text actor :
        vtkTextActor* l_text_actor = vtkTextActor::New();
        
l_text_actor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
        l_text_actor->GetPositionCoordinate()->SetValue( 0.01, 0.99 );
        l_text_actor->GetTextProperty()->SetJustificationToLeft();
        l_text_actor->GetTextProperty()->SetVerticalJustificationToTop();
        l_text_actor->GetTextProperty()->SetFontSize( 17 );
#ifdef VTK_WAS_BUILT_WITH_OPENGL2
        l_text_actor->SetInput( "OpenGL2 : 0 FPS" );
#else
        l_text_actor->SetInput( "OpenGL1 : 0 FPS" );
#endif
        l_renderer->AddActor( l_text_actor );

        // setup fps callback
        vtkFPSCallback* l_callback = vtkFPSCallback::New();
        l_callback->SetTextActor( l_text_actor );
        l_renderer->AddObserver( vtkCommand::EndEvent, l_callback );
        l_renderer->AddVolume( l_volume );
        // Adjust camera position
        l_renderer->GetActiveCamera()->SetParallelProjection( false );
        l_renderer->GetActiveCamera()->SetViewUp( 0, 0, 1 );
        double l_distance = 1000;
        double l_center[ 3 ], l_pos[3];
        l_reader->GetOutput()->GetCenter( l_center );
        l_reader->GetOutput()->GetCenter( l_pos );
        l_pos[ 1 ] -= l_distance;
        double l_cam_angle = atan( ( l_center[ 2 ] * 2. ) / ( l_distance * 2. ) 
) * 360.0 / vtkMath::Pi();
        l_renderer->GetActiveCamera()->SetFocalPoint( l_center );
        l_renderer->GetActiveCamera()->SetPosition( l_pos );
        l_renderer->GetActiveCamera()->SetViewAngle( l_cam_angle + 1 );
        l_renderer->GetActiveCamera()->SetClippingRange( 0.01, 10000 );

        // Go rendering !
        l_iren->Start();

        std::cout << l_callback->getMeanFPS() << std::endl;

        // Memory cleanup
        l_reader->Delete();
        l_resample->Delete();
        l_renderer->Delete();
        l_render_windows->Delete();
        l_trackball->Delete();
        l_iren->Delete();
        l_gpu_mapper->Delete();
        l_color->Delete();
        l_opacity->Delete();
        l_volume_property->Delete();
        l_volume->Delete();
        l_text_actor->Delete();
        l_callback->Delete();
}
Benchmark results with MaximumImageSample set to 2.0

Windows 7 | Xeon E3-1220 | 16GB RAM | Nvidia Quadro K420 
- OGL1: 25.29 FPS
- OGL2: 12.36 FPS

Windows 7 | Xeon X5690   | 48GB RAM | NVidia Quadro K620
- OGL1: 26.46 FPS
- OGL2: 29.50 FPS  
_______________________________________________
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 ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to