|
Kineme GL BlendTo prevent black fringe around glow or luminous edges, I need a Special blend mode that creates an alpha channel based on the maximum luminance of the RGB channels, then make the RGB channels "un-premultiplied". I can do it with a core image kernel, but i need it at the root blending level of the patch ... Does the kineme GL Blend Equation can help me or something else ? THX. |
Can you provide an example?
the GL Blend modes aren't particularly powerful for this sort of thing (they're all channel-independent, so luma isn't possible).
GLSL could probably do this for you at the level you're wanting it.
Here is an exemple : alpha generated by rgb max. This is specialy useful to blend glow, light, fire, lens flare and based particles on cleary backgrounds without black fringe... This actualy works but i need this principe inside an iterator with a lot of (different images) iterations and in this case a CI kernel on each would be very fat for FPS....
Your best bet is to pre-process the images (if there's a fixed number), either manually, or with this method in QC (outside of the iterator).
unpremultiply
isn't used for anything in this sample -- unpremultiply takes the color values, and divides by alpha -- in these examples, alpha is always one, so the division isn't doing anything (R/1 = R, etc.)It should be possible in GLSL (without severe performance loss), if you want to go that route.
GL Blend cannot do this -- all the blend modes available do simple addition, subtraction, and multiplication (no division for
unpremultiply
), and no compares between components (for themax
's).My exemple was not ideal. (because of no alpha on images ;) Here is a much better one. To be more precise it is about a Fxplug based on a QC comp that is embed in a host. My problem is with particles blending : each particle is layered with the add blending mode. The alpha value is generated from the addition of each opacity of each particle. So I can't preprocess because original images (letters in this case) have a full plain alpha.
It's definitely premultiplication. If you want it at the root level of the patch, why not put the whole patch in a render in image? Then you can just add a CI filter with
return premultiply(sample(image, coords));
and connect to a billboard. It should be pretty fast.
I was trying to do it without RII because of differents composited nodes that i need to keep separated (animated Text+motionblur+particle+special background). the ideal is to render each node in a separated render to image patch then process, but this will kill the FPS on lower end GPU...
Ok, if that's not practical, back to your original suggestion of the GLBlend modes:
"The premulitplied blending function, with its alpha channel ignored, can be emulated by this function:
gBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);"
Is this function available in the blend modes at all?
We reverse engineered the Blend port to extend it with our Alpha blend mode. Here's the pertinent part:
So it looks like the built-in Over mode should do it.
Thanks to both of you. I think that RII with a custom CI will work.