capture to texture is so easy ...
... from one object to an other, as shown in the jit.gl.texture-copytotex.pat in max examples folder.
But what is the way to capture several GL objects to one texture?
[jit.gl.texture] can't capture more than one.
I suppose [jit.gl.sketch] could be of any use, but I can't find an example patch.
Could you tell me where can I find one, (forum? receipes?) or point out the technic.
Thank you very much.
Xtra! Thank you so much!
Is there a way to capture an entire scene to [jit.gl.texture]?
usetexture [texturename], to_texture
jit.gl.render.
On Nov 14, 2008, at 4:25 PM, Derrick Giscloux wrote:
>
> Is there a way to capture an entire scene to [jit.gl.texture]?
> Is there a way to capture an entire scene to [jit.gl.texture]?
I mean: capture the render in a jit.gl.texture
I does not seem to work. Is it a least possible?
Thank you
no, this does work, as long as you have a jit.gl.texture object to
catch the texture. but you need to be careful about timing.
On Nov 14, 2008, at 6:08 PM, Derrick Giscloux wrote:
>
>> Is there a way to capture an entire scene to [jit.gl.texture]?
>
>
> I mean: capture the render in a jit.gl.texture
>
>
> I does not seem to work. Is it a least possible?
>
>
> Thank you
Oh yes! I can readback my context to matrix to texture then apply to a videoplane.
thank you.
Ok, I am able to capture the context to a videoplane, thanks to readback technics (1.6.3 !!).
- Now I want some 3D elmts in the scene not to be captured in.
Can I tell some 3D objects (gridshape & else): "don't be captured to the texture where I catch the render"?
It seems difficult since the readback reads back the entire scene?
I think I have to use a second context ...
You should not need two contexts nor should you need to render to a matrix. What you need to do is
Prerequisites:
some objects to render
jit.gl.render/jit.window destination
an extra jit.gl.videoplane, and the jit.gl.texture @name capturetexture (or whatever name you want) to capture the scene to
Now you do:
erase to jit.gl.capture
render all the objects, with @automatic 0 and sending bangs in the proper order
2, send usetexture capturetexture, to_texture to jit.gl.render
this now populates the texture with the contents of the objects you banged (rendered).
Now you have to draw the texture. If you are rendering things with alpha, you should either use @blend_enable 0 on jit.gl.videoplane.
Now, send the texture to the videoplane, which should look something like:
jit.gl.videoplane mycontext @automatic 0 @blend_enable 0 @depth_enable 0
voila. No to matrix, no to second context, etc. Plenty of examples of this on the list.
Definitely avoid using shared_context for this, you'll need it later
for the preview window:)
My new favorite way of capturing various objects to different textures
without thinking too much about the order, with automatic 1, proper
alpha channels, depth_enable, blending etc, etc, is using:
the jit.gl.sketch (tm) (best gl object ever!)
the idea is to group objects using one sketch per group and drawobject
messages. Then capture those groups to texture simply using @capture
attribute to enclosing sketch.
another tip for good capturing is to avoid using erase message to
jit.gl.render, since it can fill the background around the captured
object with it's alpha value, and it also can't fill the background
with the alpha of 0.
So, i prefer using:
the jit.gl.sketch (tm)
for clearing the context, using: glclearcolor, glcleardepth, glclear
and @automatic 0
instead of sending erase to jit.gl.render, just bang this object at
the beginning of the draw cycle.
I've attached two patches to demonstrate this. First one demonstrates
what I mentioned above, and second one has a bit more details, ideas
and bugs.
Second example also shows how one could have a better blending and
depth sorting using old gl trick of first drawing all non-transparent
objects, and then transparent ones over them. This system queries
blend_enable and color attributes and then sorts drawing order based
on that.
It also has a post-process stage that uses slabs to process two
captured groups and then display this on the third videoplane.
I know this explanation is a bit short and fuzzy, so please feel free
to ask more questions!
-nesa
multicapture-simple:
*********************second example************************************
Thanks Vade below is the patch.
Sorry nesa, still not on Max V.
Thanks for the tips - I found this thread helpful. I was not able to get @shared_context to work for my needs, but just throwing a @capture on my jit.gl object allowed me to easily use it as a texture for another object! Sweet!
Thanks,
James
wish I had this thread like a year ago for my thesis! R
On Mon, Nov 17, 2008 at 9:52 AM, Derrick Giscloux
wrote:
>
> Thanks Vade below is the patch.
> Sorry nesa, still not on Max V.
>
>
> #P window setfont "Sans Serif" 9.;
> #P flonum 309 415 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 1;
> #P message 309 434 84 196617 position $1 0. 0.;
> #P window linecount 2;
> #P newex 278 461 239 196617 jit.gl.videoplane asd @scale 0.5 @automatic 0 @blend_enable 0 @depth_enable 0 @texture mytex;
> #P window linecount 5;
> #P message 275 25 297 196617 ; max launchbrowser https://cycling74.com/forums/index.php?t=msg&th=34799&start=0&rid=3975&S=7ce5bd165531a69fd736c670d0f10f69;
> #P flonum 501 208 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 1;
> #P message 501 230 69 196617 color 0. 1. 0.;
> #P newex 278 137 284 196617 t b b b b b;
> #P flonum 582 127 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P message 582 146 84 196617 position $1 0. 0.;
> #P message 414 320 179 196617 usetexture mytex , to_texture , erase;
> #P newex 56 404 144 196617 jit.window asd @pos 800 600;
> #P newex 56 107 125 196617 t b b erase;
> #P toggle 56 64 15 0;
> #P newex 56 84 57 196617 qmetro 66;
> #P newex 56 370 83 196617 jit.gl.render asd;
> #P window linecount 2;
> #P newex 482 252 247 196617 jit.gl.gridshape asd @automatic 0 @scale 0.2 @position -0.3 0. 0. @shape circle @color 1. 0. 0. 1.;
> #P newex 550 168 211 196617 jit.gl.gridshape asd @shape torus @scale 0.2 @position 0.3 0. 0. @automatic 0;
> #P window linecount 1;
> #P newex 346 380 217 196617 jit.gl.texture asd @name mytex @automatic 0;
> #P window linecount 2;
> #P comment 597 320 235 196617 • to_texture = Copy the previously drawn frame to the named texture. Useful for feedback effects.;
> #P connect 6 0 5 0;
> #P connect 5 0 7 0;
> #P connect 7 2 4 0;
> #P connect 7 0 4 0;
> #P fasten 9 0 4 0 419 353 61 353;
> #P fasten 7 1 12 0 118 132 283 132;
> #P connect 12 0 16 0;
> #P fasten 17 0 16 0 314 455 283 455;
> #P connect 18 0 17 0;
> #P connect 12 1 1 0;
> #P connect 12 2 9 0;
> #P connect 12 3 3 0;
> #P fasten 13 0 3 0 506 248 487 248;
> #P connect 14 0 13 0;
> #P connect 12 4 2 0;
> #P fasten 10 0 2 0 587 164 555 164;
> #P connect 11 0 10 0;
> #P window clipboard copycount 19;
>
>
>
jit.gl.sketch wuth drawobject commands is probably the easiest way to
capture a scene to texture. The other possible solution is to use
jit.gl.lua and something like:
jit.gl.begincapture("mytex", 0)
-- draw scene here
jit.gl.endcapture("mytex", 0)
wes