Requires Unreal Engine 5.0.3 or above
Supports Linux & Windows
This is the ultimate example with AOT Plugin integrated, which demonstrates SPH AOT runs in an UE5 project.
C++ class Source/SPHExample/SPH_Particles_Box
contains the major AOT implementation.
Taichi C-API were packaged into UE Plugin located at Plugins/AOTPlugin
SPH_AOT files were generated using:
git@github.com:taichi-dev/taichi-aot-demo.git
commit: d1a4842 [misc] Remove usage of deprecated kwarg in rw_texture type annotation (#111)
C-API library was generated using:
git@github.com:taichi-dev/taichi.git
commit: 2603e6695 [llvm] Unify the llvm context of host and device (#7249)
- Generate Taichi C-API library
- Have
-DTI_WITH_C_API=ON
in yourTAICHI_CMAKE_ARGS
- Add target backends to your
TAICHI_CMAKE_ARGS
,-DTI_WITH_CUDA=ON -DTI_WITH_LLVM=ON
suggested - Clone and compile Taichi following this guide: https://docs.taichi-lang.org/docs/dev_install
You'll find C-API library in: {TAICHI_REPO}/_skbuild/{OS_NAME}/cmake-install/c_api
- Update C-API library for UE project
TaichiAOTPlugin
- Replace
C_API_LINUX
orC_API_WINDOWS
underTaichiAOTPlugin/Plugins/AOTPlugin/Source/AOTPlugin/Public/
- Regenerate
taichi_unreal.hpp
if neccessary. (taichi_unreal.hpp
is generated fromtaichi.hpp
by replacing all function calls to C-API with a macroCALL_C_API_FUNC
, which wraps the original direct function calls withdlopen
&dlsym
. TODO: Automatically generatetaichi_unreal.hpp
fromtaichi.hpp
)
- Generate Taichi AOT Plugin
- UE interface:
Edit->Plugins->AOTPlugin->Package
- Import Plugin in your project
- Take SPHExample project as an example, put the generated
AOTPlugin
underSPHExample/Plugins/
- Generate SPH AOT files
- To avoid file mismatch, use the python-taichi you just compiled
- Generate SPH AOT files: https://github.com/taichi-dev/taichi-aot-demo/tree/master/5_sph/assets/sph.py
- Tutorials & examples: https://github.com/taichi-dev/taichi-aot-demo