vtkClipClosedSurface with RGBA

In vtk.js, I would like to cut through a surface and show it overlayed in a volume rendering but with RGBA. Something like below but in the sphere area, I want the underlying volume to get shown (since Sphere clipped surface has opacity <1) as well. The underlying volume is just composite blend.

Is it possible even? As far as know, the filters are on CPU, so it should be possible?
I checked the vtkClipClosedSurface API and didn’t see a place for Alpha.

I appreciate any insight on this problem or in general my use case (cutting through a surface and show it with RGBA overlayed).

Here is the demo I created in the code sandbox


If you need more control over the coloring, I suggest setScalarModeToLabels(). Then you can do the coloring with the mapper, by providing a lookup table for the mapper. The lookup table only needs 3 colors, since there will only be three unique label values.

For the mapper, in addition to setLookupTable(), you will also need useLookupTableScalarRangeOn() and you will have to set the range of the lookup table, e.g. table.setRange(0,3) for a table with 3 colors.

However, I suspect that compositing a translucent polydata with a volume rendering will not work. The volume ray-casting algorithm is only aware of the depth buffer from other rendered objects, it isn’t aware of the alpha of other rendered object. Or at least, that’s my understanding of how the algorithm works.

Thanks, I’m only interested in changing the opacity, but thanks for your insights on the color too.

Based on my research vtk C++ has a DualDepthPeeling than enables intermixing surfaces with volumes (?).

Is DualDepthPeeling a heavy algorithm to run in js and we can’t theoretically have a good rendering with it, or it is just not implemented yet?

I also saw @Forrest replied in another thread about an order independent algorithm. Is that related to this too?

Just to clear up any potential misunderstanding, the reason I mentioned vtkLookupTable is that its colors are RGBA, and therefore the lookup table provides a way to change the opacity of the faces.

Unfortunately I don’t know the answers to your questions about depth peeling in vtk.js.

Hmm, then I’m now confused. Can i use the vtkLookupTable method above to have alpha for a face so that the underlying image data (through volume rendering with composite blend) is visible?

Yes, the lookup table method will allow you to set the alpha for each face. Whether the rendering will work properly, I’m not sure.

Thanks David, I tried your suggestions.

I was looking into the vtkClipClosedSurface api and saw there is a generateOutline which I could mix with setLineWidth on actor’s property to generate a thicker line and set the faces to off which would address my use case for now. I guess your filter is faster than vtkCutter (which probably would do the same result) since it uses clipping planes?


but as expected by you the rendering does not work for intermixing volume and geometry, It basically doesn’t show anything at all even for opacity of 254. (In my code sandbox below you need to set generateFaces to True and change LUT opacity of faces (thirs item) to 254)

CC @ken-martin I’m more than happy to investigate and fix/add this if you can guide me on the approach. Does adding DualDepthPeeling solve this intermixing?

Thanks again for your time and help

I can’t say much about speed since I’ve never done a side-by-side comparison. But the internal algorithms are very different. vtkCutter is general purpose (any clip function, any cell type), while vtkClipClosedSurface is specialized (only clip planes, only polygons and triangle strips).