GPU & alphablending : how to ?

Feb 2, 2008 at 6:08pm

GPU & alphablending : how to ?

Hello,

the question is in the title.
Is there a shader to do an alphablending with gl objects ?

thank you.

#35626
Feb 2, 2008 at 6:16pm

you dont need shaders to blend alpha, just enable blend_enable 1, and
use a blend_mode which uses alpha. Some cards may require
lighting_enable 1 to be active, if you send a texture to an object
that has alpha components (and you arent uploading it UYVY which
removes the alpha channel), you should see transparency

Unless you are asking something totally different? What do you want to
do?

On Feb 2, 2008, at 1:08 PM, Derrick Giscloux wrote:

>
> Hello,
>
> the question is in the title.
> Is there a shader to do an alphablending with gl objects ?
>
> thank you.

#121632
Feb 2, 2008 at 7:18pm

Thank you for the answer.
I have several problem with a patch and many questions come all in time.
I work on jitter-clone of the quartz composer patching called “light passage” by Zugakousaku (http://www.zugakousaku.com/index.php?ref=project-quartz-jp-quicktime-22_LightPassage).

Perhaps you know it.

My patch works fine, but I can’t achieve the light effect at the bottom of the tunnel. Even with the blend_enable & blend_mode attributes.
The problem is that with blend_enable 1 and the blend modes I tryed, the full image is transparent. I’d like to have transparency only in the black region around the light sphere.
(please look at the file joined).
I presume my photoshop picture file should have an alpha channel set to 0 in the black region and 255 in the light region or something like that. It is why I considered to do that with jit.op and jit.alphablend, but not very sure …

But the main problem is that texture disappears from the plane when I run in fullscreen.
This was evoked in another thread and the @automatic and rendering in proper order proposals aren’t very clear, since tutorial 31 seems not to work as expected.

below pic file of the problem.

#121633
Feb 3, 2008 at 5:16pm

yes it took me a while too to get around it ,
Vade’s tutorials ( http://abstrakt.vade.info/?p=147 ) and Andrew Benson’s receipes have been really helpfull to get some of the openGL magic :)

hope this helps in the meantime :

#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P comment 819 293 267 196617 tweek these for blending yourkeying your black and white image;
#P window linecount 1;
#P newex 584 259 48 196617 loadbang;
#P newex 584 279 206 196617 t 0.01 0.8 0.;
#P toggle 707 363 15 0;
#P flonum 778 303 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 685 303 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 584 302 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 778 323 100 196617 prepend param fade;
#P newex 685 323 91 196617 prepend param tol;
#P newex 584 323 100 196617 prepend param luma;
#P comment 384 64 267 196617 your background;
#P user jit.fpsgui 30 140 60 196617 0;
#P message 30 243 68 196617 fullscreen $1;
#P toggle 30 221 15 0;
#P newex 30 201 35 196617 sel 27;
#P newex 30 181 40 196617 key;
#P flonum 723 363 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 635 384 99 196617 pak color 1. 1. 1. 0.;
#P newex 30 265 160 196617 jit.window obama @size 640 480;
#P newex 284 117 66 196617 t b b b b b;
#P newex 384 364 245 196617 jit.gl.slab obama @file co.lumakey.jxs @automatic 0;
#P message 384 267 102 196617 read countdown.mov;
#P newex 384 404 350 196617 jit.gl.videoplane obama @transform_reset 2 @automatic 0 @blend_enable 1;
#P newex 384 320 155 196617 jit.qt.movie @adapt 1 @unique 1;
#P message 384 79 83 196617 read dishes.mov;
#P newex 384 191 350 196617 jit.gl.videoplane obama @transform_reset 2 @automatic 0 @blend_enable 1;
#P newex 384 157 155 196617 jit.qt.movie @adapt 1 @unique 1;
#P newex 29 120 209 196617 jit.gl.render obama @erase_color 0. 0. 0. 1.;
#P newex 29 90 61 196617 t b b erase;
#P toggle 29 29 15 0;
#P newex 29 57 51 196617 qmetro 2;
#P comment 383 229 267 196617 on top : your mask;
#P connect 29 0 25 0;
#P connect 29 1 26 0;
#P connect 29 2 27 0;
#P connect 30 0 29 0;
#P hidden connect 28 0 15 0;
#P connect 27 0 24 0;
#P connect 26 0 23 0;
#P connect 25 0 22 0;
#P fasten 24 0 11 0 783 352 389 352;
#P fasten 23 0 11 0 690 352 389 352;
#P fasten 22 0 11 0 589 352 389 352;
#P connect 8 0 11 0;
#P connect 12 1 11 0;
#P connect 11 0 9 0;
#P connect 4 0 20 0;
#P fasten 3 1 12 0 59 112 289 112;
#P fasten 14 0 9 0 640 401 389 401;
#P connect 12 0 9 0;
#P connect 5 0 6 0;
#P connect 12 3 6 0;
#P connect 19 0 13 0;
#P connect 18 0 19 0;
#P connect 17 0 18 0;
#P connect 16 0 17 0;
#P connect 12 2 8 0;
#P connect 12 4 5 0;
#P connect 3 2 4 0;
#P connect 3 0 4 0;
#P connect 1 0 3 0;
#P connect 15 0 14 4;
#P connect 10 0 8 0;
#P connect 7 0 5 0;
#P connect 2 0 1 0;
#P window clipboard copycount 32;

#121634
Feb 12, 2013 at 12:17am

i know there is countless threads about this and i read them all but i still do not get it – there is this mysterious co.alphablend.jxs shader but no documentation whatsoever so maybe someone could just show me the way…:
i blend videos with proper alphachannels on videoplanes – that works fine. the only problem is, that AFTER the blending i want to apply some effects (as well on the gpu-side) so i would need something which works just like a videoplane with “blend_enable 1″ and a layer order but which does not draw to a window but has an outlet i could feed into some other slab.
how would i do this???

the working videoplane version is in the patch below. i would need the same, but without drawing to a videoplane but just an outlet instead.
who can give me a hand?
k

– Pasted Max Patch, click to expand. –
#121635
Feb 14, 2013 at 7:56pm

isn’t there anyone who can explain this to me? this is seriously driving me nuts and i am pretty sure the solution is really easy…
isn’t there a way i can just use a slab for this (which i tried and it does sort of blend but ignores the append message of the alpha)…?
?
k

#121636
Feb 14, 2013 at 9:18pm

i’m pretty sure i answered this in your other post no?

many of the default shaders ignore the alpha value, therefore you either edit them, or (IMO a much easier solution) use jit.gl.pix.

if you provide a complete working patch showing what you’re trying to achieve, i’d be happy to offer a more specific solution.

#121637
Feb 14, 2013 at 9:49pm

well…, you did.
to be honest, the problem is i did not buy gen and i would not even know what to use it for except for this.
and for editing shaders… frankly i have no idea how to do this (if i would understand code lines i would probably have none of these problems anyway).
what about this co.alphablend.jxs-shader? it sounds exactly like what i am looking for but i can’t find any help patch or any other documentation…?

i just find it hard to believe i can not mix two inputs plus an alpha to one single texture. especially since it can be so easily done with videoplanes.
i currently work with 8 videoplanes, to each one applying the very same effect chain (bunch of slabs) – which is not only “not pretty” but as well generates a different result as when i would apply these effects only once to a composited image.

thank you so much for your help!!!!
k

#121638
Feb 14, 2013 at 10:53pm

to make it more clear what i am looking for, i updated my example patch from above so it is really working and shows exactly what i need…
again, thank you so much for your help!
k

– Pasted Max Patch, click to expand. –
#121639
Feb 14, 2013 at 11:04pm

ok, if you don’t want to edit the shaders or use gen, you can do what you want using jit.gl.node.
add your videoplane layers to a jit.gl.node and enable capturing on the node.
you can then further process the captured texture.

– Pasted Max Patch, click to expand. –
#121640
Feb 14, 2013 at 11:11pm

wow, that was quick!
i do not fully understand it yet but i think i can safely say: YOU ARE MY HERO!
(i guess you hear that a lot but still…)
for the third time: thank you so much!!!
k

#121641
Feb 15, 2013 at 11:16am

just for reference: i finally understood these alphaglue/alphablend shaders too. it really is dead drop simple – i just did not get the fact that you have to combine them.
for other being equally stupid below the same patch using these two (unmodified) shaders:

best
k

– Pasted Max Patch, click to expand. –
#121642
Feb 15, 2013 at 5:54pm

Hey karl, I am trying to run the patch you posted. What do I use for “input: picture with proper alpha channel”?
Is this a jpg image?

#121643
Feb 16, 2013 at 2:16pm

hi,
jpeg does not support alpha, i use targa. you can however as well use any other channel (r, g, b) of any image if you just select another output (2, 3, 4) of the jit.unpack. or you replace it with jit.rgb2luma and take any image (which gets converted to greyscale then which will get used as an alpha matte).
best
k

#121644
Feb 16, 2013 at 7:35pm

interesting…: i changed my patch to do the compositing (6 layers, each with individual alpha) with shaders (alphaglue/alphablend, see above) and that does work – but introduces quite noticeable frame lagging. once i stop playback, everything is fine and the mattes and videos match perfectly but while playing some of them get delayed by about 1 frame. as well single wrong images appear briefly when switching to different slabs (eg. when i bypass one slabchain with a gate).
i do not have this behaviour if i allocate a separate videoplane to each single compositing process – that performs flawlessly (apart from the problem with applying effects after that…).
the jit.gl.node approach i did not fully test yet because with a lot of layers this gets messy really quickly but i will post the outcome when i try that.
best
k

#121645

You must be logged in to reply to this topic.