outputting video texture to two different render contexts

Mac Thiessen's icon

Hi,

I'm refining a project that I have been working on for several months. I had hoped to take advantage of a relatively powerful gpu, but have run into a problem when I am trying to output jit.movie to textures, and there is more then one rendering context.

I wont get into the full details of the project, but a simplified version of what I have been trying to get to work is attached. I'm basically trying to run two copies of the 43j tutorial, using output texture. I currently have it working the way I want it without using output_texture, but being able to utilize the gpu in a bigger way will be a game changer for the project, as the cpu is being taxed in number of other fairly heavy ways.

I would appreciate any help/suggestions/collaboration. For what it's worth, I did search the forum, looked at the various tutorials, tried to utilize jit.gl.node but I've gotten stuck here.

Thanks in advance.

examplepatch.maxpat
Max Patch
yaniki's icon

Hi Mac

To share textures between two or more rendering contexts just use @shared 1 attribute (of [jit.world] or [jit.window] or [jit.pwindow]). Check this topic - https://cycling74.com/forums/splitting-an-opengl-screen/ - and patches I attached there.

Mac Thiessen's icon

great! that worked great on my test patch. Thanks!

Mac Thiessen's icon

Out of curiosity, how would I switch the output textures from a single jit.move object between render contexts? In the patch attached, it seems to switch the textures like a big clump - all at once.

Ideally, I would like to be able switch the jit.movie render destinations, and the slab (as in the attached patch). In my project, one render destination is a preview, while the other is on a projector. As it stands, I will have to have to have two jit.movie objects, with the same movie in it for each window and I'll setup a co-ordinated start and stop between them, so the preview stops when the projector movie starts. I'd rather just have one object that can switch the textures between the respective windows and slabs while doing the work all on the gpu.

It was easy to do when the output of the jit.movie object a matrix, but I'm really trying to free up as much cpu as possible.

examplepatchver2.maxpat
Max Patch
yaniki's icon

If you put an instance of the [jit.movie] object in your patch (e.g. [jit.movie ctx @adapt @texture_name tex]) and you want to change rendering context just send "drawto" message followed by the name of rendering context to the object. But with @shared 1 attribute you don't need it - the texture should be accessible from all your rendering contexts (if created with @shared 1) .

Rob Ramirez's icon

yes, as yaniki says, you shouldn't need to change the drawto to draw to either destination, as long as @shared is enabled in both destinations. furthermore, you probably don't want to change the drawto in a performance setting, as that causes the gl texture resources to be freed and rebuilt.

Mac Thiessen's icon

I think the challenge I am having is that I actually want to have the video switch between the two render contexts, not be shared between both.

The idea is to be able to configure a video (setup a loop, adjust playback speed etc) in a preview window and then switch it to the projector. I have updated my example patch to reflect your suggestions, but I'm not able to switch between the windows, only get playback in both windows.

Unless anyone has any suggestions to make my patch work, I think I'll stick to using two instances of jit.movie for each clip, and setting things up to stop the clip from playing in the preview window when it gets played in the projector window. Maybe I'll try out jit.gl.hap.

Thanks again for all of your help!

Mac

examplepatchver21.maxpat
Max Patch
Rob Ramirez's icon
Max Patch
Copy patch and select New From Clipboard in Max.

you just have to clear the stored texture of the destination you no longer want to be drawing the video to, e.g. by sending in a black matrix when no longer streaming video to that destination.