AlphaComposite finally!

Hi folks!

In one of the recent twitch streams @<a href=“” target=“_blank”>Luos</a> asked about a blend mode called called BlendAdd that was shown in a talk by Julian Love but no valuable answer came back so we started chatting about it and how it could be integrated into the engine. The topic also came up in the RealTimeVFX Facebook group with Julian itself helping out.

So after starting and investigating on what BlendAdd actually was I realized that the good old AlphaComposite blend was exactly the same thing. As stated in the UE3 documentation AlphaComposite:

In terms of a Blend Mode the result of the final color is expressed as

res.rgb = src.rgb + (dst.rgb * (1.0 - src.a))
res.a   = src.a   + (dst.a   * (1.0 - src.a))

So what does this actually means is that the alpha part is already within the color of the material, this way you can control your opacity and highlight better. Long story short it fixes the issues with additive going to white and details vanishing on bright backgrounds. The next screenshots will give you a sent on what I mean by it (both has been overdrawn 3 times).

(The texture I used has been provided by my pal Douglas Kerr @ Phoenix Labs)

As you can see the right side tends to go to white with more and more overdraws while the left side still holds the details of the original texture.

This is what a typical graph looks like using AlphaComposite, note that I actually feed the opacity not directly in the opacity pin, I pre-multiply it with the actual color part to control the final opacity there.


Once I prepared a test build, @<a href=“” target=“_blank”>Luos</a> started to play with it which resulted in the following videos (he will record new ones with better examples ^^), his art skills are way better than my humble programming art :rolleyes:.

(You can fade the opacity by just multiplying it with into the color itself, the new videos will show that part a bit better)

The blend mode has already been pushed as a PullRequest to Epic that you can integrate yourself (or use the attached AlphaCompositePatch.txt file for version 4.10, just change the file ending to .diff or .patch).

So I guess that’s all for now :smiley: try it out yourself and post your awesome effects!



Well… yea, of course I want this awesome new blending mode added to ue4.
So I look upon thee, developers of epic, please add it!

That is awesome :smiley: And Luos’ tests look great! :DDDD

Thanks!!! Let’s hope it gets in as soon as possible :smiley:

+1 +1 +1
Need this! :slight_smile:

+111111 Heck yeah! Thanks Moritz! Lets get this in standard build.

Anything that makes us into better artists “easier” is fine by me.

What is the reason why people want this? Its not like its going to save any performance in most cases if you just move the instruction to the shader, unless you bake it into the texture. And then we are talking about a pretty tiny effect whereas adding a blend mode complicates the code for future development.

The main reason for this technique is highlighted in this VFX talk:

If you jump to the section talking about “Don’t Ruin The experience”. Its about controlling additive buildup.

This isnt about performance though, this is about visuals.
And me and a lot of fellow particle/vfx guys would love to have this option.
It shouldn’t be that less performant than the regular translucent/blend modes anyways.

Besides that, since you are a member in the VFX group, why not read: Redirecting...

Probably the best quote from the facebook thread…

" it’s weird that you have all this pre-blend mode complexity at your disposal but only a handful of presets for how that stuff gets composited." --Julian Love

ah I see. I thought all of what it was doing was contained within the material graph shown in the first post. Does seem pretty useful.

You could sort of approximate this in a translucent material without code changes by referencing scene texture and adding to that, and then lerping between that result and your translucent blend using the alpha. The only issue is multiple effects would not accumulate properly in the additive portion that way.

edit* mike hanson on the VFX page basically posted the same trick I was talking about to achieve it.

Ah very cool! Looks promising :slight_smile:

Tried that, result is sub-par… and also discussed a bit in that thread :slight_smile:

For a single material it should be identical as doing it in code. It would only look different once you have multiple layers since they will not accumulate the additive portion. I know its not as useful as the full thing just posting it for those who want to try it out for now.

The latter point is the one I was more interested in, when there are several effects going on in the scene or if the scene is brighter to begin with.

Just to clarify, if the scene is brighter to begin with and you have only one layer it should still function the same, just the accumulation of layers will be different.

Always I read from Epic Developers the sentence “…complicates the code for future development…” not sure why Unreal Engine 4 is not just a console that say “Hello World” and close to have all controlled and clear.

I only said that when misunderstanding what the desired effect was from the thumbnail. I was merely saying if that is all the effect is doing (a material multiply) it would not be worth doing in code. But I wasn’t aware it was mixing blending and additive together since I did not look at the included link :slight_smile: but it is a valid concern we have to juggle.