smooth rendering/writing to disk?

Feb 1, 2006 at 11:16pm

smooth rendering/writing to disk?

Howdy list,

I’m very curious about getting smooth animations (using OpenGL),
especially for non-realtime (frame-by-frame, using bline to drive
presets) recording. I created this patch as part of a system for doing
that – starting a save, stopping a save, all without losing frames, and
recording frame-by-frame without skipping any. Can someone look this
over and tell me if this is an efficient method for doing this? My
biggest issue was working out a way of banging the jit.gl.render
object, reading that video to a matrix, saving it via jit.qt.record,
and then banging again when done, without causing a stack overflow.

There are comments in the attached patch that explain the process.
Basically, I use onebang as a gate after the main qmetro (which drives
the patch) to prevent the state of the jit.gl.* objects from changing
before the frame finishes rendering. But it’s possible that I’m
missing something, using a qmetro on one end and jit.qball on the
other. It does seem to work very well, though.

Any thoughts appreciated.

Best,
Evan

max v2;
#N vpatcher 126 74 856 767;
#P origin -5 -23;
#P window setfont “Sans Serif” 9.;
#P comment 115 121 18 196617 ->;
#P comment 115 56 18 196617 ->;
#P window linecount 5;
#P comment 132 56 208 196617 onebang (after qmetro) gates the master
clock , opens after either renderer is finished rendering scene or (if
file saving gate is open) after scene has been rendered AND a frame
written to a file;
#P window linecount 1;
#P comment 132 40 277 196617 Qmetro (master clock) is always on (for
realtime preview);
#P window linecount 0;
#P message 307 580 219 196617;
#P window linecount 1;
#P newex 307 558 62 196617 prepend set;
#P newex 308 537 59 196617 r QTrecord;
#P newex 237 621 65 196617 s savePause;
#P toggle 237 591 22 0;
#P newex 238 568 39 196617 s save;
#P toggle 238 538 22 0;
#P newex 48 161 20 196617 t b;
#P newex 453 313 123 196617 pak color 0.2 0.5 0.2 0.8;
#P button 475 165 15 0;
#P newex 501 118 50 196617 loadbang;
#P newex 501 187 107 196617 expr ($f1+50.)*0.01;
#P newex 501 165 58 196617 random 50;
#P message 501 227 62 196617 0. , $1 400;
#P newex 321 313 123 196617 pak color 0.6 0.3 0.2 0.8;
#P window linecount 2;
#P newex 314 425 236 196617 jit.gl.handle testclk @auto_rotate 1
@tracking 2. @radius 0.2;
#P window linecount 4;
#P newex 157 363 215 196617 jit.gl.gridshape testclk @shape sphere
@scale 0.6 0.3 0.2 @color 0.7 0. 0.2 0.8 @smooth_shading 1
@lighting_enable 1 @automatic 0;
#P window linecount 3;
#P newex 377 365 234 196617 jit.gl.gridshape testclk @shape cube @scale
0.3 0.3 0.5 @color 0.2 0.5 0.2 0.8 @smooth_shading 1 @lighting_enable 1
@automatic 0;
#P window linecount 1;
#P newex 441 284 70 196617 s renderSync;
#P newex 441 259 107 196617 bline 0.;
#P newex 441 232 50 196617 r sync;
#P newex 217 219 50 196617 loadbang;
#P flonum 197 167 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 195 218 15 0;
#P newex 135 183 72 196617 qmetro 33.45;
#P newex 135 220 50 196617 onebang;
#P newex 48 476 23 196617 !- 2;
#P newex 48 446 39 196617 r save;
#P newex 98 528 47 196617 gate 2 2;
#P message 149 437 86 196617 lighting_enable 0;
#P newex 135 502 20 196617 t b;
#P newex 135 481 107 196617 jit.qball @mode defer;
#P toggle 191 273 15 0;
#P newex 212 274 29 196617 gate;
#P user jit.fpsgui 251 274 60 196617 0;
#N vpatcher 503 152 941 433;
#P toggle 351 83 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 351 103 50 196617 visible $1;
#P newex 59 151 50 196617 r window;
#P message 194 152 70 196617 size 320 240;
#P message 117 152 70 196617 size 640 480;
#P toggle 287 86 15 0;
#P message 287 104 55 196617 floating $1;
#P toggle 214 86 15 0;
#P newex 175 85 35 196617 sel 27;
#P message 214 104 68 196617 fullscreen $1;
#P newex 130 85 40 196617 keyup;
#P window linecount 2;
#P newex 30 184 228 196617 jit.window testclk @rect 200 100 520 340
@depthbuffer 1 @fsmenubar 0 @floating 0;
#P inlet 351 32 15 0;
#P fasten 10 0 1 0 64 175 35 175;
#P fasten 9 0 1 0 199 175 35 175;
#P fasten 8 0 1 0 122 175 35 175;
#P fasten 3 0 1 0 219 126 35 126;
#P fasten 6 0 1 0 292 126 35 126;
#P fasten 11 0 1 0 356 126 35 126;
#P fasten 2 0 4 0 135 104 172 104 172 83 180 83;
#P fasten 4 0 5 0 180 104 211 104 211 83 219 83;
#P connect 5 0 3 0;
#P connect 7 0 6 0;
#P connect 0 0 12 0;
#P connect 12 0 11 0;
#P pop 1;
#P newobj 53 342 50 196617 p Window;
#P newex 37 124 65 196617 r savePause;
#P newex 37 603 74 196617 gate 1 1;
#P button 152 242 15 0;
#P newex 135 312 70 196617 r renderSync;
#P newex 239 437 63 196617 r toRenderer;
#P newex 135 270 39 196617 s sync;
#P toggle 80 477 15 0;
#N vpatcher 700 117 1195 611;
#P origin 0 10;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P newex 231 394 77 196617 route codeclist;
#P newex 180 246 64 196617 r framerate;
#P newex 181 285 61 196617 float 29.97;
#P message 9 346 64 196617 getcodeclist;
#P outlet 76 416 24 0;
#P window linecount 1;
#P newex 76 393 20 196617 t b;
#P toggle 281 327 15 0;
#P newex 231 440 77 196617 print codecs;
#P newex 231 418 25 196617 iter;
#P message 281 348 63 196617 realtime $1;
#P newex 298 416 59 196617 s QTrecord;
#P hidden newex 10 456 105 196617 bgcolor 237 30 41;
#P inlet 114 36 15 0;
#P message 251 325 27 196617 stop;
#P newex 257 84 40 196617 sel 1 0;
#P message 112 113 125 196617 reset , glreadpixels vessel;
#P newex 94 140 179 196617 jit.gl.sketch testclk @automatic 0;
#P message 86 325 162 196617 write $1 photojpeg lossless;
#P newex 76 369 165 196617 jit.qt.record 640 480 @realtime 0;
#P newex 76 71 28 196617 t b b;
#P inlet 76 36 15 0;
#P newex 76 194 162 196617 jit.matrix vessel 4 char 640 480;
#P connect 1 0 2 0;
#P lcolor 1;
#P connect 2 0 0 0;
#P lcolor 1;
#P connect 0 0 3 0;
#P fasten 8 0 3 0 256 360 81 360;
#P lcolor 1;
#P fasten 4 0 3 0 91 360 81 360;
#P lcolor 1;
#P fasten 12 0 3 0 286 365 81 365;
#P fasten 18 0 3 0 14 367 81 367;
#P connect 3 0 16 0;
#P connect 16 0 17 0;
#P fasten 19 0 4 0 186 319 91 319;
#P lcolor 1;
#P fasten 6 0 5 0 117 135 99 135;
#P lcolor 1;
#P connect 2 1 5 0;
#P lcolor 1;
#P fasten 7 0 6 0 262 108 117 108;
#P lcolor 1;
#P fasten 7 0 19 0 262 280 186 280;
#P lcolor 1;
#P connect 3 1 21 0;
#P connect 21 0 13 0;
#P connect 13 0 14 0;
#P connect 20 0 19 1;
#P fasten 7 1 8 0 277 316 256 316;
#P lcolor 1;
#P fasten 9 0 7 0 119 55 262 55;
#P connect 15 0 12 0;
#P connect 21 1 11 0;
#P pop;
#P newobj 65 568 74 196617 p renderToFile;
#P newex 53 313 49 196617 loadbang;
#P newex 135 337 406 196617 t b b b erase;
#P toggle 135 164 15 0;
#P newex 135 460 212 196617 jit.gl.render testclk @erase_color 0. 0. 0.
1.;
#P comment 218 516 130 196617 stripped-down saving GUI;
#P window linecount 4;
#P comment 402 63 238 196617 preset control – synced to master clock
(for non-realtime recording of presets) – this is connected to a
pattrstorage in other patches to control multiple sets of parameters
over time;
#P user panel 49 549 109 44;
#X brgb 255 57 43;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P window setfont “Sans Serif” 14.;
#P window linecount 1;
#P comment 110 18 57 196622 Notes:;
#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P comment 1 96 100 196617 pauses and resumes while saving;
#P window linecount 3;
#P comment 132 121 211 196617 Is this an efficient use of processing ,
using automatic 0 on gridshapes , and jit.qball to prevent stack
overflows?;
#P window linecount 1;
#P comment 115 40 18 196617 ->;
#P user panel 218 531 339 110;
#X brgb 235 178 178;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P background;
#P user panel 403 113 223 196;
#X brgb 174 255 173;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P background;
#P connect 20 0 19 0;
#P fasten 20 0 49 0 42 151 53 151;
#P connect 29 0 30 0;
#P connect 12 0 21 0;
#P fasten 28 0 13 0 103 561 70 561;
#P fasten 29 0 14 0 53 467 85 467;
#P fasten 30 0 28 0 53 510 103 510;
#P fasten 13 0 19 1 70 589 106 589;
#P fasten 14 0 13 1 85 553 134 553;
#P connect 10 0 32 0;
#P connect 32 0 31 0;
#P connect 31 0 15 0;
#P fasten 18 0 15 0 157 264 140 264;
#P connect 17 0 11 0;
#P connect 11 0 9 0;
#P fasten 11 3 9 0 536 360 140 360;
#P fasten 27 0 9 0 154 457 140 457;
#P fasten 16 0 9 0 244 457 140 457;
#P fasten 41 0 9 0 319 457 140 457;
#P connect 9 0 25 0;
#P connect 25 0 26 0;
#P connect 26 0 28 1;
#P connect 42 0 40 0;
#P connect 11 1 40 0;
#P fasten 49 0 31 1 53 210 180 210;
#P fasten 35 0 31 1 222 240 189 240 189 210 180 210;
#P fasten 19 0 31 1 42 647 577 647 577 210 180 210;
#P fasten 33 0 31 1 200 240 189 240 189 210 180 210;
#P fasten 28 1 31 1 140 647 577 647 577 210 180 210;
#P connect 34 0 32 1;
#P fasten 24 0 23 0 196 291 208 291 208 270 217 270;
#P fasten 31 0 23 1 140 264 236 264;
#P connect 52 0 53 0;
#P connect 50 0 51 0;
#P fasten 23 0 22 0 217 294 245 294 245 271 256 271;
#P connect 54 0 55 0;
#P connect 55 0 56 0;
#P fasten 37 0 42 1 446 281 354 281;
#P connect 11 2 39 0;
#P connect 48 0 39 0;
#P fasten 43 0 37 0 506 252 446 252;
#P connect 36 0 37 0;
#P connect 37 0 38 0;
#P fasten 37 1 44 0 543 282 613 282 613 156 506 156;
#P fasten 47 0 44 0 480 185 495 185 495 161 506 161;
#P connect 46 0 44 0;
#P connect 44 0 45 0;
#P connect 45 0 43 0;
#P fasten 37 0 48 2 446 281 514 281;
#P pop;

#24224
Feb 2, 2006 at 12:50am

Here’s how I’ve been doing it. Generally speaking, I give all of my
gl objects the @automatic 0 attribute. Going into the jit.gl.render
object, I have a t b b erase. The middle bang is for rendering.
After the scene is drawn, I send a bang to the jit.gl.sketch object
and send it the command “glreadpixels mat_name 0 0 width height”. I’m
a bit lazy, so I send it on every bang, but this is redundant. Just
afterward, I send a bang to the matrix which holds the rendered pixels
and pipe that into a jit.qt.record. The outlet of the record has a
delay on it to avoid feedback problems and a gate. THe gate
allows/disallows a new frame to be rendered.
If possible, I’d like to remove the delay and replace it with
something else that will immediately send a bang but still avoid
scheduler overflow.

wes

HEre’s the patch:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 422 30 90 196617 < = start recording;
#P newex 506 225 20 196617 t b;
#P newex 403 49 76 196617 s renderFrame;
#P button 403 30 15 0;
#P message 362 156 143 196617 write 15. mjpega normal 600;
#P newex 506 97 76 196617 r recordFrame;
#P newex 15 174 76 196617 s recordFrame;
#P toggle 439 217 48 0;
#P newex 487 270 29 196617 gate;
#P newex 487 291 76 196617 s renderFrame;
#P newex 506 249 43 196617 delay 2;
#P user jit.pwindow 616 202 82 62 0 1 0 0 1 0;
#P newex 506 138 27 196617 t b l;
#P newex 506 179 159 196617 jit.matrix pixies 4 char 320 240;
#P message 506 118 155 196617 glreadpixels pixies 0 0 320 240;
#P newex 523 158 82 196617 jit.gl.sketch rec;
#P newex 506 204 108 196617 jit.qt.record 320 240;
#P window linecount 2;
#P newex 15 278 389 196617 jit.gl.gridshape rec @shape cube @scale 1.2
1.2 1.2 @blend_enable 1 @depth_enable 0 @lighting_enable 1 @color 0.2
0 0.8 0.6 @smooth_shading 1 @automatic 0;
#P window linecount 1;
#P newex 15 201 72 196617 r drawSphere;
#P newex 15 257 62 196617 r drawCube;
#P window linecount 2;
#P newex 15 222 346 196617 jit.gl.gridshape rec @shape sphere
@blend_enable 1 @depth_enable 0 @lighting_enable 1 @color 0.8 0 0.2
0.7 @smooth_shading 1 @automatic 0;
#P window linecount 1;
#P newex 14 95 76 196617 r renderFrame;
#N vpatcher 20 74 195 202;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 13 70 62 196617 s drawCube;
#P window linecount 0;
#P newex 89 70 72 196617 s drawSphere;
#P newex 33 48 66 196617 t draw draw;
#P inlet 33 28 15 0;
#P fasten 1 0 3 0 38 67 18 67;
#P connect 0 0 1 0;
#P connect 1 1 2 0;
#P pop;
#P newobj 117 152 75 196617 p RenderOrder;
#B color 5;
#P toggle 198 60 15 0;
#P message 198 80 68 196617 fullscreen $1;
#N vpatcher 30 89 166 253;
#P window setfont “Sans Serif” 9.;
#P newex 50 71 35 196617 sel 27;
#P newex 50 50 40 196617 key;
#P outlet 50 93 15 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P pop;
#P newobj 198 40 33 196617 p Esc;
#P newex 198 98 148 196617 jit.window rec @depthbuffer 1;
#P message 159 98 34 196617 reset;
#P newex 159 118 256 196617 jit.gl.handle rec @inherit_transform 1
@auto_rotate 1;
#P toggle 93 76 15 0;
#P newex 93 95 57 196617 qmetro 60;
#P newex 93 118 58 196617 t b b erase;
#P newex 93 174 154 196617 jit.gl.render rec @camera 0 0 4;
#P window linecount 2;
#P comment 442 191 37 196617 enable record;
#P connect 21 1 18 0;
#P connect 19 0 21 0;
#P connect 21 0 20 0;
#P fasten 2 0 27 0 98 159 20 159;
#P connect 15 0 13 0;
#P connect 14 0 16 0;
#P connect 4 0 3 0;
#P connect 3 0 2 0;
#P fasten 12 0 2 0 19 115 98 115;
#P fasten 2 0 1 0 98 157 98 157;
#P fasten 2 2 1 0 146 146 98 146;
#P fasten 5 0 1 0 164 146 98 146;
#P fasten 2 1 11 0 122 146 122 146;
#P connect 6 0 5 0;
#P connect 8 0 10 0;
#P connect 10 0 9 0;
#P connect 9 0 7 0;
#P connect 30 0 31 0;
#P fasten 26 0 25 0 444 267 492 267;
#P connect 25 0 24 0;
#P connect 28 0 19 0;
#P fasten 29 0 20 0 367 174 511 174;
#P connect 20 0 17 0;
#P connect 17 0 32 0;
#P connect 32 0 23 0;
#P connect 23 0 25 1;
#P fasten 20 0 22 0 511 199 622 199;
#P window clipboard copycount 34;

#69706
Feb 2, 2006 at 1:10am

Any strategies for dealing with jit.gl.handle when recording ‘non’
realtime?

ie: in your patch, running it in realtime and manipulating
jit.gl.handle results in a camera rotation. turning off the qmetro
and banging manually results in unsteady rotations (jit.handle is
still rotating behind the scenes, the render context isnt being
updated).

any ideas on how to deal with this, as I use a jit.gl.handle
abstraction in my patches to control many gl objects, and non rt
rendering would be fun to play with.

thanks,

v a d e //

http://www.vade.info
abstrakt.vade.info

#69707
Feb 2, 2006 at 1:34am

Good question. I’m not entirely sure it’s possible if @auto_rotate is
enabled. I tend to calculate my own rotations, so I’ve not had to
deal with this.

wes

#69708
Feb 2, 2006 at 2:30am

I usually use a javascript to deal with this, that rotates objects a
certain amount each frame.
Although, it would be cool if jit.gl.handle had an @automatic attribute
also!

-ev

#69709
Feb 2, 2006 at 2:33am

That’s what I was doing before, but the stack overflows and jerkiness
were a real problem. Thus, using the onebang object to gate the main
qmetro, so you can both use the patch for realtime feedback, and then
set the qmetro speed to something very low and render to disk as fast
as possible.

-ev

#69710
Feb 2, 2006 at 2:34am

you sir, know how to read a girls mind. exactly what I was hinting at.

v a d e //

http://www.vade.info
abstrakt.vade.info

#69711
Feb 2, 2006 at 7:51pm

Some good ideas in this thread. I spent a lot of time this winter
working on a recording patch. The interest here is prompting me to
clean it up for sharing earlier than I was planning to, like in a
couple of days, so please stay tuned.

-Randy

#69712
Feb 8, 2006 at 11:37am

this text seems to be incomplete.
can you please post this again.

best,
david

#69713

You must be logged in to reply to this topic.