Skip to content

A plugin that downloads, builds, installs and links VTK to UE.

License

Notifications You must be signed in to change notification settings

VRGroupRWTH/VTKPlugin

Repository files navigation

VTK Plugin for Unreal Engine 5+

A plugin that links the VTK Library to Unreal Engine 5.3.

Currently, this plugin does the following:

  • Download & build VTK (infer/change the version in the install script file)
  • Expose VTK to your complete Unreal project (public, but you may want this private)
  • Provide a blueprint function "DistanceBetweenTwoPoints" for testing vtkMath.h (based on an official VTK example, cross-compatible)
  • Provide a blueprint function "ReadStructuredGridTest" for more complex vtk includes (loosely based on an official VTK example
  • ✔️ Complete cross-compatibility for Windows/Linux/Mac (tested)

This plugin is quite verbose as it aims to be a foundation for implementing & testing VTK functionality in UE. Check the Unreal Log for [VtkPlugin] to see what's happening (also valid for the blueprint functions).

⚠️ Remarks on Windows

  • Delay-loading (which would be better practice) is currently disabled and all VTK dlls are instantly loaded.
    • This prevents module reloading.

⚠️ Remarks on Linux/Mac

  • Cross-compatibility only through an RTTI enabled Wrapper module (VtkWrapper)
    • Using PImpl pattern
    • UE on Unix is per default compiled without RTTI and will clash with RTTI-functionality used in some VTK includes (also discussed here)
    • Wrapper modules also employed by Unreal, e.g., in the OpenExrWrapper (see here)

Installation

Automated Installation

You can use the [*.bat|*.sh|*.command] installation scripts to download and build VTK for UE automatically.

By default it will do a Release build, but you can tell it to do a Debug build by starting it with Debug as a parameter.
If you do a Debug build, don't delete your build folder (./Temporary) at the end of the script. The *.dll files store the path to its debug symbols which remain there.

# Release build
.\install_vtk_windows.bat

# Debug build (do not delete build folder at the end)
.\install_vtk_windows.bat debug

Manual Installation

Alternatively, download & build the VTK library yourself and copy the files to the correct locations:

  • Copy the includes to VtkPlugin/Source/ThirdParty/VtkLibrary/Public
  • Windows
    • Copy *.lib files to VtkPlugin/Source/ThirdParty/VtkLibrary/[Release|Debug]/lib folder
    • Copy *.dll files to VtkPlugin/Source/ThirdParty/VtkLibrary/[Release|Debug]/bin folder
  • Linux
    • Copy *.so files to VtkPlugin/Source/ThirdParty/VtkLibrary/Linux/[Release|Debug]/lib folder
  • Mac
    • Copy *.dylib files to VtkPlugin/Source/ThirdParty/VtkLibrary/Mac/[Release|Debug]/lib folder

Prerequisites:

Troubleshooting

For test data have a look at the VTKData repository (files here are referenced in the official VTK examples): https://github.com/open-cv/VTKData

If there are linking errors with the VTK library, have a look in the Source/ThirdParty/VtkLibrary folder:

  • Check if your VTK binaries are in the correct folder
  • Check if your VTK includes are present
  • Check if VtkLibrary.Build.cs correctly finds your VTK includes & binaries

If the necessary VTK binaries don't exist, they may have not been built. Check which VTK module is missing and enable it explicitly in your build configuration for VTK.

  • If you used our installation script: Add -DVTK_MODULE_ENABLE_VTK_<module_name>=WANT to the cmake call
  • If you build yourself with the commandline: Same as above
  • If you build yourself using the CMake GUI: Check the Advanced box, then you can search for the missing module name