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)

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;
}
