blend modes, layers, and me
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.
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:
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 1003.3oc0Y1saZCCEG+Z3ovJZWxPw14CxtXp6kX2LMUYHFvcI1zXmV5l169R hIcoTnDa.2TgHQwIA++7yGeNGa9y3QdyEaoROvW.+.LZzeFOZTSS0MLZ20i7 xIaWjQjMOlGm9nX9cdSz2RQ2pZZNSPRmS3qZuAuLmwynplWBtqwMD0h0L9pa KnKT5NEg8m5OALq4XbyQXxTevO++uinTs+ODKsoSqDxmQQsc4RAWwI4zla8c ZQJgSZum92P8zFpta8Zz5y8R8qJY+t4lvJQT25eGOt9vjyiK2wTSEa.2T88q fadfjAfnYGDRn2.R9ZvnoDDEdBLgN.lBsBSUx+1bhpfs0aBvyU.aU1zGXoTw lLBmBVJDfaVHxDE.n9S6Kkw3zEhRtpqQ2aOOMTwHMTg5qfFAU7GDnV.TqoGc 5o+wgTvN5DzbJblEyOQVwnKJUlWpTBtmcNHPcDJzyGMv1gmJ9iEFSNUJIqnu dLlRRAoheSKllKdvzPLAAcCwjfatH1DiElbgGnaEaAUR4JhhI3cELNVqwj5S 96NbEHJStlJsAo3yGoyd+m67FgouWUiEF0zIV6701M+JZl4YyfQW0.umvyCh 0xGc1ddWA3hOe39QpTAcOVUTvh0jh5j4.TfukQ5eNferEPK3CDz3Blj1xr.P fsYFizm7irfW3OV0iJyHy0Uhx3aJUR.FbyRVFELmwIEOky1N8tsx9WXJ9zdi QcK8xrBSgHqo6praqs8xB5EmvGKO6xxrL4hBJkC9Dz3rrZXoKOKNxhjru+4X UhUqxLNROD8hnVwla5niZdrZW2KXFMIMCfhMcrcVWCDmXdTFr86MfiBu7K5S ltlLbWpDfOAUBdMUrKUUsKwjCcxQAgejwSEOVGC13Rhz.SGHcVf4tQgCd2H4 at.+2fMgcWi6IWeu+qYSupD+pmdtfxSoE16brqTlDj4NGwCGmiZXrbibUIyT JjnMe8ZFzgaCLABGdgpeqfQxNdJzia9vKoKhBLu5CsfTUy6b6bOzaLcrEwZS NKui1yMh+4Fd+K8PSE62XLnuyp739bppPToO6JrTGeLJv7M9DBut+wDMOSyJ M16+uowVpa+kvRJJKVz1Ks6LK3+FTJUppVKS8lcz4gpWWamGZMKMkx6lJHmk tQTMnsSDGYnq2ZJpOZJY.poYCOMUu8yNTS64pbDNgbqlv8gSgtcrKb.NuC1G Mgc6XWTe8mPtSSg8USP2oo9DGG41wt9kaIZ.pI2FKXuTYCBNsWprAAm5SpE2 5g2qDKt0+tOCat0SxuORxwZpOY5baAlIuHE1gUTryUj+fRQ8YTKz4LBdBEE4 bEgOghNmkoTcweG+O90IU+C -----------end_max5_patcher-----------
Rob, you are my new best friend :)
This is perfect. Thank you for your help with this!
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,
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.);
vec4 mixr = mix(b,c,a.g);
gl_FragColor = mixr;
That should preserve alpha channels.
Forums > Jitter