Multivolume : Shading is not working

Hi everyone,

I am trying to use a vtkMultivolume with a vtkGPUVolumeRayCastMapper in 8.2 in c++ and I found something weird.

When there is only on port used in the mapper and also one port used in the vtkMultivolume I can see that a shader is computed, I can see shadows. The volume is thus “well” displayed.
However, when I add more volumes there is no more shader and the result is obviously bad.

I also found a note in TestGPURayCastMultiVolumeOverlapping.cxx saying :
" // Note: Shading is currently not supported with multi-volume active
//->ShadeOn();"

Do you have any idea if I can apply a shader by my own or if there is a way to active the shader even if there are multiple volumes displayed ?
I’m also wondering if it’s because of the mapper or because of the multivolume.

You can see an example here : (1) Only 1 volume. (2) Two volumes but I hid one to have the same view.

image (1)
image (2)

Thanks for your help.
Regards,
CNA

As far as I know, developers ran out of time/funding before they could complete implementation of shading in the multi-volume mapper, but it should not be too difficult to do it.

Would you have time and expertise (or funding) to contribute to the development?

Hi Lassoan, Thank you for your answer.

I might be able to work on this implementation but I’ll need some help. Do you have any idea how I can start and what I should do in general.

I don’t know the details well enough but @ken-martin, @sankhesh, or @Simon should be able to help you to get started.

If you know something about GLSL shaders, I think it shouldn’t be too difficult to fix the problem.

vtkOpenGLGPURaycastMapper compiles a fragment shader program that computes the ray integration for each pixel to render. The code of this shader program is modified and recompiled when you change the parameters of the mapper (vtkOpenGLGPUVolumeRayCastMapper::BuildShader()).

When assembling the different shader program parts, the mapper has a different behavior for the single volume and the multi volume cases (see this line and below). The multiple volume case doesn’t even try to take into account shading. So, basically, you need to find a way to either merge vtkvolume::ShadingMultipleInputs() and vtkvolume::ShadingSingleInput() into a single function that handles all cases or bring the functionality of vtkvolume::ShadingSingleInput() to the multi-volume function.

To help with the development, you can set a path with vtkShaderProgram::SetFileNamePrefixForDebugging (const char *), which will output the shader program to the file once assembled.

Let me know if you have more questions.

1 Like

Hi @Simon

Thank you for this explanation. I’m starting to work on it and I want to output the shader of the “ShadingSingleInput” to compare the shader i’m actually coding for each volume of the MultiVolume. (I assume that it should be close to the one compute on a single volume).
However i’m struggling at using this function " vtkShaderProgram::SetFileNamePrefixForDebugging (const char *)"
Would you like to help me on this ?

Thank you

CNA.

Can you be a little more specific about your difficulty with vtkShaderProgram? I just found out @cpinter is also interested in fixing this shading problem. You might want to coordinate.

1 Like