# AlphaComposite finally!

**URL:** <https://forums.unrealengine.com/t/alphacomposite-finally/56936>\
**Category:** Rendering\
**Tags:** unreal-engine\
**Created:** [March 1, 2016, 8:41pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936 "2016-03-01T20:41:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moss](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/moss/32/704032_2.png) [@Moss](https://forums.unrealengine.com/u/Moss)\
**Post date:** [March 1, 2016, 8:41pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/1 "2016-03-01T20:41:29Z")

</div>

Hi folks!

In one of the recent twitch streams @\<a href=“[https://forums.unrealengine.com/member.php?u=606](https://forums.unrealengine.com/member.php)” target=“\_blank”\>Luos\</a\> asked about a blend mode called called BlendAdd that was shown in a [talk by Julian Love](http://www.gdcvault.com/play/1017660/Technical-Artist-Bootcamp-The-VFX) 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:

> [@](#):
>
> **BLEND\_AlphaComposite** - Used for materials with textures that have premultiplied alpha. That is, the color channel has already been multiplied by the alpha so when blending with the frame buffer, the GPU can skip the (SrcAlpha \* SrcColor) arithmetic that is typically used with alpha blending. The blend mode was added as part of the Scaleform GFx integration which often uses this type of blending for UI textures.

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

```auto

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).

![jFtgz0i.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/9/c/9c5ea8e04fb4998aaeb49c4fa549019ea49991a4.png)  
(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.

![jFtgz0i.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/0/7/b0769d59fe171eae609aa39613b2869bc18523ff.png)

Once I prepared a test build, @\<a href=“[https://forums.unrealengine.com/member.php?u=606](https://forums.unrealengine.com/member.php)” 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:.

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/1/4/d14927c8704a8cf8b45730a7f29abb7601d5de08.jpeg "[UE4] Alpha Composite (Blend Add) test 1") ](https://www.youtube.com/watch?v=zwrdavg0ips)

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/b/a/5bae739ec4cc1e6a159238494fcb43befcd20a04.jpeg "[UE4] Alpha Composite (Blend Add) test 2 - comparison") ](https://www.youtube.com/watch?v=jYASZpPt3Ag)

(You can [fade the opacity](https://i.gyazo.com/381989ba7b199a72bd931e8b8fa5fe1a.gif) by just multiplying it with into the color itself, the new videos will show that part a bit better)

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/9/6/e96e02d67e3d704eff6af9b4d7baf9c59293696f.jpeg "[UE4] Alphacomposite - Test 3") ](https://www.youtube.com/watch?v=K-ZMAzlHgYk)

The blend mode has already been pushed as a [PullRequest](https://github.com/EpicGames/UnrealEngine/pull/2114) 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 😃 try it out yourself and post your awesome effects!

---

<div class="post-metadata">

**Author:** ![Allar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Allar](https://forums.unrealengine.com/u/Allar)\
**Post date:** [March 1, 2016, 8:45pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/2 "2016-03-01T20:45:04Z")

</div>

Wheeeeeeeeeeee.

---

<div class="post-metadata">

**Author:** ![Luos](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/luos/32/918700_2.png) [@Luos](https://forums.unrealengine.com/u/Luos)\
**Post date:** [March 1, 2016, 8:46pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/3 "2016-03-01T20:46:16Z")

</div>

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!

> **[10 Beautiful Types of Huskies (With Pictures) | Pet Keen](https://petkeen.com/types-of-huskies/)**
>
> You might be surprised to learn that there are a few different breeds of huskies. Learn about 10 beautiful types and what makes them so unique!

---

<div class="post-metadata">

**Author:** ![Niktsuki](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Niktsuki](https://forums.unrealengine.com/u/Niktsuki)\
**Post date:** [March 1, 2016, 8:50pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/4 "2016-03-01T20:50:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Moss](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/moss/32/704032_2.png) [@Moss](https://forums.unrealengine.com/u/Moss)\
**Post date:** [March 1, 2016, 8:54pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/5 "2016-03-01T20:54:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![simonschreibt](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/simonschreibt/32/947877_2.png) [@simonschreibt](https://forums.unrealengine.com/u/simonschreibt)\
**Post date:** [March 1, 2016, 9:10pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/6 "2016-03-01T21:10:50Z")

</div>

+1 +1 +1  
Need this! 🙂

---

<div class="post-metadata">

**Author:** ![Devero](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Devero](https://forums.unrealengine.com/u/Devero)\
**Post date:** [March 1, 2016, 9:11pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/7 "2016-03-01T21:11:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![VictorBurgos](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/victorburgos/32/1008648_2.png) [@VictorBurgos](https://forums.unrealengine.com/u/VictorBurgos)\
**Post date:** [March 1, 2016, 9:17pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/8 "2016-03-01T21:17:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RyanB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanB](https://forums.unrealengine.com/u/RyanB)\
**Post date:** [March 1, 2016, 9:17pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/9 "2016-03-01T21:17:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Devero](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Devero](https://forums.unrealengine.com/u/Devero)\
**Post date:** [March 1, 2016, 9:28pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/10 "2016-03-01T21:28:31Z")

</div>

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

> **[Technical Artist Bootcamp: The VFX of Diablo](https://www.gdcvault.com/play/1017660/Technical-Artist-Bootcamp-The-VFX)**
>
> Technical art is evolving rapidly. In many studios TAs play key roles in developing efficient tools pipelines, and ensuring art content is visually striking and optimized for performance. TAs bridge content and engineering, helping make both more...

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

---

<div class="post-metadata">

**Author:** ![Luos](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/luos/32/918700_2.png) [@Luos](https://forums.unrealengine.com/u/Luos)\
**Post date:** [March 1, 2016, 9:35pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/11 "2016-03-01T21:35:04Z")

</div>

> [@;484835](#):
>
> 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.

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...](https://www.facebook.com/groups/realtimevfx/permalink/1142897625728435/)

---

<div class="post-metadata">

**Author:** ![Devero](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Devero](https://forums.unrealengine.com/u/Devero)\
**Post date:** [March 1, 2016, 9:37pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/12 "2016-03-01T21:37:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RyanB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanB](https://forums.unrealengine.com/u/RyanB)\
**Post date:** [March 1, 2016, 9:42pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/13 "2016-03-01T21:42:17Z")

</div>

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.

 ![BlendAdd.JPG](https://d3kjluh73b9h9o.cloudfront.net/original/3X/f/5/f55966ddfbb3d3feb0e7b34aaae5e9cd1f9319b8.jpeg)

---

<div class="post-metadata">

**Author:** ![bokuden](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bokuden](https://forums.unrealengine.com/u/bokuden)\
**Post date:** [March 1, 2016, 9:43pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/14 "2016-03-01T21:43:36Z")

</div>

Ah very cool! Looks promising 🙂

---

<div class="post-metadata">

**Author:** ![Luos](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/luos/32/918700_2.png) [@Luos](https://forums.unrealengine.com/u/Luos)\
**Post date:** [March 1, 2016, 9:47pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/15 "2016-03-01T21:47:35Z")

</div>

> [@;484856](#):
>
> 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.
> 
> of course destcolor is scenecolor now.

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

---

<div class="post-metadata">

**Author:** ![RyanB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanB](https://forums.unrealengine.com/u/RyanB)\
**Post date:** [March 1, 2016, 9:52pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/16 "2016-03-01T21:52:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Devero](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Devero](https://forums.unrealengine.com/u/Devero)\
**Post date:** [March 1, 2016, 9:57pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/17 "2016-03-01T21:57:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![RyanB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanB](https://forums.unrealengine.com/u/RyanB)\
**Post date:** [March 1, 2016, 10:01pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/18 "2016-03-01T22:01:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Hevedy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hevedy](https://forums.unrealengine.com/u/Hevedy)\
**Post date:** [March 1, 2016, 10:22pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/19 "2016-03-01T22:22:10Z")

</div>

> [@;484835](#):
>
> 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.

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.

---

<div class="post-metadata">

**Author:** ![RyanB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanB](https://forums.unrealengine.com/u/RyanB)\
**Post date:** [March 1, 2016, 10:28pm UTC](https://forums.unrealengine.com/t/alphacomposite-finally/56936/20 "2016-03-01T22:28:42Z")

</div>

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 🙂 but it is a valid concern we have to juggle.

[Next page](https://forums.unrealengine.com/t/alphacomposite-finally/56936.md?page=2)
