Create Holographic Scenes Using VTK Python

March 11, 2021

Use VTK 9.0 to quickly and easily write a Python script to create your own 3D scene and visualize it on a Looking Glass holographic display!

Kitware has partnered with Looking Glass Factory to bring the power of VTK to their innovative holographic displays. This partnership enables you to see your data in 3D without the need for special glasses or headgear! Furthermore, with VTK 9.0, creating custom scenes and rendering them onto a Looking Glass holographic display can be accomplished in Python, with only a few lines of code!

Here is an example of VTK Python code for rendering text and a cone onto a holographic display, as shown in the video.

import vtk

# Declare a VTK rendering process
ren = vtk.vtkRenderer()

# Use the following line to render to a standard display:
#   renWin = vtk.vtkRenderWindow()
# Use the following line to render to a Looking Glass display:  
renWin = vtk.vtkLookingGlassInterface.CreateLookingGlassRenderWindow()

# Add the rendering process to the window

# The mouse controls the position of the camera
iren = vtk.vtkRenderWindowInteractor()

# Add some text to the display
text = vtk.vtkVectorText()
text.SetText("Hello VTK!")
textMapper = vtk.vtkPolyDataMapper()
textActor = vtk.vtkActor()

# Position a cone above the text
cone = vtk.vtkConeSource()
coneMapper = vtk.vtkPolyDataMapper()
coneActor = vtk.vtkActor()

# Initialize the window

# The mouse controls the camera until "q" is pressed to exit

This code is also available as a Python Jupyter Notebook on Github.

To use this Python code with VTK 9.0, you will need to compiled VTK with the “VTK_WRAP_PYTHON” and the “VTK_MODULE_ENABLE_VTK_RenderingLookingGlass” modules enabled during CMake configuration. Future versions of VTK will provide a pip installable version of VTK with the Looking Glass module already enabled.

Beyond Python: if you are looking to visualize your data on a Looking Glass display without having to write any code, ParaView or 3D Slicer may be exactly what you need. Otherwise, you can contact us at to have us create a custom solution for you.

Leave a Reply