Advertisement
Guest User

Untitled

a guest
Jan 30th, 2021
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 KB | None | 0 0
  1. Shader "Unlit/TextureGlow"
  2. {
  3.     Properties
  4.     {
  5.         _MainTex ("Texture", 2D) = "white" {}
  6.         _Color ("Color", Color) = (0.0, 0.0, 0.0, 0.0)
  7.         _Glow ("Glow", Range (0.0, 1.0)) = 0.5
  8.     }
  9.     SubShader
  10.     {
  11.         Tags { "Queue" = "Transparent" }
  12.         Blend SrcAlpha OneMinusSrcAlpha ZWrite On
  13.  
  14.         Pass
  15.         {
  16.             CGPROGRAM
  17.             #pragma vertex vert
  18.             #pragma fragment frag
  19.             #pragma target 2.0
  20.  
  21.             #include "UnityCG.cginc"
  22.  
  23.             struct appdata
  24.             {
  25.                 float4 vertex : POSITION;
  26.                 float2 uv : TEXCOORD0;
  27.             };
  28.  
  29.             struct v2f
  30.             {
  31.                 float2 uv : TEXCOORD0;
  32.                 float4 vertex : SV_POSITION;
  33.             };
  34.  
  35.             sampler2D _MainTex;
  36.             // Needed for TRANSFORM_TEX
  37.             float4 _MainTex_ST;
  38.             fixed4 _Color;
  39.             float _Glow;
  40.  
  41.             v2f vert (appdata v)
  42.             {
  43.                 v2f o;
  44.                 o.vertex = UnityObjectToClipPos(v.vertex);
  45.                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  46.                 return o;
  47.             }
  48.  
  49.             fixed4 frag (v2f i) : SV_Target
  50.             {
  51.                 // sample the texture
  52.                 fixed4 col = tex2D(_MainTex, i.uv);
  53.                 // blend color
  54.                 col = (col * (1.0 - _Glow) + _Color * _Glow);
  55.  
  56.                 col.a = _Color.a;
  57.  
  58.                 return col;
  59.             }
  60.             ENDCG
  61.         }
  62.     }
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement