slabs and planes in js

Aug 15, 2006 at 6:45pm

slabs and planes in js

i’m attempting to use a two-inlet jit.gl.slab and a jit.gl.videoplane for compositing within js. i’m not quite sure how to go about this nor can i find any documentation of how i might begin. generally, this is what i have so far:

—-
var frameA = new JitterMatrix(4,”char”,vdim[0],vdim[1]);
var frameB = new JitterMatrix(4,”char”,vdim[0],vdim[1]);
var outslab = new JitterObject(“jit.gl.slab”,”compositor”);
outslab.inputs = 2;
outslab.colormode = “uyvy”;
outslab.file = “co.normal.jxs”;
outslab.param = ["amount",0.];
var outplane = new JitterObject(“jit.gl.videoplane”,”compositor”);
outplane.automatic = 0;
outplane.blend_enable = 1;
outplane.depth_enable = 0;
outplane.scale = [1.1, 0.833, 1.];
outplane.colormode = “uyvy”;
outplane.color = [1., 1., 1., 1.];

//** i have no idea if this part is correct, just guessing

outslab.tex0(frameA.name);
outslab.tex1(frameB.name);
outslab.draw();

outplane.jit_texture(**not sure what to put in here**);
outplane.draw();

—-

i can post a more complete and semi-functional example with patch if this isn’t enough. also, to set a shader param from within js, is it correct to use something like this (basically my crossfade value):

outslab.param = ["amount",crossfadeamount];

any suggestions or directions towards documentation are much appreciated. this is my first real project using js (exciting!), so thanks for your help!

all my best,
jonathan

#27170
Aug 15, 2006 at 7:03pm

I haven’t tested this yet, but what should work for input is setting
the activeinput attribute and then calling the jit_matrix or
jit_gl_texture message accordingly, and for output, you can grab the
texture name from the capture attribute. i.e.

outslab.activeinput = 1;
outslab.jit_matrix(frameB.name);
outslab.activeinput = 0;
outslab.jit_matrix(frameA.name);
outslab.draw();

outplane.jit_gl_texture(outslab.capture); //could alternately just
set the outplane’s texture attribute.

Secondly, param is a method not an attribute (it just is permitted to
use attribute syntax via the “attrsafe” flag):

outslab.param(“amount”,crossfadeamount);

Lastly, you don’t need to use uyvy except for the first point of
input, though it will be harmless.

Let us know if you’re able to get it working with the above.

Thanks,
Joshua

On Aug 15, 2006, at 11:45 AM, jonathan lee marcus wrote:

>
> i’m attempting to use a two-inlet jit.gl.slab and a
> jit.gl.videoplane for compositing within js. i’m not quite sure how
> to go about this nor can i find any documentation of how i might
> begin. generally, this is what i have so far:
>
> —-
> var frameA = new JitterMatrix(4,”char”,vdim[0],vdim[1]);
> var frameB = new JitterMatrix(4,”char”,vdim[0],vdim[1]);
> var outslab = new JitterObject(“jit.gl.slab”,”compositor”);
> outslab.inputs = 2;
> outslab.colormode = “uyvy”;
> outslab.file = “co.normal.jxs”;
> outslab.param = ["amount",0.];
> var outplane = new JitterObject(“jit.gl.videoplane”,”compositor”);
> outplane.automatic = 0;
> outplane.blend_enable = 1;
> outplane.depth_enable = 0;
> outplane.scale = [1.1, 0.833, 1.];
> outplane.colormode = “uyvy”;
> outplane.color = [1., 1., 1., 1.];
>
> …
>
> //** i have no idea if this part is correct, just guessing
>
> outslab.tex0(frameA.name);
> outslab.tex1(frameB.name);
> outslab.draw();
>
> outplane.jit_texture(**not sure what to put in here**);
> outplane.draw();
> …
> —-
>
> i can post a more complete and semi-functional example with patch
> if this isn’t enough. also, to set a shader param from within js,
> is it correct to use something like this (basically my crossfade
> value):
>
> outslab.param = ["amount",crossfadeamount];
>
> any suggestions or directions towards documentation are much
> appreciated. this is my first real project using js (exciting!), so
> thanks for your help!
>
> all my best,
> jonathan
>
>

#81993
Aug 15, 2006 at 8:31pm

thanks joshua!

for a bit more context, i’m trying to implement something similar to buffers/sequence from softvns. i have a cpu-only version working perfectly, but now i’m trying to push as much onto the gpu as possible.

two issues:

1) at first this code:
outslab.param(“amount”,tweenfade);

was causing these errors once per frame/bang:
*error: js: jsbuffer.js: Javascript TypeError: outslab.param is not a function, line 140
*error: js: error calling function jit_matrix

commenting it out stopped the errors. but then un-commenting it did not bring the errors back. not sure what happened there. this isn’t really an issue anymore.

2) i can’t get anyhting other than pure black to show up. even using this simplified code:

outslab.jit_matrix(framearray[outframeA].name);
outslab.draw();
outplane.jit_gl_texture(outslab.capture);
outplane.draw();

let alone the activeinput switching and fading with co.normal.jxs. been trying to strip it down and debug it, but no luck. also tried outplane.texture = outslab.capture;

thanks again

best,
jonathan

#81994
Aug 15, 2006 at 9:06pm

On Aug 15, 2006, at 1:31 PM, jonathan lee marcus wrote:

> for a bit more context, i’m trying to implement something similar
> to buffers/sequence from softvns. i have a cpu-only version working
> perfectly, but now i’m trying to push as much onto the gpu as
> possible.

If you want to use the gpu even further, you should use an array of
jit_gl_textures.

> two issues:
>
> 1) at first this code:
> outslab.param(“amount”,tweenfade);
>
> was causing these errors once per frame/bang:
> *error: js: jsbuffer.js: Javascript TypeError: outslab.param is not
> a function, line 140
> *error: js: error calling function jit_matrix
>
> commenting it out stopped the errors. but then un-commenting it did
> not bring the errors back. not sure what happened there. this isn’t
> really an issue anymore.

Likely because somewhere you had set this function property to an array.

> 2) i can’t get anyhting other than pure black to show up. even
> using this simplified code:
>
> outslab.jit_matrix(framearray[outframeA].name);
> outslab.draw();
> outplane.jit_gl_texture(outslab.capture);
> outplane.draw();

Sounds like perhaps you still have a jit.gl.videoplane which hasn’t
been garbage collected.

I’ve attached a simple test patch which demonstrates this working
(never tested before AFAIK, so this was a good exercise). For
jit_gl_texture just call outslab’s jit_gl_texture method instead of
jit_matrix, and send your input frames to he corresponding
jit.gl.texture object via jit.gl.texture’s jit_matrix method.

Let me know if you have further troubles.

-Joshua

PATCH:

#P window setfont “Sans Serif” 9.;
#P flonum 157 156 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P message 156 179 57 196617 amount $1;
#P message 251 93 83 196617 read dishes.mov;
#P message 157 94 80 196617 read dozer.mov;
#P toggle 30 30 15 0;
#P newex 29 55 57 196617 qmetro 10;
#P newex 29 78 58 196617 t b b erase;
#P newex 134 286 75 196617 jit.window foo;
#P newex 36 283 82 196617 jit.gl.render foo;
#P newex 222 130 63 196617 jit.qt.movie;
#P newex 142 129 63 196617 jit.qt.movie;
#P newex 142 213 79 196617 js jsslabtest.js;
#P connect 7 0 6 0;
#P connect 6 0 5 0;
#P connect 5 0 3 0;
#P connect 5 2 3 0;
#P connect 8 0 1 0;
#P connect 5 1 1 0;
#P connect 10 0 0 0;
#P connect 1 0 0 0;
#P connect 11 0 10 0;
#P connect 2 0 0 1;
#P connect 9 0 2 0;
#P connect 5 1 2 0;
#P window clipboard copycount 12;

JS File (jsslabtest.js):

inlets = 2;

var outslab = null; // good policy while saving/recompiling so that
original slab will be garbage collected
outslab = new JitterObject(“jit.gl.slab”,”foo”);
outslab.file = “co.normal.jxs”;
outslab.param(“amount”,0.5);

var outplane = null;
outplane = new JitterObject(“jit.gl.videoplane”,”foo”);
outplane.automatic = 0;
outplane.transform_reset = 2;

function amount(a)
{
outslab.param(“amount”,a);
}

function jit_matrix(m)
{
outslab.activeinput = inlet;
outslab.jit_matrix(m);
if (inlet==0) {
outslab.draw();
outplane.texture = outslab.capture;
outplane.draw();
}
}

#81995
Aug 15, 2006 at 9:52pm

your patch works in jit 1.6 but not in jit 1.5.

this being a multi-person project, i’d been holding off on having everyone upgrade to UB. looks like i’ll be doing that sooner than expected :)

just testing my patch with you technique in jit 1.6 and it works like a dream. thanks for all your help!

best,
jonathan

#81996
May 22, 2008 at 7:45am

Ahhh, thank you so much for this code.. it’s exactly what I needed. However, moving a bit further ahead I am stuck:

Right now I’m compositing an array of these effect chains with multiple videoplanes stacked on one another. I change the opacity of the videoplane to blend the clip with the others, however this is not quite the effect I want. Before I was using a jit.gl.slab Max object with “43j-fourwaymix.jxs” from the tutorial. I’m trying to get it to work in Javascript using the mixer and just one videoplane, but I can’t figure out how to input FOUR textures into a slab object – it only has the one .texture property.

I tried something like this:

//this code isn’t quite complete. it’s riffing off of your example just to give the basic idea…
var GL_CONTEXT = “foo”;

var outplane = null;
outplane = new JitterObject(“jit.gl.videoplane”,GL_CONTEXT);
outplane.automatic = 0;
outplane.transform_reset = 2;

var mixerObj = null;
mixerObj = new JitterObject(“jit.gl.slab”, GL_CONTEXT);
mixerObj.file = “43j-fourwaymix.jxs”;
mixerObj.param(“a”, 1.0); //set first clip to be visible

var outslab = null;
outslab = new JitterObject(“jit.gl.slab”,GL_CONTEXT);
outslab.file = “co.normal.jxs”;
outslab.param(“amount”,0.5);

function jit_matrix(m) {
outslab.activeinput = inlet;
outslab.jit_matrix(m);
outslab.draw();

//use a slab’s texture as the first input to the mixer.
/******this is the part I can’t get to work!******/
mixerObj.param(“tex0″, outslab.capture);

//output mixer to screen
mixerObj.draw();
outplane.texture = mixerObj.capture;
outplane.draw();
}

#81997

You must be logged in to reply to this topic.