We hope these custom operators can be a starting point to developing for anybody including members of the community only beginning with c++ development.
A few basic examples can be found in the Samples/CPlusPlus folder of the TouchDesigner Installation. This repository contains more complex examples, some of which depend on more external libraries.
Tip: You can kick-start your custom operators projects by using the Cpp Pars Template Generator (cppParsTemplateGen) available in TouchDesigner's Palette to generate a Parameters class that will mimic the custom parameters of a reference COMP. For more informations, please visit the wiki.
- List of Operators
- Compiling Custom Operators
- Building with CMake
- Compiling OpenCV with CUDA support
- CUDA and NVIDIA hardware compatability
- Fixes for OpenCV or CUDA version updates
- Loading Custom Operators in TouchDesigner
- TOP Family
- CHOP Family
- SOP Family
- DAT Family
This text should be a small guide to getting started with compiling custom operators that can be found on github or elsewhere as pure source code. Often setting up your environment is the most difficult step followed by making accessible all libraries that might be necessary for successfully compiling other’s projects.
- Download the latest Visual Studio Community Edition from: https://visualstudio.microsoft.com/vs/community/
- Start the installation process
- In the Installer, select “Desktop Development with C++” and proceed with the installation process
All samples are built with CMake, a cross platform build system that generates Visual Studio solutions on Windows and Xcode projects (or Makefiles) on macOS from the same CMakeLists.txt files. CMake 4.4 or newer is required; check with cmake --version.
Visual Studio's “Desktop Development with C++” workload includes a copy of CMake, and Visual Studio can open any folder containing a CMakeLists.txt directly (File > Open > Folder). That copy may be older than CMake 4.4, in which case configuring stops with an error saying CMake 4.4 is required. Install the current release from https://cmake.org/download/ to use it from a terminal or the CMake GUI, or to generate a Visual Studio solution.
The easiest way to install CMake is via Brew. Once brew is installed and setup, you can install cmake by running:
% brew install cmakeFor some of the projects a CUDA Development environment is required. Which version much depends on the TouchDesigner version the operator is targeted at. Check https://docs.derivative.ca/CUDA for more information.
- Download the CUDA Toolkit from here: https://developer.nvidia.com/cuda-toolkit . Legacy versions of the CUDA Toolkit can be found here: https://developer.nvidia.com/cuda-toolkit-archive
- During installation choose “Custom” and be careful to only select the CUDA component. The other options will install most likely outdated driver components.
The toolkit's major version must match the CUDA version TouchDesigner uses, currently CUDA 12: the plugins link the shared CUDA runtime, and TouchDesigner only ships the runtime DLL for its own major version (cudart64_12.dll). Any 12.x toolkit works. CMake checks this when configuring and skips the CUDA samples, with a message, if the toolkit it finds is another major version.
CMake finds the CUDA 12 toolkit automatically, even if other CUDA versions are installed too: it picks the newest 12.x toolkit from the default install folder (C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.*) or from the CUDA_PATH_V12_* environment variables the installer sets, rather than the default toolkit (CUDA_PATH, which points at the last toolkit installed). The toolkit it chose is printed when you configure. To pick one yourself, pass -DCMAKE_CUDA_COMPILER="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8/bin/nvcc.exe", or with the Visual Studio generator, -T cuda=12.8, in a fresh build folder.
CUDA 12 doesn't support Visual Studio 2026, so build the CUDA samples with Visual Studio 2022: generate with -G "Visual Studio 17 2022", or use Ninja from a Visual Studio 2022 developer prompt. With the Visual Studio 2026 generator or compiler, CMake reports this and skips the CUDA samples (or stops, when configuring one of them on its own).
Samples that run ONNX AI models, such as ONNXCandyStyleTOP, use the ONNX Runtime C API.
- They require TouchDesigner 2025.32302 or later, installed via the Web Installer with the 'Public ONNX' installer option selected. This is due to a conflict with the
onnxruntime.dllversion that Kinect Azure requires. - They require ONNX Runtime version 1.23.2, for CUDA 12. Download it from the ONNX Runtime GitHub releases and unzip it into
C:/Program Files/onnxruntime, so that these folders exist with the.liband.hfiles:C:/Program Files/onnxruntime/libC:/Program Files/onnxruntime/include
- CMake looks for the ONNX Runtime headers and libraries in
C:/Program Files/onnxruntimeby default. To use another location, configure with-DONNXRUNTIME_ROOT=<path>. - Only the headers and
.libfiles are used to build. The.dllfiles from the download are not used: the plugin loads theonnxruntime.dllthat comes with TouchDesigner.
An operator that uses Python's C API is built against the Python that ships with TouchDesigner, so it matches the interpreter it's loaded into; add PYTHON to its td_add_custom_op() call (see Adding your own operator). No separate Python install is needed:
- Windows: TouchDesigner 2025 series builds bundle Python's headers in
<TD_INSTALLATION_PATH>/Samples/CPlusPlus/3rdParty/Python/IncludeandInclude/PC(wherepyconfig.his) and its import library (python3XX.lib) in<TD_INSTALLATION_PATH>/Samples/CPlusPlus/3rdParty/Python/lib/x64. - macOS: the headers come from
<TD_INSTALLATION_PATH>/Contents/Frameworks/Python.framework. The plugin isn't linked against a Python library; it uses the Python TouchDesigner has already loaded.
These samples require Python 3.11, the Python that the TouchDesigner builds they target ship; configuring stops with a message if the installation has another Python, which usually means TD_INSTALLATION_PATH points at a different TouchDesigner series. The required version is set by TD_PYTHON_VERSION and TD_PYTHON_FREE_THREADED in cmake/TouchDesignerCustomOP.cmake.
On Windows these operators always use the release C runtime, because the debug runtime would make Python's pyconfig.h switch to a debug build of Python. The Python version found is shown in the configure output, e.g. Adding CHOP sample: BasicGeneratorCHOP (Python 3.11 from TouchDesigner), and the folders it came from are filled in as TD_PYTHON_INCLUDE_DIR and TD_PYTHON_LIB_DIR (TD_PYTHON_FRAMEWORK_DIR on macOS) in the CMake cache. To build against another copy of the same Python, set those instead; see Building without a TouchDesigner installation.
Some projects make use of various OpenCV modules.
The samples are written for OpenCV 4 and are compiled against the OpenCV that ships with the TouchDesigner build you point CMake at, so the plugins use the same headers and libraries TouchDesigner loads. When configuring, CMake reads the OpenCV version from that install's opencv2/core/version.hpp and stops with a message if it isn't OpenCV 4.x. The version is shown next to each OpenCV sample in the configure output, e.g. Adding TOP sample: ContoursTOP (OpenCV 4.11.0 from TouchDesigner), and the folders it came from are filled in as TD_OPENCV_INCLUDE_DIR and TD_OPENCV_LIB_DIR in the CMake cache. To build against another copy of the same OpenCV, set those instead; see Building without a TouchDesigner installation.
These samples are for the TouchDesigner 2025 series. They find everything they use from TouchDesigner's installation through one CMake variable, TD_INSTALLATION_PATH, which points at the root of the install of the latest 2025 series build. If TouchDesigner is installed in its default location you don't need to set it:
- Windows: the install folder, default
C:/Program Files/Derivative/TouchDesigner - macOS: the application bundle, default
/Applications/TouchDesigner.app
cmake -S . -B build -DTD_INSTALLATION_PATH="D:/Apps/TouchDesigner.2025.31550"The installation path is printed when you configure.
Since TouchDesigner 2020.44130, OpenCV libraries are included in the TouchDesigner Install folder at Samples\CPlusPlus\3rdParty. CMake takes the headers and libraries from <TD_INSTALLATION_PATH>/Samples/CPlusPlus/3rdParty/opencv.
The library names carry the OpenCV version (e.g. opencv_core4110.lib for OpenCV 4.11.0). CMake links the libraries whose version matches the headers, so there is no need to edit library names when TouchDesigner updates OpenCV, and libraries left over from another version are never picked up.
Note: The OpenCV libraries shipped with TouchDesigner are "Release" binaries. To still allow Debug builds, samples linking TouchDesigner's OpenCV always use the release C runtime (/MD), in every configuration.
TouchDesigner also bundles OpenCV on macOS: CMake takes the headers from <TD_INSTALLATION_PATH>/Contents/Resources/tfs/Samples/CPlusPlus/3rdParty/opencv/include/opencv4 and the .dylibs matching their version (e.g. libopencv_core.4.11.0.dylib) from <TD_INSTALLATION_PATH>/Contents/Frameworks. The plugins are given an rpath to TouchDesigner's Frameworks folder, so they load the same OpenCV that TouchDesigner uses.
If TouchDesigner's OpenCV isn't found at all, CMake falls back to a regular install, e.g. brew install opencv, which must also be OpenCV 4.x. It doesn't fall back when TouchDesigner's OpenCV is there but is another major version or is missing a library, since the plugin would then not match the OpenCV TouchDesigner loads.
If you want to use a different OpenCV 4 release than the one that ships with TouchDesigner, or OpenCV is installed in a non-standard location, point CMake at the folder containing OpenCVConfig.cmake:
cmake -S . -B build -DTD_USE_BUNDLED_OPENCV=OFF -DOpenCV_DIR="C:/opencv/build"If you additionally need CUDA support, follow instructions below to compile OpenCV with CUDA support. Remember to place the OpenCV DLLs next to your plugin (see Loading Custom Operators).
Note: This is not necessary for compiling these operators - in fact TouchDesigner comes with all necessary binaries precompiled. We'll leave this guide here as the instructions were hard to find initialy.
Some other projects require the OpenCV windows libraries with CUDA modules included, yet as the available pre-built versions do not offer this support, OpenCV has to be recompiled with the required CUDA modules enabled. A good guide to follow can be found here: https://jamesbowley.co.uk/accelerate-opencv-4-3-0-build-with-cuda-and-python-bindings/
- Visual Studio (using Visual Studio 2019 in this example)
- The sources for OpenCV and OpenCV Contrib
- CMake
- CUDA Toolkit
- Optional: for video decoding on the gpu - Nvidia Video Codec SDK
- Extract and copy the contents of the Interface directory to the include directory and the Lib directory to the lib directory inside your CUDA installation.
- Optional: for DNN CUDA backend support - cuDNN
- Extract and copy the bin, include and Lib directories to your CUDA installation
The original instructions ask for running everything in a Command Prompt, arguably it’s easier to create a .bat file.
- create a .bat file and open it in your editor:
set "openCvSource=PATH_TO_OPENCV_SOURCE"
set "OpenCVExtraModules=PATH_TO_OPENCV_CONTRIB_MODULES"
set "openCvBuild=%openCvSource%\build"
set "buildType=Release"
set "generator=Visual Studio 16 2019"
"C:\Program Files\CMake\bin\cmake.exe" -B"%openCvBuild%/" -H"%openCvSource%/" -G"%generator%" -DCMAKE_BUILD_TYPE=%buildType% -DOPENCV_EXTRA_MODULES_PATH="%OpenCVExtraModules%/" -DINSTALL_TESTS=ON -DINSTALL_C_EXAMPLES=ON -DBUILD_EXAMPLES=ON -DBUILD_opencv_world=ON -DWITH_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.2" -DCUDA_FAST_MATH=ON -DWITH_CUBLAS=ON -DCUDA_ARCH_PTX=7.5 -DWITH_NVCUVID=ON -DWITH_OPENGL=ON -DWITH_MFX=ON
- run the bat file in a Terminal or Command Prompt
- make changes to the configuration as required using the CMake GUI
- open the OpenCV.sln in Visual Studio
- In the Solution Explorer, expand CMakeTargets and right click on Install, selecting Build
Note: During the process of generating the build files with CMake, an error can occur when running on a ExFAT filesystem:
CMake Error: Problem extracting tar: e:/git/opencv/.cache/ippicv/879741a7946b814455eee6c6ffde2984-ippicv_2020_win_intel64_20191018_general.zip
CMake Error at cmake/OpenCVDownload.cmake:240 (message):
IPPICV: Unpack failed: 1
This can be resolved by using 7zip as explained here: https://stackoverflow.com/a/61489779
The CUDA samples compile real GPU code for the Pascal to Hopper architectures (sm_60 … sm_90) plus PTX for older (compute_50) and future GPUs, which the driver compiles just-in-time. To change this, set the standard CMake variable CMAKE_CUDA_ARCHITECTURES when configuring, e.g. only for an RTX 40-series card:
cmake -S . -B build -DCMAKE_CUDA_ARCHITECTURES="89"For a reference on GPU compilation and virtual as well as gpu features, please refer to the nvcc documentation and the CMAKE_CUDA_ARCHITECTURES documentation.
Microsoft Visual Studio 2022 might throw an error due to the toolset (v143) compatibility version with MSC_VER expected by the CUDA toolkit.
A MSB3721 error and C1189 error referencing the C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\include\crt\host_config.h can arise.
Configure with -DTD_CUDA_ALLOW_UNSUPPORTED_COMPILER=ON to remedy this. It passes the following flags to the compilers: -allow-unsupported-compiler -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH (the second half allows Visual Studio to accept Cuda < 12.4).
Some newer TouchDesigner Versions might be delivered with an updated OpenCV and/or require a newer CUDA Version.
Within the same major version there is nothing to change: CMake reads the version from TouchDesigner's OpenCV headers and links the libraries that match it. Re-run CMake (or delete the build folder) after updating TouchDesigner.
The required major version is set by TD_OPENCV_MAJOR_VERSION in cmake/TouchDesignerCustomOP.cmake. When the samples move to a TouchDesigner build with a new OpenCV major version, update it there (along with any source changes the new OpenCV requires).
Install the CUDA Toolkit version matching the major version of CUDA (11, 12 etc.) that the version of TouchDesigner you are using is on, then re-configure in a fresh build folder. The required major version is set by TD_CUDA_MAJOR_VERSION in cmake/TouchDesignerCUDAToolkit.cmake; if it's not the one your TouchDesigner uses, update it there. See Installing the CUDA Toolkit for selecting a specific toolkit when several are installed.
Every sample folder has its own CMakeLists.txt, and the repository root has a CMakeLists.txt that builds all samples in one project. Both use the shared helper in cmake/TouchDesignerCustomOP.cmake.
The compiled plugins (.dll on Windows, .plugin bundles on macOS) are written to a plugins folder inside the build folder, e.g. build/plugins/BasicFilterCHOP.dll.
TouchDesigner loads custom operators from its system-wide Plugins folder when it starts. After building, copy the plugins there with:
cmake --install build --config ReleaseThe default install folder is:
- Windows:
Documents/Derivative/Plugins(your actual Documents folder, also when it's redirected, e.g. to OneDrive) - macOS:
~/Library/Application Support/Derivative/TouchDesigner099/Plugins
To install somewhere else, such as a Plugins folder next to your .toe file, pass --prefix <folder> to cmake --install, or set CMAKE_INSTALL_PREFIX when configuring. Restart TouchDesigner to pick up a newly installed plugin.
cmake -S . -B build
cmake --build build --config ReleaseOn Windows this generates build/CustomOperatorSamples.sln, with the samples grouped into CHOP / DAT / SOP / TOP folders. On macOS add -G Xcode to get an Xcode project instead of Makefiles.
Samples whose dependencies aren't available (OpenCV, the CUDA Toolkit, the ONNX Runtime) or that don't support the current platform (the CUDA samples are Windows only) are skipped with a warning, and the rest still build. Use -DTD_BUILD_CHOPS=OFF (or _DATS, _SOPS, _TOPS) to leave out an operator family.
Configure the sample's folder directly:
cd CHOP/BasicFilterCHOP
cmake -S . -B build
cmake --build build --config ReleaseOn Windows you can also open build/BasicFilterCHOP.sln, or open the sample folder in Visual Studio with File > Open > Folder. When building a single sample, a missing dependency is an error instead of a warning.
Generators: use -G to choose a specific generator, such as -G "Visual Studio 17 2022", -G Xcode or -G "Unix Makefiles".
Visual Studio and Xcode are set up to launch TouchDesigner (with TOUCH_TEXT_CONSOLE=1) when you start debugging a plugin. This uses the TouchDesigner in TD_INSTALLATION_PATH; set TD_EXECUTABLE only to debug with a different executable.
| Option | Default | Description |
|---|---|---|
TD_BUILD_CHOPS / TD_BUILD_DATS / TD_BUILD_SOPS / TD_BUILD_TOPS |
ON |
Root project only: which operator families to build. |
TD_PLUGIN_OUTPUT_DIR |
<build folder>/plugins |
Folder the built plugins are written to. |
CMAKE_INSTALL_PREFIX |
TouchDesigner's Plugins folder | Where cmake --install copies the plugins (see Installing into TouchDesigner). |
TD_INSTALLATION_PATH |
C:/Program Files/Derivative/TouchDesigner (Windows), /Applications/TouchDesigner.app (macOS) |
Root of the TouchDesigner installation. Its bundled OpenCV and the debugger executable are found relative to it. |
TD_PYTHON_INCLUDE_DIR, TD_PYTHON_LIB_DIR (Windows), TD_PYTHON_FRAMEWORK_DIR (macOS) |
found in TD_INSTALLATION_PATH |
Where TouchDesigner's Python headers and import library (Windows) or framework (macOS) are (see Building without a TouchDesigner installation). |
TD_OPENCV_INCLUDE_DIR, TD_OPENCV_LIB_DIR |
found in TD_INSTALLATION_PATH |
Where TouchDesigner's OpenCV headers and libraries are (see the same section). |
TD_USE_BUNDLED_OPENCV |
ON |
Link TouchDesigner's OpenCV. OFF uses find_package(OpenCV) / OpenCV_DIR. |
ONNXRUNTIME_ROOT |
C:/Program Files/onnxruntime |
Location of the extracted ONNX Runtime package (see Installing the ONNX Runtime). Only appears once an operator that uses ONNX Runtime is configured. |
CMAKE_CUDA_ARCHITECTURES |
see above | GPU architectures for the CUDA samples. |
TD_CUDA_ALLOW_UNSUPPORTED_COMPILER |
OFF |
Windows: allow CUDA < 12.4 with newer Visual Studio toolsets. Only appears once CUDA is set up. |
TD_EXECUTABLE |
empty (TouchDesigner in TD_INSTALLATION_PATH) |
Program launched when debugging from Visual Studio / Xcode. |
CMAKE_OSX_DEPLOYMENT_TARGET |
12.0 |
macOS: oldest macOS version the plugins run on. |
By default Python and OpenCV come from the TouchDesigner installation in TD_INSTALLATION_PATH. A build that has them somewhere else, such as one without a TouchDesigner installation, can point at them directly:
| Variable | Folder |
|---|---|
TD_PYTHON_INCLUDE_DIR |
Windows: Python's headers, the folder with Python.h and patchlevel.h. If it doesn't have pyconfig.h, a PC folder holding it, inside this folder or next to it as in a CPython source tree, is added automatically. Other folders the headers need can be listed after it. |
TD_PYTHON_LIB_DIR |
Windows: the folder with Python's import library. The library that matches the headers is picked from it: python311.lib for Python 3.11 headers, or python311t.lib for a free-threaded Python (when pyconfig.h defines Py_GIL_DISABLED, or the samples target one). Never the _d debug library. |
TD_PYTHON_FRAMEWORK_DIR |
macOS: the folder holding Python.framework (or the framework itself). Python's headers, pyconfig.h included, come from the framework instead of TouchDesigner.app's. On macOS this is the only Python path: TD_PYTHON_INCLUDE_DIR and TD_PYTHON_LIB_DIR are reported as not used. |
TD_OPENCV_INCLUDE_DIR |
The folder with opencv2/core/version.hpp. |
TD_OPENCV_LIB_DIR |
The folder with OpenCV's libraries: the import libraries (opencv_core4110.lib) on Windows, the .dylibs on macOS. The ones matching the headers' version are linked. |
cmake -S . -B build -DTD_INSTALLATION_PATH= \
-DTD_PYTHON_INCLUDE_DIR=C:/python/Include -DTD_PYTHON_LIB_DIR=C:/python/PCbuild/amd64 \
-DTD_OPENCV_INCLUDE_DIR=C:/opencv/include -DTD_OPENCV_LIB_DIR=C:/opencv/x64/vc17/lib- Use forward slashes in these paths. Backslashes are removed by most shells unless the path is quoted, and
C:\dev\pythonthen reaches CMake asC:devpython, a path relative to the current folder. - The version checks still apply: the samples need Python 3.11 and OpenCV 4.x, as the TouchDesigner 2025 series ships them.
- Set
TD_INSTALLATION_PATHempty, as above, when there is no installation at all. - The paths come in pairs, so that headers and libraries can't come from different builds: set both Python paths or neither, and both OpenCV paths or neither. (On macOS, Python comes from
TD_PYTHON_FRAMEWORK_DIRalone.) Configuring stops if only one of a pair is set, or if a path doesn't hold what it should. - Configuring also stops on any other
TD_PYTHON_*orTD_OPENCV_*variable, such as a misspelt name, which CMake would otherwise ignore and so build against the installation instead. - The OpenCV paths are for TouchDesigner's OpenCV, so they can't be combined with
TD_USE_BUNDLED_OPENCV=OFF. - Paths left empty are filled in with what was found in
TD_INSTALLATION_PATH, socmake-guiandccmakeshow where everything comes from. A value filled in this way keeps followingTD_INSTALLATION_PATHwhen it changes; editing it makes it explicit, and clearing it goes back to the installation.
The configure output says where each was taken from, e.g. Adding CHOP sample: BasicGeneratorCHOP (Python 3.11 from TD_PYTHON_INCLUDE_DIR/TD_PYTHON_LIB_DIR).
Copy one of the samples (keep it two folders below the repository root, or adjust the include() path to cmake/TouchDesignerCustomOP.cmake), rename it, and update its CMakeLists.txt:
cmake_minimum_required(VERSION 4.4)
include(${CMAKE_CURRENT_LIST_DIR}/../../cmake/TouchDesignerPreProject.cmake) # must come before project()
project(MyFilterTOP LANGUAGES CXX)
include(${CMAKE_CURRENT_LIST_DIR}/../../cmake/TouchDesignerCustomOP.cmake)
# td_enable_cuda() # only needed if the operator has .cu files
td_add_custom_op(MyFilterTOP
OPENCV_COMPONENTS core imgproc # optional: OpenCV modules to link
# CUDA # optional: compile .cu files, link the CUDA runtime
# PYTHON # optional: build against TouchDesigner's Python
# CXX_STANDARD 20 # optional: C++ standard (default 17)
# INCLUDE_DIRECTORIES include # optional: extra header folders
# WINDOWS_ONLY # optional: skip/fail on other platforms
SOURCES
MyFilterTOP.cpp
Parameters.cpp
MyFilterTOP.h
Parameters.h
CPlusPlus_Common.h
TOP_CPlusPlusBase.h
)To include it in the all-samples build, add an add_subdirectory() line for it to the root CMakeLists.txt.
Code shared with the operator in a static library, or its tests, can use the same OpenCV through td_add_opencv_library(<target> COMPONENTS <modules...>), which makes an INTERFACE library to link to.
On Windows the operators are compiled with the Unicode character set (UNICODE/_UNICODE), as the original Visual Studio projects were, and on macOS for macOS 12.0 or newer (CMAKE_OSX_DEPLOYMENT_TARGET). If an operator's CPlusPlus_Common.h imports <Metal/Metal.h>, as newer TouchDesigner headers do, its sources are compiled as Objective-C++ on macOS and linked with the Foundation and Metal frameworks automatically.
Please refer to the documentation here
Note: When compiling custom operators with a custom version of OpenCV (with or without CUDA) or other dependencies, you will need to place those dependencies next to your custom cpp operator .dlls

