FFGL alpha shader problem

FFGL, OSC, GLSL. If you like abbreviations, this is the forum for you
Post Reply
User avatar
flux
Met Resolume in a bar the other day
Posts: 10
Joined: Sun Feb 09, 2014 14:47
Location: berlin

FFGL alpha shader problem

Post by flux »

hey guys,

i am fiddling with FFGL coding at the moment and i wanted to implement a simple mixmode plugin that uses a shader which takes two texture inputs tex0 and tex1 and applies one of the R, G, B, or A channel of tex0 as the Alpha channel of tex1.

i got it to compile and run in resolume avenue 4, but unfortunately not with the desired output. the assignment of tex0's alpha channel to tex2 works, but the result is that all alpha transparency is black instead of transparent.

here's a screenshot of the actual output on the left (top layer has my mixmode plugin "AlphaX" loaded and takes the blue channel from the middle layer as its own alpha) and the desired output on the right (photoshop mockup)

Image

is the problem related to how resolume implements the mixmodes, so alpha in the mixed texture doesn't affect the layer's alpha at all? or is it a problem in my shader? do i need to change any GL options in the FFGL plugin, like glTexEnvi? the plugin code is almost completely based on the LumaKey sample from the FFGL SDK, except that i changed the fragment shader part to this:

Code: Select all

uniform sampler2D tex0;
uniform sampler2D tex1;
uniform float channel;
void main( void )
{
    // load the two textures
    vec4 color0 = texture2D( tex0, gl_TexCoord[0].st );
    vec4 color1 = texture2D( tex1, gl_TexCoord[0].st );
    // depending on float variable between 0 and 1 switch to one of RGBA channels:
    if (channel < 0.25f) { gl_FragColor.a  =  color0.r; }
    if (channel >= 0.25f && channel < 0.5f ) { gl_FragColor.a  =  color0.g; }
    if (channel >= 0.5f && channel < 0.75f ) { gl_FragColor.a  =  color0.b; }
    if (channel > 0.75f ) { gl_FragColor.a  =  color0.a; }
    // keep RGB from tex1
    gl_FragColor.rgb  =  color1.rgb;
}
any hint would be appreciated. thanks a lot in advance! :geek:

Joris
Doesn't Know Jack about VJ'ing or Software Development and Mostly Just Gets Coffee for Everyone
Posts: 5185
Joined: Fri May 22, 2009 11:38

Re: FFGL alpha shader problem

Post by Joris »

Blend modes take two textures as input: the first is the layer that the blend mode is applied on, the second is all other layers underneath that. Think of the layer that the mode is applied as “tex0” and the combined video of all of the lower layers that the layer is being mixed with as "tex1".

There is currently no way to take a single layer as a mask for another layer, while leaving the third layer intact. As you mention in another thread on this topic (viewtopic.php?t=10919&p=43315#p43315) this would require a third input.

User avatar
flux
Met Resolume in a bar the other day
Posts: 10
Joined: Sun Feb 09, 2014 14:47
Location: berlin

Re: FFGL alpha shader problem

Post by flux »

thanks joris, for clearing this up! now it all makes sense!

i would love to have one layer fully masking another one - so many possibilities. so, yeah, please think about the idea in my other post ;)

Post Reply