blend modes, layers, and me
Hi all,
I don't know why I am having such a block against this, but I am. Here's what I am trying to do.
I have three videoplanes:
#1 = background image
#2 = live feed of a performer in black & white (binary image)
#3 = texture to be applied to performer
Goal: whatever is white in the live feed (#2) becomes a window to the texture (#3). Whatever is black in the live feed becomes transparent and shows the background image (#1).
I'm trying to do everything I can in gl using jit.gl.videoplane for the mixing/blending.
I've been able to get the first part to work without a problem...however I'm am really not sure if the blend modes I am using are right. To get the live feed to be filled with the texture I have the texture set to layer 2, blendmode = 1 0. The live feed is layer 3, blend mode 0 3. Don't know if that is right, but it works up to this point. I have the background set to layer 1, and it just doesn't matter what blendmode I use, nothing shows up (not surprising). I'm pretty certain what I need to do is create an alpha channel to the live feed...whenever the image is white alpha = 1., black alpha = 0. I started on this, but I think my lack of understanding of blend_modes is going to keep me from seeing any results.
I know a patch will be helpful and am working on one now to follow-up with, but if anyone has any pointers in the meantime, it would be hugely appreciated.
Thanks,
David
hi david. i think a custom shader would be the best solution.
the glsl mix function should do everything you need.
quick example with shader:
Rob, you are my new best friend :)
This is perfect. Thank you for your help with this!
Best,
David
Reviving an old thread here!
Perhaps I haven't thought this thru very well, but how would I preserve the alpha channel of the two textures being mixed in, e.g. if the texture I am using to replace black has an alpha mask, is there a way to preserve it?
Thanks in advance,
David
In Max6 if you are capturing the texture via jit.gl.node you can specify node's @erase_color as 0 0 0 0 and the alpha channel will be preserved.
That's something that can be adjusted in the shader.
These two lines:
vec3 mixr = mix(b.rgb,c.rgb,a.rgb);
gl_FragColor = vec4(mixr,1.);
…can become:
vec4 mixr = mix(b,c,a.g);
gl_FragColor = mixr;
That should preserve alpha channels.