Ray Tracing in VTK - Capabilities in surface and volume Rendering - Own Implementation

Hello All,

I am new to the community and have only recently started reading up on vtk and need support on the possibilities of this great library.

Namely, I want to develop my own ray tracer in Python using the vtk library. As I understood it according to the following post, the own implementation of a ray tracer is relatively easy possible without creating new classes, provided that the data (assuming medical CBCT data) has already been converted to a surface model with e.g. vtkMarchingCubes From Ray Casting to Ray Tracing with Python and VTK | PyScience (wordpress.com) One advantage of this approach is yes, that one can very easily perform cut tests with the OBBTree class. However, a disadvantage is that if you want to represent different tissue types, such as bone and soft tissue with different material properties, you should first segment each tissue type of a dataset and define its own material property. (As far as I understood :slight_smile:)

Furthermore, both researches didn’t show me that this possibility to use existing vtk classes can also be used for the implementation of an own ray-tracing volume rendering algorithm. For this I only found that you have to create your own derivation of the class vtkVolumeMappers, in which you can then integrate the functions. Is this also possible in Python? And to what extent can I merge the functions of other libraries, like pyoptix with the vtk functionalities to achieve my goals? Or in the same way with paraview?

Thank you very much in advance and I appreciate any answer!

Best regards David

Many questions at once. Do you want to implement your own ray tracer or would it be sufficent to play around with an open-source ray tracer? Have you looked into vtkOSPRay? To see how things fit into the VTK framework, I believe it is a good place to start.

I thank you for the quick reply. exactly, I want to write my own RayTracing algorithm on volume data. I also read something about vtkRenderPass? Could you implement your own renderer using this interface?
I left it at vtkOSPRay just the name for now without reading further.

Thank you very much !!!

Hi @DMelenberg, I suggest looking at how the current implementation of the volume mapper is written. The main code is in OpenGL shaders composed by a header file called "vtkVolumeShaderComposer. The composer is used by vtkOpenGLGPUVolumeRayCastMapper` to dynamically create the vertex and fragment shaders that cast rays through the volume. If there are certain improvements you’d like to make, then there is the ability to replace parts of the shader code with your own.

Understanding how the current volume mapping is done should hopefully help you figure out your next steps. As suggested, Intel OSPRay’s integration in VTK should also give you more ideas.