[vtkusers] vtkVolumeTextureMapper3D in VTK 7.1?

Simon ESNEAULT simon.esneault at gmail.com
Wed Mar 8 08:30:25 EST 2017


Same here, for the still rendering I use the minimal spacing value in all 3
directions divided by 2 (something to respect Shannon theorem but I'm not
sure if it's relevant here ...)
During interaction I ended up hacking
vtkOpenGLGPUVolumeRayCastMapper::ComputeReductionFactor() method to compute
a sampling distance that really honor the wanted FPS. That make it easier
to ensure a target FPS

Here is the diff from VTK 7.1 release

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- C:/VTK-7.1.0/Rendering/VolumeOpenGL2/vtkOpenGLGPUVolumeRayCastMapper.cxx
Mon
Nov 14 19:58:01 2016
+++ C:/VTK-7.1.0/Rendering/VolumeOpenGL2/vtkOpenGLGPUVolumeRayCastMapper.cxx
Wed
Mar 08 14:21:13 2017
@@ -2116,26 +2116,9 @@
   else
   {
     input->GetSpacing(this->CellSpacing);
-    vtkMatrix4x4* worldToDataset = vol->GetMatrix();
-    double minWorldSpacing = VTK_DOUBLE_MAX;
-    int i = 0;
-    while (i < 3)
-    {
-      double tmp = worldToDataset->GetElement(0,i);
-      double tmp2 = tmp * tmp;
-      tmp = worldToDataset->GetElement(1,i);
-      tmp2 += tmp * tmp;
-      tmp = worldToDataset->GetElement(2,i);
-      tmp2 += tmp * tmp;
-
-      // We use fabs() in case the spacing is negative.
-      double worldSpacing = fabs(this->CellSpacing[i] * sqrt(tmp2));
-      if(worldSpacing < minWorldSpacing)
-      {
-        minWorldSpacing = worldSpacing;
-      }
-      ++i;
-    }
+     // Approximate Shannon -> half the miniaml spacing
+    double minWorldSpacing = std::min(std::min(this->CellSpacing[0],
+                             this->CellSpacing[1]),this->CellSpacing[1]) /
2.;

     // minWorldSpacing is the optimal sample distance in world space.
     // To go faster (reduceFactor<1.0), we multiply this distance
@@ -3113,7 +3096,6 @@

   if ( this->TimeToDraw )
   {
-    double oldFactor = this->ReductionFactor;

     double timeToDraw;
     if (allocatedTime < 1.0)
@@ -3137,30 +3119,17 @@
       timeToDraw = 10.0;
     }

-    double fullTime = timeToDraw / this->ReductionFactor;
-    double newFactor = allocatedTime / fullTime;
-
-    // Compute average factor
-    this->ReductionFactor = (newFactor + oldFactor)/2.0;
-
-    // Discretize reduction factor so that it doesn't cause
-    // visual artifacts when used to reduce the sample distance
-    this->ReductionFactor = (this->ReductionFactor > 1.0) ? 1.0 :
-                              (this->ReductionFactor);
-
-    if (this->ReductionFactor < 0.20)
+    if ( timeToDraw == BigTimeToDraw )
     {
-      this->ReductionFactor = 0.10;
+      this->ReductionFactor = 1;
     }
-    else if (this->ReductionFactor < 0.50)
-    {
-      this->ReductionFactor = 0.20;
-    }
-    else if (this->ReductionFactor < 1.0)
+    else
     {
-      this->ReductionFactor = 0.50;
+      double l_wanted_fps = 1. / ( allocatedTime * 3. );
+      double l_current_fps = 1. / timeToDraw;
+      this->ReductionFactor *= l_current_fps / l_wanted_fps;
+      this->ReductionFactor = vtkMath::Round( this->ReductionFactor * 50.
) / 50.;
     }
-
     // Clamp it
     if ( 1.0/this->ReductionFactor > this->MaximumImageSampleDistance )
     {
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Simon

2017-03-08 14:04 GMT+01:00 Elvis Stansvik <elvis.stansvik at orexplore.com>:

> 2017-03-08 11:16 GMT+01:00 Simon ESNEAULT <simon.esneault at gmail.com>:
> > Hello Alvaro,
> >
> > That's real good news to hear (about the down-sampling in X and Y), I
> find
> > it really difficult to tweak volume rendering only with sample distance,
> > especially during interaction.
> > Has the development began already ? Is there some branche where we can
> test
> > that feature ?
> >
> > Also in that case would it be possible to add a final "gaussian smoothing
> > pass" or equivalent only on the 2D generated image (maybe only as an
> option)
> > ? I look like it is the case with FixedPointVolumeraycastMapper, the
> image
> > looks a bit blurred but sometimes it helps to see the structures
>
> I'm also very interested in this. I'm using vtkGPUVolumeRayCastMapper,
> and I'm currently turning off the automatic adjustment of sample
> distance during interaction and resorted to doing my own simpler
> adjustment. I'm simply quadrupling the sample distance during
> interaction (for still rendering I use
> (spacingX+spacingY+spacingZ)/6). I'd love to have another quality
> controlling knob to turn.
>
> Is there a MR up for it already? Will it be in 7.2?
>
> Elvis
>
> >
> > Thanks
> > Simon
> >
> >
> > 2017-03-06 18:17 GMT+01:00 Alvaro Sanchez <alvaro.sanchez at kitware.com>:
> >>
> >> Hi Shark,
> >>
> >> unfortunately there is no current plan of porting
> vtkVolumeTextureMapper3D
> >> to OpenGL2
> >> , as far as I know.  We will soon however support image down sampling
> in X
> >> and Y which
> >> should serve as additional knobs to tweak the performance of
> >> GPURayCastMapper in
> >> OpenGL2 (only sample distance can be currently adjusted).
> >>
> >> Could you provide more detail on the size of the dataset you are
> rendering
> >> and your GPU
> >> specs?
> >>
> >> Thanks,
> >> Álvaro
> >>
> >> On Mon, Mar 6, 2017 at 10:30 AM, Shark <m.nunes at fratoria.com> wrote:
> >>>
> >>> Hello,
> >>>
> >>> I have been having some issues with vtkVolumeTextureMapper3D. I see it
> >>> has
> >>> been deprecated, however it is still available if I use the old openGL.
> >>>
> >>> Since for software rendering with texture mapping is much faster than
> ray
> >>> casting, I would like to know if you are planning to have a Volume
> >>> Texture
> >>> Mapper for openGL 2, or if there is actually a new one that I am not
> able
> >>> to
> >>> find.
> >>>
> >>> Best regards,
> >>> Shark
> >>>
> >>>
> >>>
> >>>
> >>> --
> >>> View this message in context:
> >>> http://vtk.1045678.n5.nabble.com/vtkVolumeTextureMapper3D-
> in-VTK-7-1-tp5742368.html
> >>> Sent from the VTK - Users mailing list archive at Nabble.com.
> >>> _______________________________________________
> >>> 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
> >>
> >>
> >>
> >>
> >> --
> >> Alvaro Sanchez
> >> Kitware, Inc.
> >> Senior R&D Engineer
> >> 21 Corporate Drive
> >> Clifton Park, NY 12065-8662
> >> Phone: 518-881-4901
> >>
> >> _______________________________________________
> >> 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
> >>
> >
> >
> >
> > --
> > ------------------------------------------------------------------
> > Simon Esneault
> > Rennes, France
> > ------------------------------------------------------------------
> >
> > _______________________________________________
> > 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
> >
>



-- 
------------------------------------------------------------------
Simon Esneault
Rennes, France
------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170308/5a42051e/attachment.html>


More information about the vtkusers mailing list