[vtkusers] vtkMultiVolume, vtkOpenGLGPUVolumeRayCastMapper - How to use vtkVolume->GetProperty()->SetScalarOpacity( vtkPiecewiseFunction ) correctly?

Angelika Ophagen ophagen at dornheim-medical-images.de
Thu Oct 25 14:36:45 EDT 2018


Hello,

I am trying to use vtkMultiVolume for a rather large application for 3D medical image data to meld multiple data - as my bachelor thesis project. I have based my code on commit https://gitlab.kitware.com/vtk/vtk/commit/9db353bb72c5567c4b75573b79517ec090d8df02 of the VTK and on branch nightly-master.
I need color transfer functions, scalar opacity functions and image data separately for each volume. I cannot get the scalar opacity to do what I want, somehow. Even in a very small example*, alpha is 1 all over the volume in the end. Gradient opacity, which I do not need, afaik, will result in alpha values smaller 1.

I have debugged the shader source code right before they are given to openGL, I have stepped through the vtlVolumeInputHelper and vtkTextureObject and vtkOpenGLVolumeOpacityTable and checked the values of the actual float-Array and - kind of** - found my expected values in there until just before they were given to openGL. From all I have seen, there should be semi-transparent parts to my generated cuboids. I have not altered bias or scale of any volume or the multivolume and presume them to be 0 and 1 respectively.

I temporarily changed the fragment shader template to try and output the LUT values (for the 1st volume) instead of the image values***. The whole "volume" in my render window was opaque white. That was the trick I am most unfamiliar with, so it might have just failed to do what I wanted.

Have I not used vtkMultiVolume and  vtkOpenGLGPUVolumeRayCastMapper in the way they are supposed to be used?
Please have a look at my small example code*. 

Regards,
A. Ophagen

-- 
Dipl.-Übers. A. Ophagen
Dornheim Medical Images GmbH
Listemannstraße 10, 39104 Magdeburg, Deutschland
WWW: http://www.dornheim-medical-images.de/
E-Mail: info at dornheim-medical-images.de
Tel: +49 (391) 5054 57 0
Geschäftsführer: Lars Dornheim, Jana Dornheim
Eingetragen beim Amtsgericht Stendal, HRB 10737


* See gist here: https://gist.github.com/AOphagen/f09d302320db67168dd9fe7316bd35e5
** I have found that the maximum image value is reduced from 127 to 63 in the process and that the LUT array has min value 0.3, but does not reach max value 0.8 in it's 1024 entries. It stops at about 0.54 - which still is not opaque at all - this should be unrelated.
*** Snippet from fragment shader template's void finalizeRayCast() + my code (commented out already):

g_fragColor.r = g_fragColor.r * in_scale + in_bias * g_fragColor.a;
g_fragColor.g = g_fragColor.g * in_scale + in_bias * g_fragColor.a;
g_fragColor.b = g_fragColor.b * in_scale + in_bias * g_fragColor.a;
gl_FragData[0] = g_fragColor;

//  gl_FragData[0].rgb = texture2D( in_opacityTransferFunc_0[0], vec2( gl_FragCoord.x, 0.0 ) ).rrr;
//  gl_FragData[0].a = 1.0; 





More information about the vtkusers mailing list