I do volume rendering of conebeam CT image using VTK. The result image is different from slicer with the same classification curve. The vtk rendering looks more like CPU Rendering, less shading effect.
I use qt6.7 and vtk9.4.2 with QMainwindow and QVTKRenderWindowInteractor as central widget.
vtk.volume with mapper of vtkGPUVolumeRaycastMapper
The shading looks nearly identical to me. The differences I see are:
camera: the view on the left is from the back, the view on the right is from the front
coloring: the rendering on the left has color, the one on the right is grayscale
There are a large number of property settings that control the coloring and shading.
property.SetColor(<color transfer function>)
property.SetScalarOpacity(<opacity transfer function>)
property.SetGradientOpacity(<gradient opacity transfer function>)
property.ShadeOn()/Off()
property.SetAmbient(<value between 0 and 1>)
property.SetDiffuse(<value between 0 and 1>)
property.SetSpecular(<value between 0 and 1>)
Whether the mapper uses the GPU or the CPU does not have much impact on the shading. GPU vs CPU mainly impacts the rendering speed.
Edit: most of the property settings have reasonable defaults, so usually only the following are needed for a shaded volume:
property.SetColor(<color transfer function>)
property.SetScalarOpacity(<opacity transfer function>)
property.ShadeOn()
Thanks David,
I used all the same properties except the color transfer function.
Slicer rendered images looks more reflecting the light.
Please look into the condyle area. Light penetrating more on VTK rendered image.
@Chris_Young_Kim note too that the Slicer code is fully available to inspection (and run–time introspection) so there’s no reason you can’t find the exact settings used in Slicer and replicate them in other VTK context. It would be great if you could report back the “minimum viable code” to make volume renderings look the way you want. It would be a nice contribution to the community if you could provide examples of what works for you in the end.
BTW, if you learn how to do additional interesting volume rendering effects we’d all love to learn what works for you.