[vtk-developers] strange behaviour in vtkVolumeTextureMapper2D
Sebastien BARRE
barre at sic.sp2mi.univ-poitiers.fr
Thu Jul 13 08:08:56 EDT 2000
Hi
I'm not a Volume Rendering specialist, but I guess there might be a bug in
the vtkVolumeTextureMapper2D. I'm sure about that, that's the reason why
I'm asking before fixing it :)
I've been conducting some tests using my SGI 320 on both the VTK official
release 3.1.2, and the current CVS, and the CVS version has a buggy
behavior *on my computer* : the rendered model disappears from time to
time, then reappears, etc. It's quite disturbing because it prevents one
from viewing it correctly, and it also makes the interactions impossible :
if the model disappears during an interaction (rotation, zoom) the
interaction is not stopped but, as the model is rendered in 0 s., the
interaction is made at full speed and your object rotates thousands of
degrees in a second, or zoom 10000%, etc, and reappears wherever.
I'm not able to understand 100% of the code, but I tried to step back the
history, and it seems to me that this behavior comes from :
Revision : 1.19
Date : 2000/6/15 16:10:8
Author : 'avila'
State : 'Exp'
Lines : +357 -144
Description :
ENH: packed several textures into a bigger (user-controlled size)
texture to improve performance. Also fixed a bug (reported on the
users list) where size should have been size-1 for texture sizes.
more specifically, to the change made "where size should have been size-1
for texture sizes".
Here it is for example :
cvs -z9 -q diff -r 1.18 -r 1.19 vtkVolumeTextureMapper2D.cxx (in directory
E:\src\vtk\vtk-cvs\graphics\)
Index: vtkVolumeTextureMapper2D.cxx
===================================================================
RCS file: /vtk/cvsroot/vtk/graphics/vtkVolumeTextureMapper2D.cxx,v
retrieving revision 1.18
retrieving revision 1.19
diff -r1.18 -r1.19
111,133c165,194
< offset[0] = 0.5 / (float)tsize[0];
< offset[1] = 0.5 / (float)tsize[1];
< t[0] = offset[0];
< t[1] = offset[1];
< t[2] = offset[0];
< t[3] = ((float)size[2] / (float)tsize[1]) - offset[1];
< t[4] = ((float)size[1] / (float)tsize[0]) - offset[0];
< t[5] = ((float)size[2] / (float)tsize[1]) - offset[1];
< t[6] = ((float)size[1] / (float)tsize[0]) - offset[0];
< t[7] = offset[1];
<
< v[1] = origin[1];
< v[2] = origin[2];
<
< v[4] = origin[1];
< v[5] = spacing[2] * size[2] + origin[2];
<
< v[7] = spacing[1] * size[1] + origin[1];
< v[8] = spacing[2] * size[2] + origin[2];
<
< v[10] = spacing[1] * size[1] + origin[1];
< v[11] = origin[2];
<
---
> offset[0] = 0.5 / (float)textureSize[0];
> offset[1] = 0.5 / (float)textureSize[1];
>
> for ( i = 0; i < numTiles; i++ )
> {
> yTile = i / xTotal;
> xTile = i % xTotal;
>
> t[i*8 + 0] = (float)((size[1]*(xTile )) )/(float)textureSize[0] +
offset[0];
> t[i*8 + 1] = (float)((size[2]*(yTile )) )/(float)textureSize[1] +
offset[1];
> t[i*8 + 2] = (float)((size[1]*(xTile )) )/(float)textureSize[0] +
offset[0];
> t[i*8 + 3] = (float)((size[2]*(yTile+1))-1)/(float)textureSize[1] -
offset[1];
> t[i*8 + 4] = (float)((size[1]*(xTile+1))-1)/(float)textureSize[0] -
offset[0];
> t[i*8 + 5] = (float)((size[2]*(yTile+1))-1)/(float)textureSize[1] -
offset[1];
> t[i*8 + 6] = (float)((size[1]*(xTile+1))-1)/(float)textureSize[0] -
offset[0];
> t[i*8 + 7] = (float)((size[2]*(yTile )) )/(float)textureSize[1] +
offset[1];
>
> v[i*12 + 1] = origin[1];
> v[i*12 + 2] = origin[2];
>
> v[i*12 + 4] = origin[1];
> v[i*12 + 5] = spacing[2] * (float)(size[2]-1) + origin[2];
>
> v[i*12 + 7] = spacing[1] * (float)(size[1]-1) + origin[1];
> v[i*12 + 8] = spacing[2] * (float)(size[2]-1) + origin[2];
>
> v[i*12 + 10] = spacing[1] * (float)(size[1]-1) + origin[1];
> v[i*12 + 11] = origin[2];
> }
>
If you remove the -1 for the (float)(size[x]-1), it works as expected. But
it might be a side-effect.
Here are my changes (well, more a hack than a change, sorry) :
cvs -z9 -q diff vtkVolumeTextureMapper2D.cxx (in directory
E:\src\vtk\vtk-cvs\graphics\)
Index: vtkVolumeTextureMapper2D.cxx
===================================================================
RCS file: /vtk/cvsroot/vtk/graphics/vtkVolumeTextureMapper2D.cxx,v
retrieving revision 1.21
diff -r1.21 vtkVolumeTextureMapper2D.cxx
186c186
< v[i*12 + 5] = spacing[2] * (float)(size[2]-1) + origin[2];
---
> v[i*12 + 5] = spacing[2] * (float)(size[2]) + origin[2];
188,189c188,189
< v[i*12 + 7] = spacing[1] * (float)(size[1]-1) + origin[1];
< v[i*12 + 8] = spacing[2] * (float)(size[2]-1) + origin[2];
---
> v[i*12 + 7] = spacing[1] * (float)(size[1]) + origin[1];
> v[i*12 + 8] = spacing[2] * (float)(size[2]) + origin[2];
191c191
< v[i*12 + 10] = spacing[1] * (float)(size[1]-1) + origin[1];
---
> v[i*12 + 10] = spacing[1] * (float)(size[1]) + origin[1];
536c536
< v[i*12 + 5] = spacing[2] * (float)(size[2]-1) + origin[2];
---
> v[i*12 + 5] = spacing[2] * (float)(size[2]) + origin[2];
538,539c538,539
< v[i*12 + 6] = spacing[0] * (float)(size[0]-1) + origin[0];
< v[i*12 + 8] = spacing[2] * (float)(size[2]-1) + origin[2];
---
> v[i*12 + 6] = spacing[0] * (float)(size[0]) + origin[0];
> v[i*12 + 8] = spacing[2] * (float)(size[2]) + origin[2];
541c541
< v[i*12 + 9] = spacing[0] * (float)(size[0]-1) + origin[0];
---
> v[i*12 + 9] = spacing[0] * (float)(size[0]) + origin[0];
885c885
< v[i*12 + 4] = spacing[1] * (float)(size[1]-1) + origin[1];
---
> v[i*12 + 4] = spacing[1] * (float)(size[1]) + origin[1];
887,888c887,888
< v[i*12 + 6] = spacing[0] * (float)(size[0]-1) + origin[0];
< v[i*12 + 7] = spacing[1] * (float)(size[1]-1) + origin[1];
---
> v[i*12 + 6] = spacing[0] * (float)(size[0]) + origin[0];
> v[i*12 + 7] = spacing[1] * (float)(size[1]) + origin[1];
890c890
< v[i*12 + 9] = spacing[0] * (float)(size[0]-1) + origin[0];
---
> v[i*12 + 9] = spacing[0] * (float)(size[0]) + origin[0];
*****CVS exited normally with code 1*****
As you understand, I'm not quite sure about what I'm doing, hence I'm
asking (Lisa ?), what was this -1 for, are you sure about that ?
Thanks
--
Sebastien BARRE
IRCOM-SIC, UMR-CNRS 6615 - Université de Poitiers
Bât. SP2MI, Bvd 3 - Téléport 2, BP 179 F-86960 Futuroscope Cedex
Tel. : +33 (0)5 49 49 65 92, Fax : +33 (0)5 49 49 65 70
http://www-sic.univ-poitiers.fr/barre/ ou http://www.hds.utc.fr/~barre/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20000713/e1c61697/attachment.html>
More information about the vtk-developers
mailing list