How to use VTK to realize volume rendering in the application based on OpenSceneGraph

I’m a beginner of VTK. My 3D application is based on OpenSceneGraph(OSG). Now I want to add volume rendering into the application so that it can convert CT/MRI images to 3D scene. But the volume rendering of OSG is too simple with poor efficiency. I want to use VTK to realize volume rendering. But it’s impossible to change the whole rendering engine from OSG to VTK. So what I’m asking really if anybody has any advice, for example, changing volume rendering data of VTK to my OSG scene so that volume data and triangle mesh data can be rendered in the same scene(window), or other suggestion. It would be really appreciated, thanks!

Hello, it’ll be quite tricky. The first challenge to overcome is to make VTK render to an OSG viewport. A starting point is to google vtkActorToOSG. There are a few source code repositories out there using that bridging class that someone wrote years ago.

Alternativelly, assuming the backend is OpenGL, you can avoid the trouble of converting vtkActors to OSG objects if you manage to pass OSG’s OpenGL context to VTK so it can render there. I’d take a look at the vtkExternalOpenGLRenderWindow class, which is designed so VTK doesn’t create a new OpenGL context.

1 Like

Thanks! I have decided to use VTK for rendering engine instead of OSG. Maybe it will take a long time. But I think it will be worthing!

Well, welcome to the VTK community. I suggest you to read the VTK primer, which is available on-line (not pirate! :wink: ). Also, there is an overwhelming ammount of code examples, posts and open source repositories out there. I also suggest you to try the basic examples to get the hang of it. The community has recently made a decent work making a new hub for learning VTK.

1 Like

I’m so grateful to choose VTK and the development of the application is going well. I have refactored the code of rendering with VTK. Though VTK is hard to handle well for me, but it is worthing. The on-line primer, examples and the community you suggest is very useful. Thank you! :grinning:

You’re welcome, Harrison. :slightly_smiling_face: VTK is a pipeline-oriented API, which has a learning curve longer than scene graph-oriented ones. But it really pays in the long run, as doing things in parallel and scaling things up is easier with pipelines.

1 Like