Advertisement
tonynogo

Demo 24 - Shadow with a vertex shader

Jul 6th, 2017
4,529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/VertexShadow" {
  2.     Properties
  3.         {
  4.             _Color ("Color", Color) = (1, 1, 1, 1)
  5.         }
  6.     SubShader {
  7.         Pass {
  8.             Tags { "LightMode"="ForwardBase" }
  9.  
  10.             CGPROGRAM
  11.  
  12.             #pragma vertex vert
  13.             #pragma fragment frag
  14.             #pragma multi_compile_fwdbase
  15.  
  16.             #include "UnityCG.cginc"
  17.             #include "AutoLight.cginc"
  18.  
  19.             struct v2f
  20.             {
  21.                 float4 pos : SV_POSITION;
  22.                 LIGHTING_COORDS(0, 1)
  23.             };
  24.  
  25.             v2f vert(appdata_base v) {
  26.                 v2f o;
  27.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
  28.                 TRANSFER_VERTEX_TO_FRAGMENT(o);
  29.                 return o;
  30.             }
  31.  
  32.             fixed4 _Color;
  33.             fixed4 _LightColor0;
  34.  
  35.             fixed4 frag(v2f i) : COLOR {
  36.                 float attenuation = LIGHT_ATTENUATION(i);
  37.                 return _Color * attenuation * _LightColor0;
  38.             }
  39.  
  40.             ENDCG
  41.         }
  42.     }
  43.    
  44.     Fallback "VertexLit"
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement