Announcement

Collapse
No announcement yet.

AlphaComposite finally!

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    AlphaComposite finally!

    Hi folks!

    In one of the recent twitch streams @<a href="https://forums.unrealengine.com/member.php?u=606" 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:

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

    Click image for larger version

Name:	jFtgz0i.png
Views:	1
Size:	320.5 KB
ID:	1175336
    (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.

    Click image for larger version

Name:	zRavkAM.png
Views:	1
Size:	57.9 KB
ID:	1175339

    Once I prepared a test build, @<a href="https://forums.unrealengine.com/member.php?u=606" 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 .



    (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 try it out yourself and post your awesome effects!
    Attached Files
    Last edited by Moss; 03-02-2016, 05:56 PM.
    Sr. Engine Programmer @ www.playspace.com - moritzwundke.com
    Remember: be polite and respect other peoples opinions - Join the Unofficial Unreal Discord Channel - Found a bug? Then use the Bug Report Form to get it fixed ^^

    #2
    Wheeeeeeeeeeee.

    Comment


      #3
      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!

      Comment


        #4
        That is awesome And Luos' tests look great! DDD

        Comment


          #5
          Thanks!!! Let's hope it gets in as soon as possible
          Sr. Engine Programmer @ www.playspace.com - moritzwundke.com
          Remember: be polite and respect other peoples opinions - Join the Unofficial Unreal Discord Channel - Found a bug? Then use the Bug Report Form to get it fixed ^^

          Comment


            #6
            +1 +1 +1
            Need this!

            Comment


              #7
              +111111 Heck yeah! Thanks Moritz! Lets get this in standard build.
              W3 Studios

              Comment


                #8
                Anything that makes us into better artists "easier" is fine by me.
                Website/Portfolio: http://www.VictorBurgosGames.com

                Join me on stream: https://www.twitch.tv/VictorBurgosGames for UE4 Game Dev. If you need help, just stop by and ask!

                Currently looking for exciting new opportunities! Available for work!
                https://forums.unrealengine.com/comm...ars-experience

                Comment


                  #9
                  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.
                  Ryan Brucks
                  Principal Technical Artist, Epic Games

                  Comment


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

                    http://www.gdcvault.com/play/1017660...otcamp-The-VFX

                    If you jump to the section talking about "Don't Ruin The experience". Its about controlling additive buildup.
                    W3 Studios

                    Comment


                      #11
                      Originally posted by RyanB View Post
                      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: https://www.facebook.com/groups/real...2897625728435/

                      Comment


                        #12
                        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
                        W3 Studios

                        Comment


                          #13
                          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.

                          Click image for larger version

Name:	BlendAdd.JPG
Views:	1
Size:	77.8 KB
ID:	1101588
                          Last edited by RyanB; 03-01-2016, 05:51 PM.
                          Ryan Brucks
                          Principal Technical Artist, Epic Games

                          Comment


                            #14
                            Ah very cool! Looks promising

                            Comment


                              #15
                              Originally posted by RyanB View Post
                              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.

                              [ATTACH=CONFIG]81383[/ATTACH]

                              of course destcolor is scenecolor now.
                              Tried that, result is sub-par.. and also discussed a bit in that thread

                              Comment

                              Working...
                              X