Forums > Jitter

Render-to-texture question (yes, another one!)

Mar 23 2011 | 11:33 pm

Dear Jitter people,

When rendering, I’m sending out lots of bangs to lots of objects which get rendered on screen. Brilliant. But now I want to add some post processing effects over the end result, using shaders. How do I get the total rendered scene into a texture for further processing?
The @capture attribute doesn’t suffice for this case because this will only render single objects to a texture, while I want the whole rendered scene.
I’d love to use some kind of glreadpixels command for, but one which works with textures in stead of matrices.

Any clues?


Mar 23 2011 | 11:43 pm

I recently made this patch for a friend — it’s a simple example that uses color to demystify the flow a bit. Basically you need to use, setting the @capture attribute, and specifying draw order of your client objects with the drawobject message.

-- Pasted Max Patch, click to expand. --

Mar 24 2011 | 12:13 am

Slight edit with @transform_reset set properly on final videoplane.

-- Pasted Max Patch, click to expand. --

Mar 24 2011 | 8:26 am

Precisely! That is exactly what I needed. And I think I just proved to the world that I’m not such a good forum-searcher.

…now I know how it’s done I can easily find the other examples on the list. But for some reason I found this initially very difficult to find. Anyway, I’ll tag this post and try to make this elegant example easy to find.


Mar 24 2011 | 3:53 pm

Back again!

So, next problem: my patch has only 2 objects, but I use each of them as if they were multiple gl objects, with @automatic set to 0.
With every frame I send them many parameters, attach various shaders and bang them multiple times to draw the shapes multiple times on screen.

This does not work with since, on banging it, it shall only draw the shape once, and with the last set of parameters and the last shader that I sent to it.

Basically what I want is quite simple: to copy my fully rendered scene onto a texture. But it seems the solution is anything but simple… 3 questions:

1. Is there an equivalent of ‘banging’ a shape to a (or a texture) like I would bang it to a regular render context?
By this I mean that I’d like to execute drawing of an object (like with "drawobject "), but waiting with sending the end result to the texture (as defined by @capture), until I tell it to.

2. I also see that the object may receive begin_capture and an end_capture commands. Perhaps this could be an answer to my problem? If so, can anybody explain me how to use these, cause I can’t seem to figure this out.

3. One other solution could be sending all of the parameters formerly sent to the gridshape objects, directly to But how would I then switch shaders within one rendering of, like I currently do between the multiple ‘bangs’ of a single gridshape?

Thanks to anyone taking the trouble to think about this!!

Mar 24 2011 | 4:49 pm

although you should be able to do what you want with sketch messages, in this case you might want to try instead the to_texture message to gl.render.
bascially, erase the context, bang all your objects to draw, capture the scene to a texture with to_texture, bang the texture, bang the videoplane, than send the final bang to render.

this patch should demonstrate:

-- Pasted Max Patch, click to expand. --

Mar 24 2011 | 9:48 pm

Again, a strange mixture of embarrassment (because yes, it is that easy..!), happiness and gratitude. This works very nicely. Great example.

Jan 08 2012 | 1:35 pm

Hey guys,

I just came across this thread and Robert’s nice patch about using "to_texture".
I’m facing problems in a current project with one frame delays in my rendering chain using to_texture, and when going back to Rob’s patch I noticed there was actually the same.

Basically, if you cut the metro and do it manually, you have to bang the rendering trigger twice to make appear a rotation from the handle on the window.

Attached is the patch with basic directions to reproduce.

Is it the normal behaviour (and/or drawback?) of using to_texture? or is there a way to fix that?

Curious to hear about your thoughts/knowledge on this.


(I’m on a 10.6.8 i7 Mac, in case you cannot reproduce)

-- Pasted Max Patch, click to expand. --

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

Forums > Jitter