Search Unity

Create Glowing Shader in Unity Shader

Discussion in 'Shaders' started by mekartikshah, Sep 28, 2019.

  1. mekartikshah

    mekartikshah

    Joined:
    Jan 10, 2017
    Posts:
    89
    Hi everyone, I wanted to create this kind of shader



    I created this using shader graph in LWRP and my project is using standard pipeline and i cannot upgrade because it's a pretty huge project with lot many complexions.

    So I wanted to do the same effect using shader editor or amplify. I don't know much about amplify, it would be grateful if anyone can help me in converting my shader to amplify or help me with shader editor. I have created a transparent shader using shader editor, and here is the effect of how it is looking.



    and here is the code for shader editor,

    Code (CSharp):
    1. Shader "Custom/LightIntensityShader"
    2. {
    3.     Properties
    4.     {
    5.         _Color ("Color", Color) = (1,1,1,1)
    6.         _MainTex ("Texture", 2D) = "white" {}
    7.         _Transparency ("Transparency", Range(0.0,0.5)) = 0.25
    8.     }
    9.     SubShader
    10.     {
    11.         Tags { "RenderType"="Transparent" "Queue"="Transparent" }
    12.         LOD 100
    13.  
    14.         ZWrite Off
    15.  
    16.         Blend SrcAlpha OneMinusSrcAlpha
    17.  
    18.         Pass
    19.         {
    20.             CGPROGRAM
    21.             #pragma vertex vert
    22.             #pragma fragment frag
    23.             // make fog work
    24.             #pragma multi_compile_fog
    25.  
    26.             #include "UnityCG.cginc"
    27.  
    28.             struct appdata
    29.             {
    30.                 float4 vertex : POSITION;
    31.                 float2 uv : TEXCOORD0;
    32.             };
    33.  
    34.             struct v2f
    35.             {
    36.                 float2 uv : TEXCOORD0;
    37.                 UNITY_FOG_COORDS(1)
    38.                 float4 vertex : SV_POSITION;
    39.             };
    40.  
    41.             sampler2D _MainTex;
    42.             float4 _MainTex_ST;
    43.             float _Transparency;
    44.             float4 _Color;
    45.  
    46.             v2f vert (appdata v)
    47.             {
    48.                 v2f o;
    49.                 o.vertex = UnityObjectToClipPos(v.vertex);
    50.                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
    51.                 UNITY_TRANSFER_FOG(o,o.vertex);
    52.                 return o;
    53.             }
    54.  
    55.             fixed4 frag (v2f i) : SV_Target
    56.             {
    57.                 // sample the texture
    58.                 fixed4 col = tex2D(_MainTex, i.uv) + _Color;
    59.                 col.a = _Transparency;
    60.                 // apply fog
    61.                 UNITY_APPLY_FOG(i.fogCoord, col);
    62.                 return col;
    63.             }
    64.             ENDCG
    65.         }
    66.     }
    67. }
    68.  


    I just add transparency factor in shader editor and I don't know how to make the border glow and center transparent. Please guide me on how can i proceed.