Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Glow Effect (Mobile Friendly)

Discussion in 'Assets and Asset Store' started by opsive, Apr 20, 2013.

  1. Tapgames

    Tapgames

    Joined:
    Dec 1, 2009
    Posts:
    242
    Hi! Just got your plugin from the asset store and it gives me errors in Unity 5.

    When I press play I get this error.

    Failed setting triangles. Some indices are referencing out of bounds vertices. IndexCount: 30, VertexCount: 205
    UnityEditor.UnityBuildPostprocessor:OnPostprocessScene()

    Invalid pass number (1) for Graphics.Blit. Material=Bottom_Glow_Rim, npasses=1
    UnityEngine.Graphics:Blit(Texture, RenderTexture, Material, Int32)
    GlowEffect.GlowEffect:CalculateGlow(RenderTexture, RenderTexture) (at Assets/Glow Effect/Glow/GlowEffect.cs:151)
    GlowEffect.GlowEffect:OnRenderImage(RenderTexture, RenderTexture) (at Assets/Glow Effect/Glow/GlowEffect.cs:134)

    After play the main texture is removes from the slot.
    When I click on a checkbox on the shader for example "Glow using Main Texture" I get this error on every checkbox.

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    System.Collections.Generic.List`1[System.String].CheckIndex (Int32 index) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:419)
    System.Collections.Generic.List`1[System.String].set_Item (Int32 index, System.String value) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:637)
    GlowMaterialInspector.showToggleGUI (System.String friendlyName, System.String keyword) (at Assets/Glow Effect/Editor/GlowMaterialInspector.cs:45)
    GlowMaterialInspector.OnInspectorGUI () (at Assets/Glow Effect/Editor/GlowMaterialInspector.cs:22)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean forceDirty, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, Boolean eyeDropperDirty) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1150)
    UnityEditor.DockArea:OnGUI()
     
  2. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Is that from the demo scene? I just tried it in Unity 5.0.0f4 and all of the different glow modes worked.
     
  3. Tapgames

    Tapgames

    Joined:
    Dec 1, 2009
    Posts:
    242
    I will check the demo scene. This is from a scene of mine.

    Edit: It is working now! :)

    On the Camera I had the wrong material. I thought it needed to be the material from an object that needs to glow. Thanks!
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Just saw your edit - glad you got it working!

    I am working on including a glowing version of Unity 5's standard shader in the next update. Things are going well so it should be released within the next couple of days. Here's a preview of what the material looks like:

    glow shader.PNG
     
  5. Tapgames

    Tapgames

    Joined:
    Dec 1, 2009
    Posts:
    242
  6. manny003

    manny003

    Joined:
    Mar 18, 2014
    Posts:
    69
    Hi there! Love your Asset and it's working great so far. However, I have one small hitch.

    I am using the GE(Glow Effect) on lasers and other particles in my game. All is good. I also have several plain background images that I load during run time that I use the new Unity UI RawImage to display. It also works good. What I was also doing was tinting the image using the RawImage color selector so that I can produce variations on an image at various stages.

    I do not want the background to glow so I used your "Unlit/Texture (No Alpha)" shader to create a material and applied it to the RawTexture. But when I do so, I lose the ability to apply a color tint.

    I tried to use the "VertexLit (No Alpha)" shader and that works to apply a tint but only if the texture is used in the actual material itself and not the RawImage Texture.

    I also turn the material on and off at various stages when I fade in the background (glow script disabled when I do), and I know that I can swap out materials and material textures during run time but would prefer not for fear of overusing GPU memory by inadvertently duplicating texture images in memory.

    My Question: Is it possible to create a "VertexLit (No Alpha)" like shader that allows me to tint the image I'm using in my UI RawImage?

    Thanks,
    Manny
     
  7. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    I haven't used RawImage before so I am still figuring out what it is all about but what shader do you normally use for that type of texture? When I submit the update that includes Unity 5's standard shader I'll go through the current list of built-in shaders and make a standard glow and alpha glow version for each of those. In terms of the VertexLit shader, I guess the problem is figuring out how to pass the RawImage into the Main Texture property, right?
     
  8. manny003

    manny003

    Joined:
    Mar 18, 2014
    Posts:
    69
    Usually, I don't have to apply a material to RawImage. The built in color selector (shown in the screenshot) works right out of the box to allow me to apply a color tint and alpha. Unity however allows for an optional material to be applied -- I supposed if we wanted added special effects.

    However, because the default color selector allows for alpha adjustments, I guess that internally, it must be using an alpha capable shader -- the glow was being applied to the RawImage background.

    That was when I went looking and tried to use one of your "no alpha" shaders -- which works for the most part, I just lost the ability to use the color tinting.

    Also, regarding your mention about "figuring out how to pass the RawImage into the Main Texture property..." -- I imagine that would be the solution -- except that I have absolutely no experience with shader programming.

    That is something I'd like to dig into one day but as I am already a one man show for my app -- shaders is the one area I have to look outside for help.

    Thanks for looking into this.

    Manny
     
  9. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    I downloaded the Unity Samples: UI asset and opened the RenderTexture scene. When I first opened it the scene looks like:

    normal.PNG

    I then applied the GlowEffect script in alpha mode to the UI Camera and everything started to glow as you would expect, including the RawImage:

    all glow.PNG

    If you look at the RawImage GameObject you'll see that it uses the UI Opaque material and that material uses the UI-Default-No-Alpha shader. This shader is included with within the samples asset in the Materials folder. I attached a shader to this post which removes the alpha channel from this shader. When I do that the RawImage no longer glows:

    no rawimage glow.PNG
     

    Attached Files:

  10. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Version 1.4.4 of the Glow Effect is now on the Asset Store. This version adds Unity 5's standard shader and the UI shaders to the built in shaders package.
     
  11. manny003

    manny003

    Joined:
    Mar 18, 2014
    Posts:
    69
    Wow, you are THE man. That did the trick. Using your modified shader, I was able to set an image to the RawTexture, attach a simple material which uses your shader and adjust the color tint using the RawImage color slider.

    Bonus -- I only have to adjust the color slider of the RawImage gameObject. The shader itself seems to be tied to that slider somehow so that if I wanted to alpha fade, all I have to do is set the RawImage's material to null and the color tint stays and the alpha channel is re-enabled.

    Awesome. Everyone who hasn't done so, buy this guy's Asset. Give him money!

    Thanks,
    Manny
     
    Last edited: Mar 7, 2015
  12. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    That's awesome! The UI-Default-No-Alpha shader has also been included in the latest release. If you don't mind leaving a review on the Asset Store I would really appreciate it :)
     
  13. manny003

    manny003

    Joined:
    Mar 18, 2014
    Posts:
    69
    I might have spoken too soon. Everything looks great in Unity Player/Editor but when I build to iOS device using the "Metal" Graphics API, and the Alpha Glow option, I get artifacts popups -- background images/textures that aren't even in the scene begins to appear in the background -- this happens both with and without the new RawImage shader you recently provided.

    No idea what's going on here. Have to see it for yourself. Again, in Unity Player, it all works as expected, as well as using the legacy Open GL ES 2.0 & 3.0 on actual iOS devices.

    Only when using the new "Metal" API does it all fall apart.

    Of course, the obvious solution would be to refrain from using Metal as this point -- but to a performance obsessed geek like myself, that's a hard pill to swallow.

    Maybe it's a bug with Unity's implementation of Metal -- don't know at this point.

    Any ideas out there?
    Bummer.
     
    Last edited: Mar 10, 2015
  14. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Unfortunately that sounds like a bug on the Unity side. Metal does have its own shading language but Unity is supposed to automatically covert to it. It sounds like a bug in this process - my suggestion would be to file a bug with Unity.
     
  15. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
    Hi opsive, is it possible to use Glow Effect to light up 2d sprites? Something like this:


    The glowing of the white plant is lighting up its surrounding stones. Previously I was using a modified version of Glow11 to achieve this effect, but the author of that plugin vanished and so did his plugin vanish from Asset Store too. I was not able to find him to help me on solving some performance issue of Glow11.

    It feel that Glow Effect would be possible to be integrated in my project to replace Glow11, but before purchasing I would like to have your opinion;D Thanks a lot
     

    Attached Files:

  16. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Thanks for taking a look at Glow Effect. What modifications did you make to Glow11 to get it to work? You'd probably have to make a similar modification to Glow Effect. The glow does not emit any light.
     
  17. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
    Thanks for your prompt reply. However I did not know how the author tailored Glow11 for me, I just asked him if it's possible and he said yes, and made a modified version which is perfect to use.

    I am sorry as an artist I do not know shader well, and Glow 11 is no longer working with latest version of Unity 5, that why I am turning to Glow Effect. By " light up", I do not mean something like unity light that actually emit light, I mean the effect that the glow is illuminating the underlying sprite as a 2d image based effect, in photoshop I could achieve this effect by setting layer blend mode to maybe lighten, or soft light mode.

    It's very appreciated that you can help me on this, many many thanks;D
     
  18. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    I was playing around with it and you actually shouldn't need to make any modifications to the Glow Effect script or core shader, just use a custom sprite shader that I have included in the Unity package at the end of this post. I downloaded the Unity Sample Assets package and opened the 2D scene. I then added the glow effect along with a sprite using the attached shader and got the following results:

    glow.PNG

    This scene is within the Unity package as well. Make sure you have first imported the Sample Assets package otherwise it won't work. Also, I used the SampleAssets/Effects/LightCookies/Texture/LightSoftCookie asset as the area defining the glow so make sure you first mark it as a sprite:

    sprite.PNG

    Then the only thing that you need to do is use a Multiple blend mode instead of Additive:

    multiply.PNG
     

    Attached Files:

  19. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
    Hi Opsive, I tried with your workflow, and it work!! Thanks for your detailed explanation. However when I was tweaking the parameters of the Glow Effect script on the main camera and lower the downsample size to 64, the glowing halo is not a circle anymore, it becomes an ellipse. Is there any way to solve this?

    Greatly recommended plugin for wonderful and prompt support, if anyone hesitate that what is the perfect per object Glow Effect plugin, try this!!!
     

    Attached Files:

  20. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    It's great to hear that you got it working! In terms of the ellipse, what is your game resolution set at? I bet if you increase the height of the game within the editor it'll become more of a circle again. I think that this is occurring because the Glow Effect uses the camera's resolution in order to draw the glow. The easiest way to fix it would be to first decide on a downsample size that you want to use, then modify the shape of the glow texture so the end result is the correct shape..
     
  21. JuanCamiloAlcaraz

    JuanCamiloAlcaraz

    Joined:
    Apr 30, 2014
    Posts:
    7
    Hi, I want to know if this glow effect works behind transparent shaders in mobile devices.

    Thanks.
     
  22. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Yes, it definitely can. You'll probably need to use the standard glow and not alpha glow just because you are dealing with transparent objects.
     
  23. Rhive

    Rhive

    Joined:
    Apr 6, 2015
    Posts:
    1
    Greetings, I am interested in using your plugin. I am just wondering how it would work with sprites, do you have a sample image of the plugin working with them? Thank you very much
     
  24. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Hello,

    It does work with sprites with the caveat that alpha glow takes some setup if you want to use that glow method. Here is a screenshot of a sprite with glow when I first got it working, this is using the standard glow method.

    Since alpha glow uses the object's alpha value to determine how much to glow, with sprites it is a problem because normally the sprite uses the alpha value for transparency. In order to get the sprite to work with alpha glow, you have to generate a mesh that conforms to the exact outline of the sprite. This then prevents the sprite from having any transparency so it can then use alpha glow. Standard glow works with sprites out of the box though :)
     
  25. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,086
    Hey Opsive, I'm trying to migrate to Unity 5, and use the standard shader glow version you provide in the package... but I don't see any of the options in the shader? I want to use a glow texture to mask what parts of my object glow, but I don't see the toggles that are in your screenshot of the glow standard shader above.

    Mine looks like this:



    EDIT: I see the options in the specular setup standard (glow), but not the regular standard glow.

    Also, when my glow is on, if there is a particle system in front of it it blocks it out... is there any way around that?
     
    Last edited: Apr 22, 2015
  26. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    I just extracted the Glow Effect into a new Unity 5 project and the standard shader glow came in correctly -

    standard.PNG

    Maybe try reimporting?

    From the demo scene I changed it so the fireworks use an alpha blended shader which has no glow to it. Here's what I see:

    particles.PNG

    The particles are in front of the glowing but since they have an alpha to them the glow shows trough. I suspect what you are seeing is an unsolved problem in computer graphics: depth testing with two transparent objects. When two transparent objects overlap in different areas there is no good solution to determine which object is in front.
     
  27. manny003

    manny003

    Joined:
    Mar 18, 2014
    Posts:
    69
    Need some help creating a glow alpha texture please.

    I am trying like the dickens to add an alpha channel to a stock Unity star particle image (attached). Know that I've never done anything like this before and nothing I've tried seems to work.

    I am wanting to use this to for Glow Using Alpha for iOS. Could someone add the alpha channel for me and maybe provide me with instructions on how to do this in the future?

    The original file is Star02.png. My attempt using Photoshop CS4, unsuccessful I might add, was the tga version, which I am not allowed to upload to this forum.

    Thanks,
    Manny
     

    Attached Files:

  28. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Do you want to add or remove glow to that image? All PNG-32 images have an alpha channel so it's more of a matter of making sure the alpha channel value is correct. You can change the alpha value by opening up the channel panel and change the value from there.

    Keep in mind though that since that image has its own transparency, you won't be able to stop the glow from occurring. The reason for this is because in order for the object not to glow, you have to set the alpha value to 0. However, if you set the alpha value to 0 with a transparent object then the object is going to completely disappear.

    The fix for this is to either use the standard glow or generate a mesh based on the pixel alpha values. This will then mean that the object does not have to be rendered in the transparent queue so the alpha channel can be used for the glow amount instead of transparent omount
     
  29. Tapgames

    Tapgames

    Joined:
    Dec 1, 2009
    Posts:
    242
    Can I show this glow effect behind a glass/transparent object?
     
  30. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Yes. Here's the demo scene with a red transparent plane just in front of the camera:

    Capture.PNG
     
  31. Tapgames

    Tapgames

    Joined:
    Dec 1, 2009
    Posts:
    242
    Is this in your demo scene? when I put a transparent object in front of the camera all glow is gone. Do I need a script to help with this?
     
  32. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Yes, that was the demo scene using the standard glow. What you may be running into is described at the end of this post dealing with depth testing and transparent objects.
     
  33. manny003

    manny003

    Joined:
    Mar 18, 2014
    Posts:
    69
    Would it be possible to have "No Alpha" versions for the Unity 5 standard assets Skybox shaders?

    Thanks in advance.
     
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Do you know which set of shaders the skybox uses? There is a "Skybox/6 Sided (No Alpha)" version included in the built-in shaders package (Glow Effect/Shaders/Built In Shaders)
     
  35. lechautu

    lechautu

    Joined:
    Mar 3, 2015
    Posts:
    5
    Hi,
    I've been trying to use your Glow Text on Ipad 2 and iphone 4 and the performance is really bad, if i turn Glow Effect component on, FPS goes down to 7, but when i turn it off, FPS goes up to 60. I tested it on other device like ipad air 2, iphone 4s and 5, it works fine.
     
  36. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Are you using standard or alpha glow? If you are using standard glow then it renders the glow as any other image effect which basically doubles the draw calls. Alpha glow is much better for older mobile devices as it doesn't have to render the entire scene again in order to work.
     
  37. Ululab

    Ululab

    Joined:
    Aug 4, 2015
    Posts:
    1
    Hi there!

    We're really interested in getting this tool, but had a question before we try it out.

    From what I understand, this package isn't compatible with the Metal API. Is there any way we can use this tool without changing graphics API for the whole project? (disabling "Automatic Graphics API" in player settings and prioritizing OpenGL)

    Thanks for the quick support too, great to see responsive devs :)
     
  38. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Thanks for taking a look at Glow Effect!

    You're talking about the iOS metal API, correct? Where did you read that it isn't compatible? I just tested the demo scene and it worked without a problem. The transition to Metal should be seamless so if there's a problem with it you should report the bug to Unity.
     
  39. ZannaU

    ZannaU

    Joined:
    Mar 24, 2013
    Posts:
    17
    Hi,

    I just purchased the Glow Package and I’m working on getting it setup in our game.

    I have some 2D objects that rotate and I need to show both sides. I did a small change to the GlowAlphaBlend.shader by adding ‘Cull Off’. With this I can see both sides of the texture but the glow effect still only apply to on one side.

    Do you have any suggestions on how to make the glow effect work on both sides?

    I’m currently using the regular glow effect even if we are working on a mobile project because we have lots of 2D content that use transparency. We have textures with a transparent fade effect so using the trick to map the sprite on a mesh won't work either. I’m hoping to mange to fit it in the budget. I noticed that simple glow don’t have a significant gain compared to the regular glow effect (approx. 1ms on the slowest devices: iPhone 4S, iPad2).

    Thanks for your help!
     
  40. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    When the glow is rendered it is done using a separate shader. You'll need to make sure you add the "Cull Off" property to the glow shader as well. It's located in the GlowReplace shader - if you are using the GlowAlphaBlend shader then you'll want to add it to the second SubShader (the one with the GlowTransparent render type)
     
  41. ZannaU

    ZannaU

    Joined:
    Mar 24, 2013
    Posts:
    17
    Thanks for the suggestion Opsive. That solved the issue. Unfortunately the regular glow is actually slower than our previous solution we were hoping to substitute with your package so we won't be able to use it.

    The alpha glow was actually nice and fast. Is there any anything we ca do to use alpha glow style with transparent sprite? Could we base the glow only on the alpha of the glow mask rather than the whole texture?
     
  42. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Sure - the alpha glow version uses the second pass of GlowEffect.shader and within the fragment shader you'll want to use the glow texture instead of the main texture.

    Code (csharp):
    1.  
    2.          fixed4 mainTex = tex2D(_MainTex, i.uv);
    3.  
    becomes::

    Code (csharp):
    1.  
    2.          fixed4 mainTex = tex2D(_Glow, i.uv);
    3.  
    Where you make sure you define _Glow for that pass:
    Code (csharp):
    1.  
    2.        uniform sampler2D _Glow;
    3.  
     
  43. ZannaU

    ZannaU

    Joined:
    Mar 24, 2013
    Posts:
    17
    Hi Justin,

    Thanks for the help. I tried your suggestions without success. Sorry to bother you but I worked in all kind of game programming except rendering and shaders.

    For what I’m understanding the glow pass is done in GlowEffec:: CalculateGlow

    We grab a temp Render texture here
    147 RenderTexture blurB = RenderTexture.GetTemporary(downsampleSize, downsampleSize, 0, RenderTextureFormat.ARGB32);

    Then we set it to the _Glow parameter
    151 glowMaterial.SetTexture("_Glow", blurB);

    And here we call the pass 2 for the alpha Glow
    154 Graphics.Blit(source, blurB, glowMaterial, 2);

    With the changes you mentioned we discard the main texture (source) and do a pass of blurB to blurB which gives random result.

    If I understand correctly OnRenderImage is called once the entire screen has been rendered. Do we still have access to the _Glow_Mask texture of the individual objects at this point?

    Thanks for your help.
     
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    I wasn't thinking last night :confused: You're correct - that method won't actually work because the image has already been drawn. What would be possible is to have an alpha value of 0 mean glow and alpha value of 1 mean no glow, but this may not help for your particular case. What we'll probably need to do is to get the standard glow's speed up to par - have you tried playing with the various parameters to see what sort of impact that has on the speed?
     
  45. iyenal222

    iyenal222

    Joined:
    Dec 7, 2014
    Posts:
    9
    Can I use it for glowing trail renderer ?
     
  46. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Standard glow can, but the alpha glow cannot because the trail renderer uses a transparent shader.
     
  47. iyenal222

    iyenal222

    Joined:
    Dec 7, 2014
    Posts:
    9
    @opsive How can I use standard glow with trail renderer ?
    There are a material of your demo scene can I use in trail renderer ?

    Thanks.
     
  48. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    If you extract the package within Shaders/BuildInShaders you'll get a glowing version of all of Unity's built in shaders. The trail renderer uses the Particles AlphaBlended shader so you can use the glowing version of that.
     
  49. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Hey dude @opsive , I have a old project that uses,

    GlowEffect.cs + GlowEffectDownsample shader

    Currently upgraded project to Unity 5.3.3 and was told that this use to be a effect bundled with Unity now long gone, not sure which version was the last. Can you asset replace the old Unity script I have?
    Just remove old script and update with yours?, I do plan to make it on mobile the game.

    Any advice would be most helpful, thank you.
     
  50. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Are you sure you're using our version of the Glow Effect? We don't have a GlowEffectDownsampler shader. Also the current works with Unity 5.3.3 - try removing the Glow Effect folder and downloading it again from the Asset Store.