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

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Hi, Thank you for the suggestion! As far as I know, TextMeshPro is planned to be included in Unity 2018.1 (it’s not a part of the engine yet). In its current state TextMeshPro has no ‘legit’ way to apply a custom material for rendering (which is required to implement blend mode effect) and I’m not sure forcing users to ‘hack’ a third-party asset is a good idea :) When TextMeshPro will be actually integrated to the engine I hope it will be refactored in a way that will allow applying custom materials (like all the other built-in renderers). For the time being, in case you wish to use blend mode effects with TextMeshPro, I can try to work out some temporary solution.
     
    ina likes this.
  2. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    873
    Wow, thanks for the fast response - maybe: https://docs.unity3d.com/Manual/SL-Blend.html
     
  3. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    That’s one of the ways to implement blend mode effect, though extremely limited one. I believe it’s only possible to achieve about five blend modes with this and there will be problems with alpha blending as well. In any case, this method also requires to modify the shaders and use custom materials to apply the effect.
     
    ina likes this.
  4. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    873
    Yeah, what would be a better temporary solution?
     
  5. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    I still need to take a closer look on how TextMeshPro is working, but I believe it should be possible to extend it’s custom material editor and manually swap render materials. If you’ve already purchased BlendModes, please contact me via support email with the invoice number and specify which TextMeshPro shader you would like to use with the blend mode effect (bitmap, SDF, surface, etc) and I’ll try work this out.
     
    ina likes this.
  6. lightbreak

    lightbreak

    Joined:
    May 24, 2014
    Posts:
    6
    Hi! I'm looking to purchase the plugin but a quick question.
    does it have any issues when built for mobile? android and ios.
     
  7. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Hi, There are no issues I’m currently aware of. Though, one thing to consider is performance: in grab and unified grab render modes the effect uses a grab pass which could hurt the performance on older Android devices (iOS devices won’t suffer from this, as they could use framebuffer optimization). Usually, that’s not a problem even for Android devices as far as you use either one instance of the effect or multiple instances in the unified grab mode (where one grab pass will be shared for all the instances). You can find more about available render modes and performance suggestions in the docs: https://goo.gl/tSAmB7
     
  8. amisner2k

    amisner2k

    Joined:
    Jan 9, 2017
    Posts:
    30
    Hi, your asset looks promising, but I have a unique masking scenario that I'm hoping will be covered. I'm using multiple SpriteMask components, each on their own game objects that use a SpriteRenderer (these are parts of a space ship). I then have one or more game objects using SpriteRenderer as decal sprites that I need to be masked by the ship part sprites. I rely on the use of sprite sort layers for both the ship part sprites (for controlling which part appears over others) and also sort layers for the SpriteMask component itself.

    Will your asset work with SpriteMask out of the box? Or at all with some special setup? I want to use your plugin for the decals so that I can control how they're "painted" on top of the ship parts and I'm hoping my advanced setup will be compatible.

    Thanks for your time!
     
  9. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Hi! In case your current setup is based on the built-in Unity shaders, there should be no problems in applying Blend Modes. The plugin has its own masking system out of the box and support for the Unity sprite masks via the custom materials feature. Sprite sort layers are also supported.

    For the best convenience I'd recommend using the built-in masking solution as following:
    1. Add BlendModeEffect components to the parts of the ship that should serve as masks and set blend mode to ‘normal’, render mode to ‘overlay’ (so it won’t execute a grab pass) and enable ‘auto mask’ checkbox;
    2. Add BlendModeEffect components to the overlay sprites, select desired blend mode, set render mode to ‘unified grab’ for the best performance, set mask mode to ‘nothing but mask’ and mask behavior to ‘cutout’.
     
  10. amisner2k

    amisner2k

    Joined:
    Jan 9, 2017
    Posts:
    30
    Thanks! I think you earned yourself a sale. :)
     
  11. alfa1993

    alfa1993

    Joined:
    Aug 20, 2015
    Posts:
    28
    hi, i tried to animate blend modes but it does not work, when I use Editor it works
     
  12. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Hi, Thank you for reporting the issue! It’s now fixed; the update will be available on the store in the next several days. If you wish to get the updated package right now, please contact me via support email (or PM here) with the invoice number.
     
  13. alfa1993

    alfa1993

    Joined:
    Aug 20, 2015
    Posts:
    28
    I think i have another bug. I have to children. Each of them has BlendModesEffect. I I modify the values of one of the children in blend mode, the other one is being changed.
    So what can I do?
     
  14. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Unfortunately, I wasn’t able to reproduce the issue you’ve described. Can you please send me a repro project?
     
  15. Chocola

    Chocola

    Joined:
    Apr 26, 2018
    Posts:
    3
    Hi. I use iMac and i applied this asset to my UI, and pushed to Github. Then my coworker who use Window pulled the project and played the scene where i implemented this asset, Unity suddenly shuts down. Unity shuts down not only when we play the scenes, but also when we click those scene in the editer. The demo scene plays with no problem. Can you do something about this?
     
  16. Chocola

    Chocola

    Joined:
    Apr 26, 2018
    Posts:
    3
    Ok, We tried everything and found out when we check "allow HDR" in Camera component (in Window PC), Unity shuts down. Please solve this problem.
     
  17. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Hi,

    Unfortunately, I wasn’t able to reproduce the issue (I’ve tried Unity 2017.4 and 2018.1 on Windows PC). The issue could be related to some specific project settings or scene setup. Can you please provide a repro project for the further investigation?
     
  18. Chocola

    Chocola

    Joined:
    Apr 26, 2018
    Posts:
    3
    Hello,

    My Unity version is 5.6.3 and here is how to reproduce the issue.
    1) Change build setting from PC to Android
    2) Create Sprite Image
    3) Add "Blend Mode" Component
    4) Unity shuts down
     
  19. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    I’ve tried it with Unity 5.6.5 and 5.6.6, but still no issues. I suspect this could be related to the fact, that on Asset Store, there are package versions for Unity 4.6.3, 5.6.5 and 2017.4. When you’re downloading the package with Unity 5.6.3, you could be getting the one for 4.6.3. Please try to update Unity to either 5.6.5 or 5.6.6, then delete the Blend Modes package from the project and re-download it from the store.
     
  20. samjoly

    samjoly

    Joined:
    Apr 23, 2013
    Posts:
    30
    Hi everyone,
    I am on Unity 2018.2.0f2. I need to mask a SpriteRenderer with a MeshRenderer. I tried to use BlendModes for that, but without success so far. Do you know if it even possible with it, or if I should just take another approach?
    Thanks
     
  21. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Hi! BlendModes starting with version 3 supports native Unity masks, but if you need exactly a mesh mask, you could try creating a material based on the attached shader and assigning it to a mesh. It should work just like the other masks (the mesh won't be visible to the user, but will mask the objects rendered after it).
     

    Attached Files:

  22. nirnirle

    nirnirle

    Joined:
    May 14, 2014
    Posts:
    1
    Hi,
    Just bought your package, and i'm disappointed to see there is no "pass through" blend mode,
    which is quite popular in photoshop.
    Is there any way to add it?
     
  23. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Hi, The "Pass Through" blend mode is an effect specific to the Photoshop's "layer group" feature, and is not really the same thing covered by the "Blend Modes" package; I'm not sure if this concept could even be applied to Unity objects. In theory, it's possible to implement something similar to layer groups for UI or sprites, but it will be out of the scope for this solution.
     
  24. fastgamedev

    fastgamedev

    Joined:
    Mar 27, 2014
    Posts:
    91
    @Elringus

    I upgraded to 3.1 from 2.15, and my scenes are now broken because I missing the extra shaders that BlendModes came with. For example, I have a material with MaskableUI shader, that's missing the shader now. Are these extra shaders gone now? I wouldn't want to have to go and add Blend Mode Effect script to every gameobject that uses these shaders.
     
  25. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    The old `extra shaders` collection is now replaced with the shader extension feature, which allows users to manually add any custom shaders to be used with the effect. The change was necessary, as the `extra` stuff was getting bigger and bigger, adding compile time and complexity to the package, while only few users actually used it.

    However, regarding the old `MaskableUI` shader: you actually don't need any special shaders with the new version, as the Unity masks are now supported out of the box. Just select an appropriate `Mask Mode` in the `Blend Mode Effect` component and it should become affected by both UI and Sprite masks.
     
  26. fastgamedev

    fastgamedev

    Joined:
    Mar 27, 2014
    Posts:
    91
    I understand your reasoning.

    To confirm, before I could assign MaskableUI shader to a material and use that material in gameobjects without adding Blend Mode Effect component to these gameobjects. After upgrading to 3.1, I need to set the shader in that material to DefaultUI and add Blend Mode Effect component to every gameobject that used this shader. Correct?
     
  27. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Correct, although you can skip changing shaders to `DefaultUI`, as the `Blend Mode Effect` component will automatically set an appropriate material to the objects.
     
  28. TheSwanCollective

    TheSwanCollective

    Joined:
    May 6, 2016
    Posts:
    11
    Elringus, this is the most artistic, useful, cheap and wonderful add-on ever! Thank you SO, SO much <3
     
    Elringus likes this.
  29. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Thank you for the kind words! I'm glad you found it useful :)
     
  30. NeoSu

    NeoSu

    Joined:
    Aug 11, 2013
    Posts:
    15
    Hi, Elringus.
    I just update the plugin to 3.3 and found you did some changes to it. Overall it's improvements and like it much.
    The problem is, it seems the "Extension Shader Properties" on BlendModes is not able to serialize to prefab correctly and also cause error when trying to do so.

    here's some reference:



     
  31. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Hi, Thanks for letting me know! I was able to reproduce the issue and is now working on the fix. I'll send you an updated version as soon as it's ready.
     
  32. NeoSu

    NeoSu

    Joined:
    Aug 11, 2013
    Posts:
    15
    Wow such efficiency! I already got an updated version from Elringus's message and so far it's working smoothly! GJ on that Elringus!
     
    Elringus likes this.
  33. FlorentFal

    FlorentFal

    Joined:
    Nov 20, 2015
    Posts:
    54
    Hello @Elringus,

    I've got following error on Android at app startup:
    Code (CSharp):
    1. 11-16 09:14:39.330 25465 25486 I Unity   : SystemInfo CPU = ARMv7 VFPv3 NEON, Cores = 8, Memory = 3396mb
    2. 11-16 09:14:39.330 25465 25486 I Unity   : SystemInfo ARM big.LITTLE configuration: 4 big (mask: 0xf0), 4 little (mask: 0xf)
    3. 11-16 09:14:39.331 25465 25486 I Unity   : ApplicationInfo com.Falcy.Luminos version 0.1 build 28d70b67-e5b8-4b76-85ee-3c7230875deb
    4. 11-16 09:14:39.331 25465 25486 I Unity   : Built from '2018.3/staging' branch, Version '2018.3.0b8 (fa755def4b97)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'armeabi-v7a'
    5. 11-16 09:14:39.592 25465 25486 D Unity   :  GL_EXT_debug_marker GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth24 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_EXT_read_format_bgra GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_image_external_essl3 GL_OES_EGL_sync GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_required_internalformat GL_OES_vertex_array_object GL_OES_mapbuffer GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_EXT_texture_type_2_10_10_10_REV GL_OES_fbo_render_mipmap GL_OES_element_index_uint GL_EXT_shadow_samplers GL_OES_texture_compression_astc GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_hdr GL_KHR_texture_compression_astc_sliced_3d GL_KHR_debug GL_EXT_occlusion_query_boolean GL_EXT_disjoint_timer_query GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_OES_get_program_binary GL_OES_texture_3D GL_EXT_texture_storage GL_EXT_multisampled_render_
    6. 11-16 09:14:39.592 25465 25486 D Unity   : to_texture GL_OES_surfaceless_context GL_OES_texture_stencil8 GL_EXT_shader_pixel_local_storage GL_ARM_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch_depth_stencil GL_ARM_mali_program_binary GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EXT_texture_sRGB_decode GL_EXT_texture_sRGB_R8 GL_EXT_texture_sRGB_RG8 GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_OES_texture_storage_multisample_2d_array GL_OES_shader_image_atomic GL_EXT_robustness GL_EXT_draw_buffers_indexed GL_OES_draw_buffers_indexed GL_EXT_texture_border_clamp GL_OES_texture_border_clamp GL_EXT_texture_cube_map_array GL_OES_texture_cube_map_array GL_OES_sample_variables GL_OES_sample_shading GL_OES_shader_multisample_interpolation GL_EXT_shader_io_blocks GL_OES_shader_io_blocks GL_EXT_tessellation_shader GL_OES_tessellation_shader GL_EXT_primitive_bounding_box GL_OES_primitive_bounding_box GL_EXT_geometry_shader GL_OES_geometry_shader GL_ANDROID_extension_pack_es31a GL_EXT_gpu_shader5 GL_OES_gpu_shader5 GL_EXT_texture
    7. 11-16 09:14:39.592 25465 25486 D Unity   : _buffer GL_OES_texture_buffer GL_EXT_copy_image GL_OES_copy_image GL_EXT_shader_non_constant_global_initializers GL_EXT_color_buffer_half_float GL_EXT_color_buffer_float GL_EXT_YUV_target GL_OVR_multiview GL_OVR_multiview2 GL_OVR_multiview_multisampled_render_to_texture GL_KHR_robustness GL_KHR_robust_buffer_access_behavior GL_EXT_draw_elements_base_vertex GL_OES_draw_elements_base_vertex GL_EXT_protected_textures
    8. 11-16 09:14:41.873 25465 25486 E Unity   : NotSupportedException: System.Configuration.ConfigurationCollectionAttribute::.ctor
    9. 11-16 09:14:41.873 25465 25486 E Unity   :   at System.Configuration.ConfigurationCollectionAttribute..ctor (System.Type itemType) [0x00000] in <00000000000000000000000000000000>:0
    10. 11-16 09:14:41.873 25465 25486 E Unity   :   at System.MonoCustomAttrs.GetCustomAttributesBase (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inheritedOnly) [0x00000] in <00000000000000000000000000000000>:0
    11. 11-16 09:14:41.873 25465 25486 E Unity   :   at System.MonoCustomAttrs.GetCustomAttributes (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) [0x00000] in <00000000000000000000000000000000>:0
    12. 11-16 09:14:41.873 25465 25486 E Unity   :   at BlendModes.ComponentExtension.GetExtensionMap () [0x00000] in <00000000000000000000000000000000>:0
    13. 11-16 09:14:41.873 25465 25486 E Unity   :
    14. 11-16 09:14:41.873 25465 25486 E Unity   : (Filename: currently not available on il2cpp Line: -1)
    My project is running on Unity 2018 beta & I have to push a bit more investigations but at first look, do error message give you some insight on what could going one ?

    Other question, in your documentation you write "Make sure your project has enough “free” keywords before importing the package. . Where/how to check the free keywords counter ?

    Thank for you help

    Florent
     
  34. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Hello,

    Seems like it’s a regression issue with Unity’s IL2CPP compiler not supporting GetCustomAttributes method (it was working in 2018.1). Mono backend is still working fine though. I’ve filed a bug report and will let you know in case I'll get any additional info on this. Here is the issue on the tracker: https://issuetracker.unity3d.com/is...em-dot-type-dot-getcustomattributes-type-bool

    Regarding the seconds question, I’m not currently aware of an any built-in way to count used shader keywords. You can, however, estimate the number, considering that there are 256 keyword "slots" in total and about 60 of them is used by Unity itself. You can find more info about the shader variants in the docs: https://docs.unity3d.com/Manual/SL-MultipleProgramVariants.html
     
    Last edited: Nov 23, 2018
  35. FlorentFal

    FlorentFal

    Joined:
    Nov 20, 2015
    Posts:
    54
    Thanks !
     
  36. NobleRobot

    NobleRobot

    Joined:
    Jan 14, 2016
    Posts:
    33
    I just updated this asset to 3.4 and it instantly broke every BlendMode instance in my game. The result is the dreaded magenta shader. :-(

    The error I get in the console (sometimes) is:
    Shader error in 'Hidden/BlendModes/UIDefault/Grab': failed to open source file: 'BlendModesCG.cginc'


    The BlendModesCG.cginc file does exist, and is located in "/BlendModes/Shaders/" where I believe it's always been. I'm not doing anything particularly interesting or off-label with this asset in my game, just applying the Blend Mode Effect component to a few UI elements.

    I do place all my asset store assets and 3rd-party libraries in an "Assets/Libraries/" sub-folder (for the sake of my sanity), but that's the only non-standard thing about my installation and it hasn't been a problem for this asset in the past.

    Any idea what I need to do to fix it?
     
  37. NobleRobot

    NobleRobot

    Joined:
    Jan 14, 2016
    Posts:
    33
    I tried to delete and reimport the asset, and sure enough, it put some files in "Assets/BlendModes" and some other files in "Assets/Libraries/BlendModes"

    Also, when I try to install the UI extension, it copies a new, incomplete version of the entire asset into "Assets/Libraries/BlendModes" even when I've manually moved everything back to "Assets/BlendModes" .

    I'm going to keep fumbling around with it, hoping I can somehow just install it fresh. I trust that nothing is actually "broken," but this isn't a fun upgrade experience. :-(
     
  38. NobleRobot

    NobleRobot

    Joined:
    Jan 14, 2016
    Posts:
    33
    Got it working again, but it did require a complete removal, Unity restart, reimport asset, another Unity restart, then reinstall of each extension. I guess I should blame Unity's handling/caching of meta files? :p



    Here's an example of what I'm using it for. I love this asset.
     
    Elringus likes this.
  39. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Hi! I'm sorry you've had such a frustrating upgrade experience. It could be due to updating a pre-3.0 version without a complete removal of the package as it's recommended in the update notes. I'm glad you was able to resolve the issue, feel free to contact me again should you have any questions.
     
  40. NobleRobot

    NobleRobot

    Joined:
    Jan 14, 2016
    Posts:
    33
    I didn't start using the asset until recently, definitely post-3.0, so that wasn't the issue.
     
  41. NobleRobot

    NobleRobot

    Joined:
    Jan 14, 2016
    Posts:
    33
    I'm continuing to get random warnings with the latest version. Two in particular are showing up multiple times:

    Fixing reference to the runtime script in scene file!

    and
    The class named 'BlendModes.UIImageExtension' is not derived from MonoBehaviour or ScriptableObject!


    Both of these point to UIImageExtension.cs but I have no idea what the problem actually is. I am nearly certain that these warnings are "wrong" in that they don't actually describe the issue (I doubt UIImageExtension is supposed to be a MonoBehaviour, for example).
     
    Last edited: Dec 5, 2018
  42. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    That could be related to the broken GUIDs you've mentioned before. Some objects on the scene are referencing a wrong component (in this case UIImageExtension, which is not a MonoBehaviour, thus can't be used as a component). Try to find those gameobjects and remove the broken references.
     
  43. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Warning regarding a recent Unity 2018.3 release

    Due to a regression issue, when built with IL2CPP scripting backend `Blend Mode Effect` script will fail to work. The issue is fixed in Unity 2019.1 alpha and is expected to be fixed in the upcoming 2018.3 patch. In case you're using Blend Modes v3.0 or later under IL2CPP scripting backend, please either refrain from updating to the new version until the patch is released or switch to Mono backend. Sorry for the inconvenience.

    UPDATE: The issue is fixed in 2018.3.5f1 patch release.
     
    Last edited: Apr 1, 2019
  44. chanon81

    chanon81

    Joined:
    Oct 6, 2015
    Posts:
    157
    Did they fix this yet in 2018.3.2f1 ?
     
  45. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    They didn't, unfortunately. I'm monitoring the patch releases and will post here when the issue is fixed.
     
  46. hurleybird

    hurleybird

    Joined:
    Mar 4, 2013
    Posts:
    92
    Fixed in 2018.3.5
     
    chanon81 and Elringus like this.
  47. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Confirmed! Thanks for the notice :)
     
  48. fakegood

    fakegood

    Joined:
    Oct 11, 2013
    Posts:
    25
    Hello, I am using Unity 2018.3.8f1 and Blendmode Version 3.6.

    I am getting error at
    Code (CSharp):
    1. BlendModes.ComponentExtension.GetExtensionMap()
    in XCode.

    Have you tested on this version and the build for iOS on IL2CPP, .NET 4.x equivalent scripting runtime and .NET Standard 2.0 api compatibility level?
     
  49. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    541
    Hi, Thanks for letting me know about the issue! I will test this and get back here with the results asap.
     
    fakegood likes this.
  50. fakegood

    fakegood

    Joined:
    Oct 11, 2013
    Posts:
    25
    i think i would like to add on that it works on .NET 3.5 equivalent but not on .NET 4.x equivalent on Unity 2018.3.8f1.
     
    Last edited: Mar 14, 2019
    Elringus likes this.
unityunity