Process the pixels from an openGL scene with GPU only ?

Julien Bayle's icon

Hi there,
I'm rendering very simple OpenGL context (only primitives multiplied with jit.gl.multiple and matrices processed with jit.gen for position/scale of objects)

rendering it to a jit.window, I'd like to add a light pixel processing stage just before the final output.

Is there a smart/efficient way to do that without to many round trip from CPU/GPU ?

I'm open to any discussions around this

Pedro Santos's icon

Search here and on Max's examples folder for "render to texture". You capture the scene, process that texture with jit.gl.slab and attach it to a jit.gl.videoplane.
In Max 6, you could simplify the process with jit.gl.node and instead of jit.gl.slab you could also use jit.gl.pix.

None of these techniques involve going back to the CPU.

Julien Bayle's icon

okay got it. sometimes (often?) I'm a stupid theorist which is unable (especially in the morning...) to apply what he knows and you just pointed me here to the totally right thing, Pedro. Thanks for that.

Ok about the fact it doesn't go back to the CPU.

Julien Bayle's icon

works perfectly, of course.

Julien Bayle's icon

trying now to switch on/off captures inside my messaging system.

indeed, I have "many" small video generators with only one active at a time.

because the texture rendering has to be included in all of them in order to make the final pixel processing stage, I need to capture only the one active...
playing with that..

Julien Bayle's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here is the result

I didn't find a better way to render from each snippet (one at a time) to global texture.
The routing system is very cheap, and I'll consolidate it asap.
But what I'm doing here when I want to trigger a particular snippet:
- I send the message "drawto texture" to this particular videoplane
- when i trig this latter, that one send a bang to all other snippets to trig the message "drawto a"

a isn't related to anything in the patch and I guess it doesn't consume any gpu or cpu here (of course, I also not routing any qmetro bangs to any snippets except the current rendering one.

is there a smarter way to disable the render to texture ?

4503.globalView.PNG
PNG