Advertisement
Meetes

CartoonDraw

Apr 27th, 2021
1,755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Unlit/OpaqueJitterVector"
  2. {
  3.     Properties
  4.     {
  5.         [PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
  6.         _Color("Tint", Color) = (1,1,1,1)
  7.         _NoiseTex("Noise Texture", 2D) = "white" {}
  8.         _Intensity("Intensity", Float) = 0.05
  9.         [MaterialToggle] PixelSnap("Pixel snap", Float) = 0
  10.         [HideInInspector] _RendererColor("RendererColor", Color) = (1,1,1,1)
  11.         [HideInInspector] _Flip("Flip", Vector) = (1,1,1,1)
  12.         [PerRendererData] _AlphaTex("External Alpha", 2D) = "white" {}
  13.         [PerRendererData] _EnableExternalAlpha("Enable External Alpha", Float) = 0
  14.     }
  15.  
  16.         SubShader
  17.         {
  18.             Tags
  19.             {
  20.                 "Queue" = "Geometry"
  21.                 "IgnoreProjector" = "True"
  22.                 "RenderType" = "Opaque"
  23.                 "PreviewType" = "Plane"
  24.                 "CanUseSpriteAtlas" = "True"
  25.             }
  26.  
  27.             Cull Off
  28.             Lighting Off
  29.             ZWrite Off
  30.             Blend One OneMinusSrcAlpha
  31.  
  32.             Pass
  33.             {
  34.  
  35.             Tags {"LightMode" = "ForwardBase"}
  36.  
  37.             CGPROGRAM
  38.                 #pragma vertex VectorVert
  39.                 #pragma fragment SpriteFrag
  40.                 #pragma target 2.0
  41.                 #pragma multi_compile_instancing
  42.                 #pragma multi_compile _ PIXELSNAP_ON
  43.                 #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
  44.                 #include "UnitySprites.cginc"
  45.  
  46.                 sampler2D _NoiseTex;
  47.                 float _Intensity;
  48.  
  49.                 v2f VectorVert(appdata_t IN)
  50.                 {
  51.                     v2f OUT;
  52.  
  53.                     UNITY_SETUP_INSTANCE_ID(IN);
  54.                     UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
  55.  
  56.                     OUT.vertex = UnityFlipSprite(IN.vertex, _Flip);
  57.  
  58.                     float interval = 0.15f; // seconds between change
  59.                     float t = floor(_Time.y/interval);
  60.                     t = t % 3; // this is the number of variants
  61.                     t *= 0.1f; // this is necessary because the t's can't all be multiples of 1
  62.                     float4 hi = float4(IN.vertex.x + t, IN.vertex.y + t, 0, 0);
  63.                     half noiseVal = tex2Dlod(_NoiseTex, hi).r;
  64.                     OUT.vertex.x += noiseVal * _Intensity;
  65.  
  66.                     OUT.vertex = UnityObjectToClipPos(OUT.vertex);
  67.                     OUT.texcoord = IN.texcoord;
  68.  
  69.                     #ifdef UNITY_COLORSPACE_GAMMA
  70.                     fixed4 color = IN.color;
  71.                     #else
  72.                     fixed4 color = fixed4(GammaToLinearSpace(IN.color.rgb), IN.color.a);
  73.                     #endif
  74.  
  75.                     OUT.color = color * _Color * _RendererColor;
  76.  
  77.                     #ifdef PIXELSNAP_ON
  78.                     OUT.vertex = UnityPixelSnap(OUT.vertex);
  79.                     #endif
  80.  
  81.                     return OUT;
  82.                 }
  83.             ENDCG
  84.             }
  85.         }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement