Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Blend Modes

Discussion in 'Assets and Asset Store' started by Elringus, Jan 16, 2015.

  1. BenQi

    BenQi

    Joined:
    Mar 18, 2013
    Posts:
    10
    I've send U the email.
     
    Last edited by a moderator: Oct 4, 2016
  2. AurochChris

    AurochChris

    Joined:
    Jan 7, 2014
    Posts:
    9
    Hey Elringus,

    We bought the plug-in yesterday. It's really useful, so thank you for that!

    One minor issue we have is the way the blend modes interact with the UGUI mask component. We want to do some subtle highlighting on a progress bar with the overlay blend mode; but we need to mask it out because it's got an irregular shape.

    I've attached a picture showing the difference.

    I'm not a programmer; so I'm not sure if this is a case of 'this is the only way it can work' or if it's just unintended.
     

    Attached Files:

  3. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    Hello,

    Unfortunately, due to the way masks are currently implemented in Unity, they are “blocking” grabpass and therefore making impossible to use the Blend Mode effect. I will try to research the topic more, but can’t promise there will be any solution. Sorry for the inconvenience.
     
  4. AurochChris

    AurochChris

    Joined:
    Jan 7, 2014
    Posts:
    9
    That's fair enough. The mask implementation has been a consistent pain for us in using UGUI anyway; so I'm not too surprised that it's a limiting factor on this too.

    Thanks for the quick response!
     
  5. cesarpo

    cesarpo

    Joined:
    Jun 8, 2013
    Posts:
    98
    This looks super useful, but I wonder, what would be the behavior of this on android devices without tegra?

    Is there any fallback?
     
  6. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    It will work in Grab and Unified Grab modes, but performance might be rather poor, depending on the device.
     
  7. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    Hey there,

    Just wanted to inform you, that due to a known bug with GrabPass in Unity 5.2 (case #724452) Blend Mode effect will not render properly in the editor when any of the aspect constraints are set for the game view (like 16:9, 4:3, etc).
    This problem only affects the editor (it will not show in any of the builds) and it will not show when using the “free aspect” mode.
    Most likely, this bug will get to the final 5.2 release, but is promised to be fixed with one of the first patches.

    In most cases, it shouldn’t be a problem to use the “free aspect” mode in the editor as a temp workaround, but if it is, please consider waiting for the patches before upgrading to Unity 5.2.

    EDIT: The bug has been fixed in 5.2.0p1.
     
    Last edited: Sep 18, 2015
  8. Fai2

    Fai2

    Joined:
    Sep 24, 2015
    Posts:
    3
    Hi, I've bought the plugin but I'm experiencing a rendering problem on 5.2.0f3. I've put a simple plane with the blending shader between the camera and the scene, but everything behind the plane is shifted. Please help! Thanks!
    Screen Shot 2015-09-24 at 00.13.41.png
     
    Last edited: Sep 24, 2015
  9. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    Hello,

    Just as I wrote in the previous post, there is a bug in Unity 5.2, which causes Blend Mode effect to render incorrectly in the editor. Just install the latest patch (https://unity3d.com/unity/qa/patch-releases) and it should solve the problem.
     
  10. Fai2

    Fai2

    Joined:
    Sep 24, 2015
    Posts:
    3
    It's sorted. Thanks very much!
     
  11. PaulHarty

    PaulHarty

    Joined:
    May 20, 2015
    Posts:
    5
    Hello Elringus,

    I'm pretty hopeless when it comes to shaders within Unity (learning, but slowly), so last week I bought this asset to resolve a particular issue which it did instantly with the Pin Light mode.

    I've build my game to Android (Tegra) using the Framebuffer render mode (as advised in the documentation) and, although the image is transparent, the completely transparent parts of the image become visible. So rather than having an image that blends nicely onto the the image behind I end up with the full box on display which ruins the effect.

    Is there anything I can do to make the fully transparent alpha level stay fully transparent in Framebuffer mode?

    Thanks

    Paul
     
  12. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    Hello Paul,

    There is a bug in the current version of the plugin, which prevents framebuffer shaders to compile correctly with Unity 5.2. It’s just a guess, but your problem could be related. Please contact me via the support email with the invoice number and I will send you the new version with the fix, so we could check if it will help to solve the problem.
     
    Last edited: Oct 3, 2016
  13. BlankMauser

    BlankMauser

    Joined:
    Dec 10, 2013
    Posts:
    111
    This kind of functionality would also be wonderful for particle systems! I would also instantly buy this if it were a feature. Is it possible to apply a black mask over the background? Or sample the background color to subtract from the color? Render on different cameras maybe?
     
  14. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    I’ve made some progress with the “selective blending” feature using alpha channel as a mask. It’s far from perfect, but does its job in simple cases like this:


    I’m still not sure if it’s at all possible to achieve such selective blending in a way that would integrate with the plugin and work in all cases (like with particles and different camera clear flags) and will continue working on this, but if someone would like to try using current implementation — you may get it here: https://get-asset.appspot.com/BlendModes (you’ll be asked to enter invoice number in order to download the package)
     
    Last edited: Nov 30, 2015
  15. noamgat

    noamgat

    Joined:
    Nov 22, 2009
    Posts:
    126
    Hi, this is a very interesting plugin for me. Is there a place where the android devices / operating system that support the required mobile friendly GL extension are listed?
     
  16. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    I’m not sure such thing exists, unfortunately. There are so many android devices that it’s nearly impossible to list them all, not speaking of listing all the extensions they support. In theory, at least all the PowerVR and most of the NVidia Tegra chips should support the extension, but then it’s also a question if the drivers exposes it.
     
    Last edited: Dec 9, 2015
  17. masterhero

    masterhero

    Joined:
    Nov 2, 2013
    Posts:
    2
    Hi Elringus,
    I just bought Blend Modes for my current project but I realised that it isn't compatible with Spine animated sprites. It's extremely important for me to make them work together because I'm making extensive use of Spine sprites for this project. Do you know if there's a way to achieve that?
    Thank you for your patience!
     
  18. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    It’s trivial: just apply a blend shader to the material of the sprite atlas.

    Here is a brief tutorial:



    Like this, you can also use blend effect with any generic renderers. More info about the feature in the docs: https://goo.gl/tSAmB7 (look for the “Using custom blend materials” section).
     
    Last edited: Dec 9, 2015
  19. masterhero

    masterhero

    Joined:
    Nov 2, 2013
    Posts:
    2
    Thank you for your answer. It was my fault, I was using an old version of the Spine runtimes. I've updated them and now it works perfectly!
     
  20. fahd

    fahd

    Joined:
    Aug 7, 2014
    Posts:
    33
    Hello
    when i use the any of the 3 rendering modes on the ipad air2 ios 9 it give me weird results how can i fix them on image component
     
  21. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    Hello, I've just replied you by email, but feel free to post here, if you wish.
     
  22. fahd

    fahd

    Joined:
    Aug 7, 2014
    Posts:
    33
    thanks for the great and fast support i hope you will help me figure out the issue
     
  23. Rissatto

    Rissatto

    Joined:
    Mar 16, 2013
    Posts:
    7
    @Elringus please help me.



    In this image I'm using color dodge blend effect. But the result is not the same as obtains in Photoshop (The example below was done in photoshop, the example above was assembled with the Blend Effect in Unity).

    I'm using this button on a video in a RawImage using the UI Unity. And the Color Dodge is very dark.

    I can reproduce the effect created in photoshop somehow?
     
  24. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    I can only see one image in your message (apparently the one from Unity). Could you please provide the second one, from PS? Also, please check tint color of the Image in Unity (it affects the resulting look).
     
  25. Rissatto

    Rissatto

    Joined:
    Mar 16, 2013
    Posts:
    7
    @Elringus both buttons are in the same image, the bottom button I exported with background from PS and the other I created on unity and positioned above to compare. The triangles are separated PNG with white Tint.
     
  26. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    Oh, I see now. So, if I understand correctly, the problem is with the 2 little triangles inside the big one? Are they done as separate images? If that’s the case, then it looks like each of them is using color dodge blend mode in PS. Please check that in Unity a Blend Mode Effect component is attached to each of them and that the render mode is set to Grab (not Unified Grab).
     
  27. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    428
    Hi @Elringus

    Blend Modes looks like a great asset. Does it already/ do you plan to support the "Color" blend mode (which blends hue and saturation but not luminosity) ?

    Thanks!
     
  28. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    Hi, I’ve researched the component blend modes a bit (Hue, Saturation, Color, Luminosity) and looks like it won’t be too hard to implement them. Will probably add this for the next update. Thanks for the suggestion!
     
  29. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    428
    @Elringus That would be amazing! Do you have an idea of when that might be?
     
  30. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    In a couple of weeks, I think.
     
    flashframe likes this.
  31. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    428
    I will buy two copies if you do :)
     
    Elringus likes this.
  32. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,181
    Just to clarify ... Blend Modes works for meshes, but not skinned meshes, right?
     
  33. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    Actually, it works nearly for any objects via custom material editor. You may create a blend material with desired blend mode and assign it just as any other materials to a skinned mesh or other renderers.
     
    hopeful likes this.
  34. Spellbook

    Spellbook

    Joined:
    May 21, 2015
    Posts:
    15
    Hi @Elringus! This asset is great, but I'm currently running into a problem.

    It seems that whenever an image is using a blend mode it gets rendered in front of everything else. The first screenshot shows the desired effect: The My Fighters button is behind the top bar. The second screenshot shows the My Quests button, which is using a blend mode. When blend modes are enabled the My Quests button is always rendered on top of all of the other UI elements.

    Is there any way around this?

    blend 1.PNG blend 2.PNG
     
  35. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    Hi, I’ve tried to reproduce the issue but it worked ok in my case:



    There I have a square and a circle images in a canvas. Square is placed at Z = 0 with a blend mode effect attached and circle is placed at Z = 10 without a blend mode. As you can see, the square is not rendering “through” the circle.

    Make sure that you are using either Grab of Framebuffer render modes, as the Unified Grab could potentially lead to this kind of problems.

    If the problem persists, please contact me by email with a more detailed setup info or a repro project.
     
  36. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    Version 2.3 with 4 new blend modes (hue, saturation, color, luminosity) and an enhanced editor is now pending review on the store.

    As usually, if you've already purchased the plugin, you may download the new version right away here: https://get-asset.appspot.com/BlendModes
     
    flashframe likes this.
  37. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    428
    @Elringus

    Hoping you can help. I'm getting some intermittent errors using Version 2.3 of Blend Modes on Unity 5.3.2. I tried installing the latest Unity Patch, but it hasn't solved it.

    Sometimes the shader seems to be displaying correctly in the editor, but most of the time I get visual errors, and occasionally a logged error in the console.

    GLSL Compilation Failed:
    ERROR: 0:50: '&&' does not operate on 'bvec2' and 'bvec2'


     
  38. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    I’ve just ran several tests on Unity 5.3.2, but wasn’t able to reproduce the issue you’ve described. Please try to re-download and reimport the package (sometimes they got corrupted). Also make sure that it’s not something project specific (does this issue occurs in a clean project?).

    If the problems persists, please contact me via email with a more detailed info (like what OS you are using, scene setup, steps to reproduce the issue, etc). A simple repro project would also be of great help.
     
  39. Taran3D

    Taran3D

    Joined:
    Jun 13, 2013
    Posts:
    5
    hi elringus

    I have been using the plugin for a while but recently when I came back to it seems to have stopped working.
    I used to be able to make multiple layers of UI Image in a canvas and use the blendmode component to blend them all into each other, it seems to only work on certain layers and doesn't behave like it used to.

    this seems to have stopped working - I have updated to the new plugin, grab mode and am using unity 5.3 of 4 personal

    any ideas
     
  40. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    Hi,

    If that happened after the update, try to delete the package from the affected project and reimport it. Also, make sure you are using Grab or Framebuffer render modes (not Unified Grab) in case you want multiple layers to blend with each other.

    If the above won’t help, please contact me via support email with a more detailed info (scene setup, screenshots, any error messages you may see in the console) and I will assist you further.
     
  41. InfiniteAmmo

    InfiniteAmmo

    Joined:
    Aug 12, 2008
    Posts:
    46
    Does anyone know if BlendModes is supported on PlayStation 4? :)
     
  42. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    428
    Haven't tested it on the dev kit yet, but I don't think there's anything in the shader that wouldn't be supported.
     
  43. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    In theory, it should work ok, as I’m not using anything special or platform-specific in the shaders.
    Please let me know if something will go wrong with it — I will be happy to assist.
     
  44. fullmontag

    fullmontag

    Joined:
    Jan 17, 2016
    Posts:
    1
    How do I do Add blend mode?
    I see Subtract, but no Add...
     
  45. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    Hi, please use the Linear Dodge mode -- it has the same effect as Additive or Add.
     
  46. TeorikDeli

    TeorikDeli

    Joined:
    Apr 6, 2014
    Posts:
    28
    Hi!

    We want to use your plugin for our new game, but our game is for mobile devices. I read that plugin uses framebuffer extension for performance on mobile. We'll probably use 2 or 3 layers (full screen png sprite) for blending and performance is very important thing for our game (for example, 20/25 FPS will cause some problems for the player). We'll support iOS 7.1+, so there is no problem for iOS devices; but on the Android side, I'm not sure which devices supports framebuffer extension (yeah, Tegras, but I don't have any list for all the devices). Is there any way to detect framebuffer extension? So that way, if there is no support on the device, we can use grab or unified grab render mode for fallback (idk which one has more performance on mobile). Or, maybe, not to use blend mode (disabling layer gameobjects) at all, if there is no framebuffer extension.

    Thanks.
     
  47. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    Hi,

    There is actually a way to detect whether the framebuffer_fetch is available, but only inside shaders. Adding this:

    #pragma only_renderers framebufferfetch​

    Right at the start of the CGPROGRAM block will trigger shader fallback if the instruction is not supported. You may then add a fallback to the desired shader which it will use in that case:

    Fallback “BlendModes/UIDefault/UnifiedGrab"​

    This way, devices which supports framebuffer_fetch will use it and all the other will stick with UnifiedGrab mode.

    I’m currently working to integrate this functionality to the plugin, so it will be more user-friendly, but meanwhile you may just send me a request and I will modify the shaders to suite your needs.
     
  48. TeorikDeli

    TeorikDeli

    Joined:
    Apr 6, 2014
    Posts:
    28
    Wow, that's great! So, will be so much impact on the performance, if we use unified grab for fallback with 2-3 full screen layers? I'll send you a request for this, as soon as we purchase and integrate your plugin to our game. Thank you
     
  49. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    572
    The impact will depend on the device, but it should be OK for the most mid-high end ones.

    You may try this WebGL demo to test performance: http://elringus.me/static/blend-modes-webgl/ Just be aware that webgl adds quite an overhead so it will work faster in native environment.
     
  50. s141797

    s141797

    Joined:
    Nov 18, 2014
    Posts:
    7
    Hi

    I´m having trouble getting the FrameBuffer (MeshDefault) shader working on iOS. When i run it on the device I get the following error message in the log output and it fallbacks to the regular diffuse shader:
    (Filename: Line: 649)


    Note: Creation of internal variant of shader 'BlendModes/MeshDefault/Framebuffer' failed.

    Setting up 1 worker threads for Enlighten.

    -------- GLSL link error: ERROR: Input of fragment shader 'vs_COLOR1' not written by vertex shader

    Any idea of how to fix this? SpriteDefault Framebuffer works as expected though. I´m on unity 5.3.4 and using openGL 3.0 on iOS.
     
unityunity