Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to obtain a Glow Effect for iOS?

Discussion in 'Shaders' started by SirCrono, Apr 3, 2012.

  1. SirCrono

    SirCrono

    Joined:
    Apr 3, 2012
    Posts:
    6
    Hi, I would like to know what is the best way to obtain a glow effect like the following image.

    $Glow.jpeg

    I need to achieve this effect for iOS, any input on how to do it, it's appreciated.

    Thanks.
     
  2. Martin-Kraus

    Martin-Kraus

    Joined:
    Feb 18, 2011
    Posts:
    617
    A coarse approximation might be a semitransparent sphere with additive blending that adds no light when the surface normal is orthogonal to the view direction and more light otherwise. For the implementation a surface shader without lighting should do fine.
     
  3. tigershan

    tigershan

    Joined:
    Jul 29, 2010
    Posts:
    73
    mobile bloom in angry ant does such, but not for every IOS device, I would suggest you only doing this effect ipad2, iphone4s, ipad3
     
  4. Martin-Kraus

    Martin-Kraus

    Joined:
    Feb 18, 2011
    Posts:
    617
    I did a quick test to see whether my idea made any sense:

    $glowtest.jpg

    Code (csharp):
    1.  
    2. Shader "Custom/glow" {
    3.     Properties {
    4.         _Color ("Color", Color) = (1,1,1,1)
    5.     }
    6.     SubShader {
    7.         Tags { "Queue"="Transparent" }
    8.         LOD 200
    9.         ZTest Always
    10.         Cull Off
    11.         Blend One One
    12.  
    13.         CGPROGRAM
    14.         #pragma surface surf Lambert
    15.  
    16.         float4 _Color;
    17.  
    18.         struct Input {
    19.             float3 viewDir;
    20.             float3 worldNormal;
    21.         };
    22.  
    23.         void surf (Input IN, inout SurfaceOutput o) {
    24.             o.Alpha = _Color.a * pow(abs(dot(normalize(IN.viewDir),
    25.                 normalize(IN.worldNormal))),4.0);
    26.             o.Emission = _Color.rgb * o.Alpha;
    27.         }
    28.         ENDCG
    29.     }
    30.     FallBack "Diffuse"
    31. }
    32.  
    33.  
    Edit: Changed "RenderType" to "Queue" and changed decal blending to additive blending with "Blend One One"
     
    Last edited: Mar 19, 2013
    Zmeyk likes this.
  5. renanss

    renanss

    Joined:
    Sep 10, 2012
    Posts:
    38
    Thanks a lot! I'm creating a lamp shader and this worked perfectly.
     
  6. laurelhach

    laurelhach

    Joined:
    Dec 1, 2013
    Posts:
    229
    it's an old thread, but does it work with unity free?
    I know all glow features are Pro only and I am not really expert in shaders...