Porting an opengl application to touchdesigner

Hello,

I have an opengl application written in Java/jogl (the language does not matter for this question).

I’m using instance rendering, buffer objects, vertex and fragment shaders.

The program receives a few float parameters via OSC that are injected as uniforms inside the shaders.

I wish to port my code to touchdesigner so I can easily add composting with the output of my opengl program. (ie. Add blur or feedback without developing further layers of opengl programs).

80% of the code is Glsl and the rest is Java code calling opengl C functions.

I am willing to recode the Java part in any language.

Could someone tell if it’s possible to port that application inside touchdesigner? If yes, could you point to the right documentation? I tried a few keywords but didn’t find what I was looking for.

I found how to receive OSC values which is a good start. I also found how to program fragment shaders, but it’s not sufficient.

If it’s not possible, is there any hack / workaround to capture the opengl buffers of my Java program so that it is processed by touchdesigner?

Thanks

Hey, Welcome!
There isn’t specific docs on porting from OpenGL. However for your GLSL you’ll want to use the GLSL TOP and GLSL MATs. You don’t really have to think about buffer objects since those are all handled for you.

From your Java program, look into Spout and DirectX texture sharing. That is how you can get textures across processes in Windows. Or Syphon on macOS.

Thanks for your quick answer.

I had a look at the documentation you gave, there is almost everything I need.

Except for Buffer Objects.

I am not referring to vertex buffers.

I am referring to Buffer Object - OpenGL Wiki

This is memory that is readable and writable and that you can use for example to update particle positions, using instanceId, at each frame using the GPU. This is to avoid computing them on the CPU and transferring them to the GPU memory.

Without this I can not port the code.

You would just write to textures for that in the GLSL TOP. Then you can source those textures as your particle positions in a GLSL MAT. The gpuParticles example in the palette does this.

That’s a solution indeed!

Is there absolutely no way to use Buffer Objects? They are much more convenient for generic memory.

I have something like 10 attributes per instance. Using structs and buffer objects is very convenient. Textures are really not convenient and will make the code harder to maintain.

Currently there is no way to work with arbitrary buffer data like that in TOPs directly. You’d need to write a Custom Operator in C++ to do that.

Thanks for you help, I will try using spout/syphon first, it looks like a very clean and flexible way to integrate both components.

Cheers!