[bug?] jit.gl.node and alpha color message

Francois Weber's icon

Hi,

I have to send a color message, changing the alpha value, to a videoplane object.
Alpha does not seem to be linear via a jit.gl.node object.
It's ok whithout using node.

I don't understand why.... is it a bug ?

Max Patch
Copy patch and select New From Clipboard in Max.

here is the patch (MBP retina, OS 10.8.4, Max 6.1.3) :

thanks

Francois Weber's icon

Nobody Knows ? .... the Trouble I've Seen... with alpha & nodes.....

vichug's icon

i can notice the same here (osx10.6.8 max6.1.3), unfortunately i'm not too familiar with jitter nodes, so i can't really help, but mayyybe it's related to the default erase color of videoplane/node ? or some blending thing ?

Rob Ramirez's icon

it looks like when you capture the first videoplane to the gl.node, it effectively premultiplies the alpha value into the texture, while still keeping the alpha channel. when you display on the second videoplane with @blend_enable 1, it applies the alpha channel to the already premultiplied texture, thereby giving your non-linear effect.

solution is to set @blend_enable 0 on second videoplane.

Francois Weber's icon

Hi,
Thanks for your reply.

@Rob : yes, it look like an alpha premultiplies problem....
you solution is not good for me, i need to use alpha on second videoplane.

In fact, i try to use 32 gl.cornerpins routed to 8 sub-masters gl.nodes, routed to 2 masters gl.nodes, routed to the gl.render.... and i need to use alpha...
So in my case, the gl.nodes premultiplies twice the alpha value !
May be using nodes isn't the right way ?

django's icon

Hi, did anyone find a solution to that yet? I ran into the same problem and I can't use Robs solution either. Thanks.

Francois Weber's icon

Hi,
Same probleme with Max7 / OSX 10.10.1
I need to use movies with alpha channel. So, i can't use Robs solution (@blend_enable 0 on second videoplane)..... and i can't use jit.gl.node....
Hope somebody find a way to do that...
Thanks

Rob Ramirez's icon

you will have to come up with another technique for this. why do you need to cascade textures using gl.node like this, rather than simply combining the textures using gl.pix or gl.slab? please post a patch.

Francois Weber's icon

Hi Rob,
Here is the patch. I try to use gl.node to have "layers" route in some "subs".
Thanks again !!!

Max Patch
Copy patch and select New From Clipboard in Max.

`

django's icon

Hi Rob, we try to create hierarchical rendering groups while preserving the alpha channel. I cannot post a patch since my project is pretty large and part of the rendering process happens in Java. I tried capturing to a texture (texture with erase_color 0 0 0 0), but it has the same effect. I have an unknown number of videoplanes and I need to combine them to a texture. Can you give us a hint on how to achieve this while preserving the alpha channel.

Thanks, David

Rob Ramirez's icon

i would just adjust your alpha control. the alpha is essentially being squared by the time it reaches the sub layer, so simply send your alpha parameter through a sqrt 1. object to invert that.

you may also want to establish which videoplane sub layer is the first layer (using the @layer attribute) and set @blend_enable 0 on that videoplane, otherwise the erase_color blends in, which may be undesirable.

another option would be to build in additional functionality that handles the alpha channels, using jit.gl.pix. you could route all alpha channels of a sub-node to a jit.gl.pix and apply them however you want to the final output of that sub-node.

Francois Weber's icon

Hi Rob,
i would just adjust your alpha control. the alpha is essentially being squared by the time it reaches the sub layer, so simply send your alpha parameter through a sqrt 1. object to invert that.

Yes of course i can use a sqrt object. But like that, i can't directly draw to the render object. i need to use a gl.node just to correct the alpha linearity…. It is not a very 'elegant' solution…

you may also want to establish which videoplane sub layer is the first layer (using the @layer attribute) and set @blend_enable 0 on that videoplane, otherwise the erase_color blends in, which may be undesirable.

Yes

another option would be to build in additional functionality that handles the alpha channels, using jit.gl.pix. you could route all alpha channels of a sub-node to a jit.gl.pix and apply them however you want to the final output of that sub-node.

Yes but…. Is it an 'elegant' solution…

Thank you very much for these options

matmat's icon

Hi François,
An another thing with "jit.gl.node" the default color is set to "0.5 0.5 0.5 1.".
If you set "@color 1 1 1 1" on "jit.gl.node" sometime it can be usefull with "blend_enable 1" .
mathieu

django's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Thank you Rob for your insights. I'm sure the answer is already there, but I cannot figure out what to do with it. If you find the time to have a look at it, I made a patch, that explains, what I'm trying to do.

django's icon
Max Patch
Copy patch and select New From Clipboard in Max.

This is how I solved it in the end. Maybe it is of some use for someone.
Thanks to Francois to point that problem out (I hope you find a solution that fits your needs) and thanks to Rob for giving me the right pointers.

MH's icon

Hello all
I am having similar problems with the alpha and gl.node. I don't know if I could have done this composition differently. I hope someone can point out what I can do. I have tried correcting the alpha with gl.pix.

My goal is to create a trail effect on a sprite mapped over a gridshape object moving over a background image and not have the top sprite blurred.

thanks for you help !