Guest User

SimpleSpriteOverlay.shader

a guest
Jan 31st, 2020
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Hidden/Simple Sprite Overlay"
  2. {
  3.     Properties
  4.     {
  5.         [HideInInspector]_MainTex("Texture", 2D) = "white" {}
  6.         _RenderTexture("Render Texture", 2D) = "black" {}
  7.         _ShadowC("ShadowColor", Color) = (0.1, 0.1, 0.1, 0.1)
  8.         _LightMultiplier("Light Circle Smoothness", Range(0, 5)) = 3
  9.         _ExtraLight("Light Strength", Range(0.5, 5)) = 1
  10.     }
  11.         SubShader
  12.     {
  13.         // No culling or depth
  14.         Cull Off ZWrite Off ZTest Always
  15.  
  16.         Pass
  17.         {
  18.             CGPROGRAM
  19.             #pragma vertex vert
  20.             #pragma fragment frag
  21.  
  22.             #include "UnityCG.cginc"
  23.  
  24.             struct appdata
  25.             {
  26.                 float4 vertex : POSITION;
  27.                 float2 uv : TEXCOORD0;
  28.             };
  29.  
  30.             struct v2f
  31.             {
  32.                 float2 uv : TEXCOORD0;
  33.                 float4 vertex : SV_POSITION;
  34.             };
  35.  
  36.             v2f vert(appdata v)
  37.             {
  38.                 v2f o;
  39.                 o.vertex = UnityObjectToClipPos(v.vertex);
  40.                 o.uv = v.uv;
  41.                 return o;
  42.             }
  43.  
  44.             sampler2D _MainTex, _RenderTexture;
  45.             float4 _ShadowC;
  46.            
  47.             float _LightMultiplier, _ExtraLight;
  48.             fixed4 frag(v2f i) : SV_Target
  49.             {      
  50.             fixed4 lights = (tex2D(_RenderTexture, i.uv)) * _LightMultiplier; // lighting layer
  51.             fixed4 col = tex2D(_MainTex, i.uv); // normal camera view
  52.             lights = saturate(lights); // saturate so it's not extra bright where the lights are
  53.             col = lerp(col * _ShadowC, col , lights * _ExtraLight); // lerp normal view multiplied by shadow color, with normal camera view over the lights layer
  54.             return col;
  55.         }
  56.         ENDCG
  57.     }
  58.     }
  59. }
Add Comment
Please, Sign In to add comment