Forums > MaxMSP

Process the pixels from an openGL scene with GPU only ?

October 7, 2012 | 8:19 pm

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


October 8, 2012 | 7:31 am

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.


October 8, 2012 | 7:40 am

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.


October 8, 2012 | 8:08 am

works perfectly, of course.


October 8, 2012 | 8:49 am

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..


October 8, 2012 | 9:47 am

Here is the result

– Pasted Max Patch, click to expand. –

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 ?

[attachment=205460,4503]

Attachments:
  1. globalView.PNG

Viewing 6 posts - 1 through 6 (of 6 total)