Forums > Jitter

Trouble with transparency

October 4, 2009 | 7:05 pm

Hello all,

I’m not new to Max but quite new to Jitter, and this current problem has me going batty.

The attached patch attempts to load a map in layer 2 and overlay a set of icons in layer 1 of jit.gl.videoplane, loading the images via a set of jit.qt.movie objects.

The trouble arises when I try to combine the icons, which are .png and contain transparency, into layer 1 of jit.gl.videoplane. As they have to be scaled to proper size using dstrect into jit.qt.movie, the transparency is only applied to the specified area; the rest of jit.pwindow remains black.

Since I will be using a good number of icons, the [jit.op +] method may not be optimal either.

Does anyone know how to ensure layer 1 remains transparent wherever the dstrect does not apply?

Many many thanks,

– Pasted Max Patch, click to expand. –

October 13, 2009 | 6:22 am

There are a number of ways to do it depending on the final effect you want. In your current patch, you could set @blend_mode 6 1 for additive blending. Anything black will seem to be transparent.

wes


October 15, 2009 | 7:19 pm

Wesley,

Thanks for the tip, however the blend_mode you propose yields semi transparent icons. Also, possibly due to the jit.op setup, the ‘frontmost’ icon’s position ends up defining the only visible space for the other icons – they disappear when they are moved outside of that zone.

Still stumped…

Here’s an updated patch with ability to change blend_mode, and a sample icon attached to see things in context…

– Pasted Max Patch, click to expand. –

October 15, 2009 | 7:49 pm

if the dstrect attributes of the qt.movies are set *after* the icon image is read in and banged out once, then the patch works as expected.
index.php?t=getfile&id=3463&private=0

if you need a more flexible solution, you might want to do your image scaling/positioning with gl.videoplanes or gl.meshes


October 15, 2009 | 10:01 pm

Hello,
Here is a patch that uses OpenGL for the alpha blending. This is a more robust and efficient way to do what you are doing, and actually respects the image transparency.

Andrew B.

– Pasted Max Patch, click to expand. –

October 16, 2009 | 7:24 pm

Thank you Andrew and Rob, both good points and solutions. But if I have, say, 10 icons to place on the map, is there no more efficient solution than to create a gl.videoplane layer for each and every one? Is there a kind of video equivalent to poly~?

Also, I’m noticing that when the icon is scaled to around 0.1, it gets grainy. Is this an interpolation issue, or am I hitting some sort of limit on screen resolution?

Thanks,


October 17, 2009 | 6:06 pm

a few different options available to solve this problem.

first off, yes there is a poly~ object for video. it’s called poly~. you can encapsulate anything you wish in a poly~ object. search the jitter forum for several different examples.

second, if you are using the same image texture, you don’t necessarily have to use a separate videoplane for each icon. you can simply tell the videoplane to redraw itself in several different positions, each draw call. check out andrew’s Dancing Sprites recipe 06:
http://www.cycling74.com/story/2006/2/6/114353/4118

last, gl.mesh might be the most efficient way to go, but also a bit trickier to learn. once again andrew illuminates. check out recipe 36 and 37:
http://www.cycling74.com/story/2006/2/17/153427/406


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