alpha, jit.gl.slab and cc.brightness.ip.jxs
masters of gl, please step forward…
i work with three layers of grayscale live video all rendered into the same window, some with alpha.
before rendering, i need to adjust brightness and contrast (same for all layers) which i do via jit.gl.slab and the cc.brightness/contrast.ip.jxs shaders.
now, this works well until i aply this to a video with alpha – if i do, the alpha is not transparent any more but displayed as solid grey.
if i bypass the two jit.gl.slabs, it works as it should. did i do anything wrong or do these shaders simply not support alpha?
(and what would i do then?)
if you look at the patch attached, the middle one is the problem.
apart i am wondering if there is a neater way to program this anyway… currently, i use six slabs for basically just adjusting brightness and contrast which does seem somewhat excessive…
any help highly appreciated!!
----------begin_max5_patcher---------- 1339.3oc6ZtzbqZCEGes8mBMLcQ6LoL5MhtJ8KP6ltqSmLxXYaRv.CHm3buy 86dEBiCwwfgDGB1ycSr4gE+424gNGo78oSblkrUk6.9Cv+BlL46SmLwdphSL Y2wSbVK2FDIys2lSPx50pXsyMkWSq1psm+ojrGxA+5xL4y4AxHEXsTqUyAOE pWAxUoxLoVAjQoqj+V0ONJLVEjrI1NB3cmLdy5jM5Hk197f6NapTGrJLd4cY p.codoLW3M.BST7AR.sGQbgf+a2uYQ1xY1wvsZTBma0Zxr6+cVkHVjDqikqU 1q7mYgxn5WIO7a1qfv6GDi.CiqzGp3b+X5zh+byGDgyST4f+5u+GPAKqiRKC O+nCiXknC0OzQGenam228ax0fW31igyUI6QVOoiWIb3TKpfcENjuN3Dqdxnf 2vl6C0tlfwrvs.DHXkLCPEP.1CdbvfaFLHnMHCg7c8gPHlZ9Nw+M7oFMvUOi xGf94TU4PUnp6JUkyM.GmWf6XBaahSkAO.vGmTjlIkeoWimmqmuuuPXbmPsw INQzQRcQvMK0n82+RvNDaLeWVaXyafcvneJwk3OVb4NuMJeO1NQXImvurCLW F4lGImA9lJTuPEmqUYfaWDZx4GD3NKKb4JcrJO2ML089s4famqR0qtSEKmYt EH3VyGwyqNF0iIUawJP7rUhfIkQ5TwalUs9zDnVM.Kitq38cSl5cYDPt9DpG AcLKA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DOC -----------end_max5_patcher-----------
hm… maybe i should phrase my question different…: the most elegant solution to all of the above i can imagine would be something like an "adjustment layer".. so like in photoshop or avid or any of these programs a layer, which just sits on top and changes the contrast/brightness of all layers below. is anything like that possible in gl-world?
i tried it with an empty videoplane @layer 10 but that does not have any effect…
best and thanks!
if you take a look at the cc.contrast shader, you see that the alpha value is ignored when sampling the input texture.
your options are to either edit the shader or reapply your alpha channel with something like the cc.alphaglue shader.
probably the best option is to use jit.gl.pix and the supplied gen file @gen brcosa
if you look at that gen patcher, you see that the alpha channel is passed on unaffected.
hm, that seem all to be good options!
i solved it for the time being by just doing the alphablending on the cpu-side with jit.alphablend before going to gpu-land but i will give that definitely a try!!
thank you guys so much!
just for the record:
since i do not work in argb but just greyscale+alpha (2 planes only), did not get alphaglue to work and the conversion to argb via jit.pack is slowing things down quite a bit, in the end i went a third way – which works surprinsingly well: i simply process alpha and image separately (jit.unpack) and bring them together in the end by loading the alpha to a texture (@colormode intensity) and then append this to the baselayer video plane (pretty much like with the other alphalayer in the patch above). performance wise this seems to be the most efficient way – at least in my patch.