Forums > Javascript

Issue with jit.gl.imageunit and a texture using JS

February 25, 2007 | 4:42 am

Hello List,

Using Javascript I am trying to have an jit.gl.imageunit process a jit.gl.texture with, e.g., ‘bloom’-effect, but it does not seems to work, resulting in an empty window. There seems to be something wrong with the connection between the texture and the imageunit, because the imageunit itself can easily generate the ‘sunbeams’ as can be seen in the example.

I assume(d) imageunits and slabs work the same concerning how textures go in and out, or am I wrong? When I let a jit.gl.slab do the work in the same setting, it’s all working properly. Since I’d like to use some imageunits-effects, I would really want to know which ingredient I am missing here.

First I tried it in Lua, but JS is giving me the same result.

Some advice would be really great.

Best,
Erik

Running the latest version of Jitter on a Mac Book Pro (10.4.8)

The script has an imageunit and a slab, the slab is disabled just as the imageunit’s ‘sunbeams’.

the js:

// save as: imageunit_js.js
autowatch = 1;

jtex = new JitterObject("jit.gl.texture","imageunit_js");
jtex.file = "colorbars.pict";

jwobbly = new JitterObject("jit.gl.imageunit","imageunit_js");

// enable one of those fx
//jwobbly.fx = "sunbeams" // this one works fine, since it doesnt need a texture
jwobbly.fx = "bloom" // this one needs a texture and does not work

// disable the imageunit above and enable the slab here
// jwobbly = new JitterObject("jit.gl.slab","imageunit_js");
// jwobbly.file = "td.wobble.jxs"

jwobbly.texture = jtex.name;
jwobbly.verbose = 1;

jvplane = new JitterObject("jit.gl.videoplane","imageunit_js");
jvplane.automatic = 0;
jvplane.transform_reset = 2;
jvplane.texture = jwobbly.out_name; //show the output of wobbly

function draw(){
jwobbly.draw();
jvplane.draw();
//post("drawn")
}

the patch:

max v2;
#N vpatcher 20 74 620 474;
#P window setfont "Sans Serif" 10.;
#P message 67 212 34 196618 draw;
#P window setfont "Sans Serif" 9.;
#P newex 149 234 92 196617 js imageunit_js.js;
#P toggle 130 78 15 0;
#P message 130 98 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 130 58 33 196617 p Esc;
#P newex 130 116 191 196617 jit.window imageunit_js @depthbuffer 1;
#P message 91 116 34 196617 reset;
#P newex 91 137 226 196617 jit.gl.handle imageunit_js @inherit_transform 1;
#P toggle 28 97 15 0;
#P newex 28 116 57 196617 qmetro 30;
#P newex 28 137 50 196617 t b erase;
#P newex 28 162 126 196617 jit.gl.render imageunit_js;
#P connect 3 0 2 0;
#P connect 2 0 1 0;
#P fasten 1 1 0 0 73 158 33 158;
#P fasten 4 0 0 0 96 158 33 158;
#P fasten 1 0 0 0 33 158 33 158;
#P connect 1 0 11 0;
#P connect 5 0 4 0;
#P connect 7 0 9 0;
#P connect 9 0 8 0;
#P connect 8 0 6 0;
#P connect 11 0 10 0;
#P pop;


February 25, 2007 | 4:57 am

Hi Erik,
I agree that what you did should work. However, there seems to be a
disconnect between the jit.gl.imageunit @texture attribute and
internal operations. You can instead use the jit.gl.imageunit
jit_gl_texture method and things work just fine. The same will be
true in Lua since this has something to do with jit.gl.imageunit and
not JS or Lua per se. Here’s a modified script that does this:

wes

editfontsize = 13
// save as: imageunit_js.js
autowatch = 1;

jtex = new JitterObject("jit.gl.texture","imageunit_js");
jtex.file = "colorbars.pict";

jwobbly = new JitterObject("jit.gl.imageunit","imageunit_js");
//
// enable one of those fx
//jwobbly.fx = "sunbeams" // this one works fine, since it doesnt need a texture
jwobbly.fx = "bloom" // this one needs a texture and does not work

// disable the imageunit above and enable the slab here
// jwobbly = new JitterObject("jit.gl.slab","imageunit_js");
// jwobbly.file = "td.wobble.jxs"

//jwobbly.texture = jtex.name;
jwobbly.jit_gl_texture(jtex.name);
jwobbly.verbose = 1;

jvplane = new JitterObject("jit.gl.videoplane","imageunit_js");
jvplane.automatic = 0;
jvplane.transform_reset = 2;
jvplane.texture = jwobbly.out_name; //show the output of wobbly

function draw()
{
jwobbly.draw();
jvplane.draw();
//post("drawn")
}


February 25, 2007 | 5:24 pm

Thank you, Wesley! That looks like a very obvious solution.. which I just couldnt see at 5 a.m.. I and might need to take a closer look at some fundamentals here.

Many thanks!
Erik


Viewing 3 posts - 1 through 3 (of 3 total)