[vtk-developers] shift error in vtkVolumeTextureMapper2D

David Gobbi dgobbi at imaging.robarts.ca
Mon Jul 22 13:54:57 EDT 2002


On Thu, 18 Jul 2002, Lisa S. Avila wrote:

> Hi David,
>
> I think the "-1" values on lines 200 through 203 are the problem. My build
> at home does not include tcl - if it builds before I fall asleep I will try
> it out tonight otherwise I will fix it tomorrow.

I removed the '-1' from those lines and it fixed the problem.  Turns out I
had a bug in my own code as well, I always filter (blur) the copy of the
volume that goes to the vtkVolumeTextureMapper2D in order to reduce the
wood-grain artifact and I was also shifting the volume by accident.
I'll commit the fix.

There is also a back-to-front shift problem (though it isn't a really a
bug) that happens when a clipping plane is parrallel to the texture
planes.  It would be possible to fix it by putting the frontmost texture
at the same position of the clipping plane.  Or by using textures that
are at 45 degrees to volume's original axes, which is what I've seen with
some of SGI's volume rendering.

> Thanks for finding this - this once again points out the need to
> consolidate this type of code (problems with texture coordinates have been
> fixed in the past in vtkOpenGLImageActor, vtkOpenGLVolumeRayCastMapper,
> vtkOpenGLVolumePro500Mapper, and vtkOpenGLTexture).

Conversions between coordinate systems always have been and always will be
a major pain in the backside.  I agree that code consolidation would help.

 - David


> At 03:00 PM 7/18/2002, David Gobbi wrote:
> >Hi Lisa,
> >
> >The vtkVolumeTextureMapper2D seems to have a half-pixel
> >offset error in either the generation of the textures or
> >in the mapping of the textures to display.
> >
> >I've attached a tcl script that demonstrates the problem.
> >It volume-renders a sphere along with a wireframe sphere
> >of the same dimensions.  The ray-cast volume rendering
> >matches the wireframe surface perfectly, but the
> >texture-map volume rendering (when you interact with
> >the window) is definitely off.
> >
> >  - David
> >
> >--
> >   David Gobbi, MSc                dgobbi at imaging.robarts.ca
> >   Advanced Imaging Research Group
> >   Robarts Research Institute, University of Western Ontario
> >
> >=======================================================
> >package require vtk
> >
> >vtkImageEllipsoidSource reader
> >     reader SetOutputScalarTypeToUnsignedChar
> >     reader SetWholeExtent 0 31 0 31 0 31
> >     reader SetCenter 15.5 15.5 15.5
> >     reader SetRadius 14 14 14
> >     reader SetInValue 200
> >     reader SetOutValue 0
> >
> >     reader UpdateWholeExtent
> >     [reader GetOutput] SetOrigin -15.5 -15.5 -15.5
> >     [reader GetOutput] SetSpacing 1 1 1
> >
> >vtkImageGaussianSmooth blur
> >     blur SetInput [reader GetOutput]
> >     blur SetStandardDeviation 1.5
> >     blur SetRadiusFactor 3
> >     blur UpdateWholeExtent
> >
> ># Create transfer functions for opacity and color
> >vtkPiecewiseFunction opacityTransferFunction
> >     opacityTransferFunction AddPoint    0   0.0
> >     opacityTransferFunction AddPoint   95   0.0
> >     opacityTransferFunction AddPoint  105   1.0
> >     opacityTransferFunction AddPoint  255   1.0
> >
> >vtkColorTransferFunction colorTransferFunction
> >     colorTransferFunction SetColorSpaceToRGB
> >     colorTransferFunction AddHSVPoint      0.0 0.01 1.0 1.0
> >     colorTransferFunction AddHSVPoint    127.5 0.50 1.0 1.0
> >     colorTransferFunction AddHSVPoint    255.0 0.99 1.0 1.0
> >     colorTransferFunction SetColorSpaceToHSV
> >
> ># Create properties, mappers, volume actors, and ray cast function
> >vtkVolumeProperty volumeProperty
> >     volumeProperty SetColor colorTransferFunction
> >     volumeProperty SetScalarOpacity opacityTransferFunction
> >     volumeProperty SetInterpolationTypeToLinear
> >
> >vtkVolumeRayCastCompositeFunction  compositeFunction
> >
> >vtkVolumeRayCastMapper volumeMapper
> >     volumeMapper SetInput [blur GetOutput]
> >     volumeMapper SetVolumeRayCastFunction compositeFunction
> >
> >vtkVolumeTextureMapper2D volumeTexMapper
> >     volumeTexMapper SetInput [blur GetOutput]
> >     volumeTexMapper SetTargetTextureSize 32 32
> >     volumeTexMapper SetMaximumNumberOfPlanes 32
> >
> >vtkLODProp3D volume
> >     volume AddLOD volumeMapper volumeProperty 0.2
> >     volume AddLOD volumeTexMapper volumeProperty 0.05
> >
> ># Create geometric sphere
> >vtkSphereSource sphereSource
> >     sphereSource SetCenter  0 0 0
> >     sphereSource SetRadius  14
> >     sphereSource SetThetaResolution 15
> >     sphereSource SetPhiResolution 15
> >
> >vtkPolyDataMapper sphereMapper
> >     sphereMapper SetInput [sphereSource GetOutput]
> >
> >vtkActor sphereActor
> >     sphereActor SetMapper sphereMapper
> >     [sphereActor GetProperty] SetRepresentationToWireframe
> >
> ># Okay now the graphics stuff
> >vtkRenderer ren1
> >vtkRenderWindow renWin
> >     renWin AddRenderer ren1
> >     renWin SetSize 256 256
> >vtkRenderWindowInteractor iren
> >     iren SetRenderWindow renWin
> >
> >[ren1 GetCullers] InitTraversal
> >set culler [[ren1 GetCullers] GetNextItem]
> >$culler SetSortingStyleToBackToFront
> >
> >ren1 AddProp sphereActor
> >ren1 AddProp volume
> >ren1 SetBackground 0.1 0.2 0.4
> >renWin Render
> >
> >wm withdraw .
> >
> >iren Initialize
>
>




More information about the vtk-developers mailing list