GL Feedback

Jan 24, 2006 at 11:17pm

GL Feedback

Hi Jitter-fans,
Here’s a simple demo patch that shows how to set up the to_texture
message to perform feedback processing with a gl context. I’ve included
2 textures, one for using fullscreen mode, and then the other for using
the 640 480 window. This technique of switching textures allows for
resizing the jit.window without getting those error messages. With a
little ingenuity, you can be kicking out some swirly 3-D psychedelic
visuals in no time.

Have fun, and Happy Patching!
Cheers,
Andrew B.

#24082
Jan 24, 2006 at 11:19pm

And here it is for reals:

max v2;
#N vpatcher 17 44 1252 430;
#P window setfont “Sans Serif” 12.;
#P window linecount 4;
#P comment 955 250 265 196620 this is set for an apple cinema display’s
dimensions. You will need to resize for your monitor in order for
fullscreen to work.;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 624 216 91 196617 window texture;
#P comment 900 216 91 196617 fullscreen texture;
#P window linecount 3;
#P comment 202 27 268 196617 This patch does a simple demonstration of
the to_texture message , and shows a workaround for resizing contexts.
In this case it is being used for scene-texture feedback.;
#P window linecount 1;
#P comment 47 60 154 196617 andrewb@cycling74.com;
#P flonum 806 267 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 843 267 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 769 267 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 732 284 121 196617 pak position 0. 0. -0.4;
#P message 360 252 28 196617 read;
#P newex 343 282 103 196617 jit.qt.movie 320 240;
#B color 5;
#P newex 443 77 40 196617 key;
#P message 419 123 70 196617 fullscreen $1;
#P newex 254 123 164 196617 sel 0 1;
#P message 331 143 75 196617 usetexture fst;
#P newex 886 231 274 196617 jit.gl.texture foo @name fst @dim 1024 768
@mode static;
#P newex 596 265 49 196617 switch 2;
#P newex 596 183 27 196617 + 1;
#P toggle 419 102 15 0;
#P newex 443 97 38 196617 sel 27;
#P message 651 266 34 196617 reset;
#P window linecount 2;
#P newex 299 309 253 196617 jit.gl.videoplane foo @automatic 0 @scale
1.333 1. 1. @color 1. 1. 1. 0.3 @blend_enable 1 @blend_mode 6 1;
#P window linecount 1;
#P newex 651 284 80 196617 jit.gl.handle foo;
#P window linecount 2;
#P newex 642 311 302 196617 jit.gl.videoplane foo @automatic 0 @scale
-1.333 1. 1. @color 1. 1 1 0.7 @blend_enable 1 @blend_mode 6 1 @position
0. 0. -0.4;
#P window linecount 1;
#P message 254 143 76 196617 usetexture dst;
#P newex 615 231 269 196617 jit.gl.texture foo @name dst @dim 640 480
@mode static;
#P toggle 46 83 15 0;
#P newex 419 142 146 196617 jit.window foo @size 640 480;
#P newex 46 255 231 196617 jit.gl.render foo @erase_color 0.07 0.07 0.05 1.;
#P newex 46 128 134 196617 t to_texture b b b b b erase;
#P newex 46 104 51 196617 qmetro 5;
#P window setfont “Sans Serif” 24.;
#P comment 47 27 154 196632 GL Feedback;
#P connect 5 0 1 0;
#P connect 1 0 2 0;
#P fasten 17 0 3 0 336 224 51 224;
#P lcolor 7;
#P connect 2 0 3 0;
#P lcolor 7;
#P fasten 7 0 3 0 259 224 51 224;
#P lcolor 7;
#P fasten 2 6 3 0 171 224 51 224;
#P lcolor 7;
#P fasten 2 1 3 0 71 224 51 224;
#P lcolor 7;
#P fasten 13 0 18 0 424 119 259 119;
#P connect 18 0 7 0;
#P fasten 2 2 10 0 91 212 304 212;
#P fasten 21 0 10 0 348 304 304 304;
#P connect 18 1 17 0;
#P fasten 2 4 21 0 131 206 348 206;
#P connect 22 0 21 0;
#P connect 12 0 13 0;
#P connect 13 0 19 0;
#P connect 19 0 4 0;
#P connect 20 0 12 0;
#P fasten 13 0 14 0 424 119 601 119;
#P connect 14 0 15 0;
#P fasten 2 5 6 0 151 203 620 203;
#P connect 6 0 15 1;
#P fasten 16 0 15 2 891 255 639 255;
#P fasten 15 0 8 0 601 288 647 288;
#P lcolor 13;
#P fasten 9 0 8 0 656 306 647 306;
#P fasten 23 0 8 0 737 306 647 306;
#P fasten 2 3 8 0 111 209 572 209 572 299 647 299;
#P connect 11 0 9 0;
#P connect 24 0 23 1;
#P connect 26 0 23 2;
#P connect 25 0 23 3;
#P fasten 2 5 16 0 151 203 891 203;
#P pop;

#69095
Jan 25, 2006 at 8:32am

hi andrew,

thanks for the clear gl_feedback_example!
the texture switching method is exactly what i needed.

cheers,

jan

#69096
Jan 25, 2006 at 11:36am

Wow.

So much food for thought. I will come back with more questions later
today ;-)

Thank you!

pa

#69097
Jan 25, 2006 at 12:04pm

Hi Andrew, I’m only getting these errors:

jit.gl.render: building GL on window “foo”…
warning: method screen_grab called on invalid object
warning: method screen_grab called on invalid object
warning: method screen_grab called on invalid object


etc.

winmax 4.5.6 jitter 1.5.2

Thijs

#69098
Jan 25, 2006 at 12:17pm

hoi thijs,

the ‘usetexture dst’ message box needs to be sent to the render befor
you start the feedback.
best achieved by putting a ‘loadbang 0′ to the fullscreen togglebox..

grtn,

jan

#69099
Jan 25, 2006 at 12:27pm

Ah thanks!

t_

#69100
Jan 25, 2006 at 1:18pm

> best achieved by putting a ‘loadbang 0′ to the fullscreen togglebox..

i meant ‘loadmess 0′ of course.
i should really stop typing emails with my nose;.)

>
> Ah thanks!

you’re welcome!

jan

#69101
Jan 25, 2006 at 3:29pm

Dear Andrew, Wesley and all

If I understand well, to_texture can only be used to do whole scene
feedback. The capture to texture is working fine so far. I have one
more question:

Wesley, what do you mean when you say:

> Personally, I like to render to a pbuffer.

I have looked on the web for pbuffer and can’t figure out what you
are talking about.

pa

nb It seems that the getparamlist message to jit.gl.slab does not
output anything…

#69102
Jan 25, 2006 at 4:13pm

Here’s a glossary of graphics card terms:
http://www.gpgpu.org/w/index.php/Glossary#FBO . After looking at this
page, I learned a new one: FBO . Seems to be the best place to get a
render to texture now-a-days.

> nb It seems that the getparamlist message to jit.gl.slab does not
> output anything…

The best way to figure out what params a shader has is to open the
file in a text editor (I prefer Text Wrangler on OSX). It’s easier to
see there than as a list in the maxwindow.

wes

#69103
Jan 25, 2006 at 4:36pm

Thanks so much

pa

#69104
Jan 25, 2006 at 4:40pm

Wesley.

Can I shamefully ask for a small sample code of pbuffering? It all
sounds great, I understand the concept, but to see a real example
will help me to deduce more usage of the openGL book started today
and ways to apply that in jitter.

Thanks

pa

#69105
Jan 25, 2006 at 4:53pm

As I’m sure you’ve discovered, it’s used alot in the computer gaphics
literature for multipass rendering. If you can get your hands on GPU
Gems 2 from your local library I think you’ll find the pages 541-543
decently descriptive as it also has code sinppets. (I’m not sure, but
NeHe might have something about this as well…in any case it’s a
great resource for opengl manips).

wes

#69106
Jan 25, 2006 at 6:32pm

#69107
Jan 27, 2006 at 8:29am

I have read the book chapter but I still find no connection on using pbuffer
in Max/Jitter environment….

Wesley, could you help to give a bit more hint on utilizing pbuffer ? Should
we use jit.gl.sketch or we have to write our own (or find) an external to
work on it ?

by the way, in my days of experiementing with rendering to texture, I have
encountered an error message saids “jit.gl.pbuffer: error updating bound
texture: GL Error: Stack overflow”. I wonder if there is an implicit object
named jit.gl.pbuffer but I have found no entry of documentation about it…

ps: Thanks to Andrew for your patch. I have made the “to_texture” working
now, but seems it only work on the display buffer while my application need
to a capture from an offscreen buffer (e.g. render to texture from camera A
and render scene in camera B with the captured texture)

(^_^)
William

#69108
Jan 27, 2006 at 3:10pm

I don;t have the book in front of me right now, but let me see if I
can remember. It went a little something like this:

Rendering to a pbuffer in the traditional fashion requires a new
opengl context to be set up. This causes massive overhead a slow
applications. Using the opengl aux buffers liek AUX0 etc gets you the
same effect but without the context switches. On the aforementioned
pages, there was code as to how to set this up. Unfortunately, to do
this in jitter right now, you’re gogin to have to write your own
external as far as I know.

best,
wes

#69109
Jan 27, 2006 at 3:28pm

this isn’t working for me at all. when i switch to fullscreen, i get the grid texture on the vidplane and the max window fills with

jit.gl.texture: error entering unbind: GL Error: Invalid value
jit.gl.texture: error entering unbind: GL Error: Invalid value
jit.gl.texture: error entering unbind: GL Error: Invalid value
jit.gl.texture: error entering unbind: GL Error: Invalid value
jit.gl.texture: error entering unbind: GL Error: Invalid value
jit.gl.texture: error entering unbind: GL Error: Invalid value
jit.gl.texture: error entering unbind: GL Error: Invalid value

os x 10.4.4, albook 1.67 feb 05, newest m/m/j.

#69110
Jan 27, 2006 at 3:33pm

You have to muck with the textures a bit to get it to work. I too had
the same errors but was eventually able to get it to work.

wes

#69111
Jan 27, 2006 at 4:05pm

how? what did you have to do?

#69112
Jan 27, 2006 at 4:13pm

I believe I never used the fst texture, just the dst texture. I also
messed with the texture dims. I don’t remember the specific settings,
but that’s what I messed with. Also, when you go fullscreen, the
context is rebuilt, so you may have to reregister the texture names by
clicking on the appropriate messages.

wes

#69113
Jan 27, 2006 at 7:24pm

this is the sort of thing that just makes me feel like an idiot w/r/t the gl stuff. i get weird errors and random crashes, and when i report them i get the digital equivalent of blank stares.

wes, can you post a version of this that actually does work? TIA.

#69114
Feb 9, 2006 at 5:23am

thanks andrew. the dual texture concept saved the day for a readback thing I needed. my head was getting sore bc. i was trying to change dims on the texture, which, for whatever reason, it did NOT like.

peter.

#69115

You must be logged in to reply to this topic.