time-delayed textures? 3d texture buffers?


    Jun 06 2007 | 10:03 pm
    is there a way to set up a video delay entirely as a buffer of textures? like using this technique (below), but entirely on the GPU?

    • Jun 06 2007 | 10:15 pm
      yup. wesley smith posted a jit.gl.lua code to do 3D texture buffering earlier in the year.
      you can do it in JS or java as well. :)
      On Jun 6, 2007, at 6:03 PM, joshua goldberg wrote:
      > is there a way to set up a video delay entirely as a buffer of > textures? like using this technique (below), but entirely on the GPU? > > #P window setfont "Sans Serif" 9.; > #P window linecount 1; > #P newex 340 302 40 196617 % 300; > #P newex 340 280 27 196617 -; > #P newex 340 258 37 196617 + 300; > #P outlet 303 410 15 0; > #P inlet 422 134 15 0; > #P inlet 302 133 15 0; > #P newex 303 372 258 196617 jit.matrix 4 char 320 240 @usesrcdim 1 > @adapt 0; > #P message 315 336 225 196617 srcdimstart 0 0 $1 , srcdimend 319 > 239 $1; > #N counter 0 0 299; > #X flags 0 0; > #P newobj 321 189 83 196617 counter 0 0 299; > #P message 331 212 225 196617 dstdimstart 0 0 $1 , dstdimend 319 > 239 $1; > #P newex 302 233 262 196617 jit.matrix 4 char 320 240 300 > @usedstdim 1 @interp 0; > #P newex 302 161 29 196617 t l b; > #P comment 353 161 30 196617 Delay; > #B color 10; > #P comment 321 410 69 196617 Delayed Video; > #P window linecount 2; > #P comment 319 133 52 196617 Input Video; > #P comment 440 133 64 196617 Delay Amount; > #P connect 11 0 14 1; > #P connect 14 0 15 0; > #P connect 13 0 14 0; > #P connect 7 0 6 0; > #P connect 7 0 13 0; > #P connect 4 1 7 0; > #P connect 15 0 8 0; > #P connect 9 0 12 0; > #P connect 5 0 9 0; > #P lcolor 13; > #P connect 8 0 9 0; > #P connect 6 0 5 0; > #P connect 4 0 5 0; > #P lcolor 13; > #P connect 10 0 4 0; > #P window clipboard copycount 16; > >
      v a d e //
      www.vade.info abstrakt.vade.info
    • Jun 06 2007 | 10:28 pm
      Yes, This is possible, but best done using JavaScript (or Lua if you are so inclined) and will be severely limited if you don't have enough texture memory.
      Here is an example of doing a JS texture array
      AB
    • Jun 06 2007 | 11:49 pm
      awesome, thank you, this does it, enclosed is a patch which does not encapsulate the render/window/vidplane in the js, for flexibility and feedback. many thanks.
      On Jun 6, 2007, at 6:28 PM, andrew benson wrote:
      > Yes, > This is possible, but best done using JavaScript (or Lua if you are so > inclined) and will be severely limited if you don't have enough > texture > memory. > > Here is an example of doing a JS texture array > > AB >
    • Jun 07 2007 | 12:22 am
      Andrew & Joshua -
      Excellent examples.
      but to make Andrew's work, you have to add the line
      var outer = 0;
      and to make joshua's work, you have change the trigger object under the counter to
      t b i
      (assuming you're each not throwing in a single typo to keep us on our toes)
    • Jun 07 2007 | 12:37 am
      no sir. it's 't i i' because the out frame needs an offset. let it run, you'll see.
      On Jun 6, 2007, at 8:22 PM, Perry Hoberman wrote:
      > > Andrew & Joshua - > > Excellent examples. > > but to make Andrew's work, you have to add the line > > var outer = 0; > > and to make joshua's work, you have change the trigger object under > the counter to > > t b i > > (assuming you're each not throwing in a single typo to keep us on > our toes) >
    • Jun 07 2007 | 2:33 am
      however the version you posted had 't b b'
      at least when I opened it
      it did some nice things with 't b i'
      it's even better with 't i i'
    • Jun 07 2007 | 5:04 am
      wow. oops, thought i sent the newer version. whoops.
      On Jun 6, 2007, at 10:33 PM, Perry Hoberman wrote:
      > > however the version you posted had 't b b' > > at the least when I opened it > > it did some nice things with 't b i' > > it's even better with 't i i' >
    • Jun 08 2007 | 9:34 am
      In a related topic (gl texture delay), I sent a question last week that appeared blank in the forums, so here it goes again:
      I've tried to adapt the jsglvideotrail-example present in examplesjitter-examplesjavascriptrender to accept a jit.gl.texture object instead of a matrix. I added a jit.gl.texture object before the matrix enters the js code and, in the js code, I changed the 2 references to "jit_matrix" with "jit_gl_texture".
      The patch kind of works. It outputs an image, at least. Here's the catch: while in the original matrix mode, each videoplane generated has a different texture (like a "time machine"), in the modified gl.texture version, the texture is the same for all planes.
      The question is: is this a GL limitation of some sort? Or maybe the change to the js code needs to be a little more extreme? Is this possible at all? Thank you in advance to any Javascript / OpenGL gurus out there...
    • Jun 08 2007 | 11:31 am
      Joshua and Andrew - This sounds really good, can you paste the js and patch in the thread for thos viewing it through the forum? Many thanks, -Nadav
    • Jun 08 2007 | 4:18 pm
      Pedro, The reason that this doesn't work as you expect is due to the difference between the way that jit_gl_texture and jit_matrix function. Videoplane copies an incoming matrix to its own internal instance of jit_gl_texture, so essentially each copy of jit.gl.videoplane represents a different texture. On the other hand, connecting a jit_gl_texture to jit.gl.videoplane simply binds the given texture to the videoplane (over-riding the internal texture). Since there is only one texture getting bound to all of your videoplanes, they are all going to look exactly the same (they are all the same texture). You will need to provide some mechanism in your JS for copying the incoming texture to an array of textures or something along those lines.
      AB
    • Jun 08 2007 | 8:12 pm
      >Here is an example of doing a JS texture array
      >AB
      Please light me about the forum : where's or how to get the example ? no example in the message ...
    • Jun 08 2007 | 11:21 pm
      Here is the JS code:
      //script for texture array management, much like jit.matrixset // create our openGL context stuff var window = new JitterObject("jit.window","odo"); window.size = [640,480]; var render = new JitterObject("jit.gl.render","odo");
      //create our variables var bank;//this will hold the array of textures var ind = 0;//this is the index to write into var vp; //videoplane array var vpt = new Array();//texture assignments for videoplanes
      //for the JS object inlets = 1; outlets=1;
      //initialize count(20); planes();
      function blend(x,y) { for(i=0;i { vp[i].blend_mode = [x,y]; } }
      function fade(x) { for(i=0;i { vp[i].color = [1.,1.,1.,x]; } }
      function count(c) { bank = null; //remove any leftovers
      bank = new Array();//create an empty array
      if (c c = 1; vcount = c;
      //fill the array with jit.gl.texture objects for (var i=0;i bank[i] = new JitterObject("jit.gl.texture","odo"); bank[i].adapt = 1; } }
      //this handles incoming jit.matrix function jit_matrix(g) { bank[ind].jit_matrix(g); }
      function index(x) { if (x if(x>19) x= 19; ind = x; }
      function out(x) { if(x if(x>19) x= 19; outer = x; }
      function planes() { vp= null;
      vp = new Array(); for(x=0;x { vp[x]=new JitterObject("jit.gl.videoplane","odo"); vp[x].blend_enable= 1; vp[x].dim = [2,2]; vp[x].displaylist = 1; vp[x].transform_reset = 2; //vp[x].scale= [0.2,1.,1.]; //vp[x].tex_scale_x = 5.; //vp[x].tex_offset_x = -x*0.2; //vp[x].tex_offset_y = 0.; //vp[x].tex_scale_y = 1.; //vp[x].position = [x*0.4-0.8,,0.]; vpt[x] = x; } }
      //this handles the drawing of our OpenGL context function bang() { render.erase();//clear the last frame //vp.jit_gl_texture(bank[outer].name);//bind the appropriate texture to videoplane for(i=0;i vpt[i]++; if (vpt[i]>19) vpt[i]=0; vp[i].jit_gl_texture(bank[(vpt[i])].name); vp[i].draw(); } //vp.draw();//draw videoplane outlet(0,"bang");//send a bang for the fpsgui for benchmarking render.drawclients();//draw the openGL contents into the framebuffer render.swap();//move the contents of framebuffer onto screen }
    • Jun 08 2007 | 11:25 pm
      And the patch I sent with it.
    • Jun 08 2007 | 11:44 pm
      Here's a link to a texture delay line I made about a month ago: http://www.mat.ucsb.edu/~whsmith/TextureDelay.zip
      It written as a JS class so you can have multiple delay lines going in one script. It can also take data form a texture or a matrix. If you modify the patch, make sure to change this line
      var texBuff = new TexBuffer("bump", [1024, 768], 10);
      where bump is the context name
      to match the name of the renderContext to match what jit.gl.render is called (I guess I could make this an argument to the js object).
      enjoy, wes
    • Jun 11 2007 | 2:02 pm
      hi all. here are my examples.
      first, the patch:
      then save this as phoenix.texbank.js :
      //script for texture array management, much like jit.matrixset
      //create our variables var bank;//this will hold the array of textures var ind = 0;//this is the index to write into
      //for the JS object inlets = 1; outlets=1;
      //initialize count(50);
      function count(c) { bank = null; //remove any leftovers bank = new Array();//create an empty array
      if (c c = 1; vcount = c;
      //fill the array with jit.gl.texture objects for (var i=0;i bank[i] = new JitterObject("jit.gl.texture","bork"); bank[i].adapt = 1; bank[i].colormode = "uyvy"; } }
      //this handles incoming jit.matrix function jit_gl_texture(g) { bank[ind].jit_gl_texture(g); }
      function index(x) { if (x if(x>49) x= 49; ind = x; }
      function out(x) { if(x if(x>49) x= 49; outer = x; }
      //this sends the correct texture out function bang() { outlet(0,"jit_gl_texture",bank[outer].name);
      }
      On Jun 8, 2007, at 7:31 AM, Nadav Assor wrote:
      > > Joshua and Andrew - This sounds really good, can you paste the js > and patch in the thread for thos viewing it through the forum? > Many thanks, > -Nadav >
    • Dec 04 2015 | 12:55 pm
      hi, i know it's an old thread, but i was interested and tried your approach.
      unfortunately i got this error in the max window:
      js: phoenix.texbank.js: Javascript SyntaxError: missing ; after for-loop condition, line 25 js: source line: bank[i] = new JitterObject("jit.gl.texture","bork");
      unfortunately my javascript knowledge is non-existing, so no use in fumbling around the code myself
      any ideas ? would be great if this could work !
      regards
      oliver
    • Dec 04 2015 | 6:22 pm
      please zip up your JS file and the patch and attach here, and i'll take a look
    • Dec 04 2015 | 10:03 pm
      here you go !
      attached is the js file that i got from this thread (originally from benson and modified by goldberg)
      thanks for joining in, rob !
    • Dec 07 2015 | 5:51 pm
      as the error message indicated, you had an error at line 24. looks like the line got chopped off at some point. fixed below.
      //script for texture array management, much like jit.matrixset
      
      //create our variables
      var bank;//this will hold the array of textures
      var ind = 0;//this is the index to write into
      
      //for the JS object
      inlets = 1;
      outlets=1;
      
      //initialize
      count(50);
      
      function count(c)
      {
      	bank = null; //remove any leftovers
      	bank = new Array();//create an empty array
      
      	if (c49) x= 49;
      	ind = x;
      }
      
      function out(x)
      {
      	if(x49) x= 49;
      	outer = x;
      }
      
      //this sends the correct texture out
      function bang()
      {
      	outlet(0,"jit_gl_texture",bank[outer].name);
      
      }
      
      
    • Dec 07 2015 | 9:40 pm
      hi, rob !
      thanx-a-gazillion ! that did it !
      BTW: i really think this very useful trick for OpenGL texture-based delay writing should be made more public and easier to find. Probably should be included in js examples in an official MAX release ! I think it's essential !
      best
      oliver
    • Mar 25 2016 | 6:13 pm
      Hi, i modified patch and js files for teaching porpuses, implementing some things and simplifying some other... cheers S
    • Mar 25 2016 | 7:39 pm
      Getting errors with the patch:
    • Mar 26 2016 | 5:07 pm
      i see, MAX 32 bit does not like it! (i am using 64... no problems there)
    • Mar 26 2016 | 5:12 pm
      I run Max in 64 bit. The previous patch/js file worked fine for me. What version of Max are you using?
    • Mar 26 2016 | 5:15 pm
      7.2.1
    • Mar 26 2016 | 5:33 pm
      still can't reproduce with the 64 bit... i tried: max app in low/hi res (i have a retina macbook), changing max engine qt/avf, changing engine only for the grab... everything works... but i get the same errors when using 32 bit... i'd like to figure this out too...
    • Mar 26 2016 | 5:41 pm
      ok seems that there is a problem with the amount of frame you can store as texture (me and you probably have different GPUs...) if you decrease the amount of frame to store in the js object (and also the counter and the random to store and output...) it works! i'll upload new patch and new js...
    • Mar 26 2016 | 5:47 pm
    • Mar 26 2016 | 5:49 pm
      and the js file... with this you can change render context (as js argument) without changing the script