Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Unlit/OpaqueJitterVector"
- {
- Properties
- {
- [PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
- _Color("Tint", Color) = (1,1,1,1)
- _NoiseTex("Noise Texture", 2D) = "white" {}
- _Intensity("Intensity", Float) = 0.05
- [MaterialToggle] PixelSnap("Pixel snap", Float) = 0
- [HideInInspector] _RendererColor("RendererColor", Color) = (1,1,1,1)
- [HideInInspector] _Flip("Flip", Vector) = (1,1,1,1)
- [PerRendererData] _AlphaTex("External Alpha", 2D) = "white" {}
- [PerRendererData] _EnableExternalAlpha("Enable External Alpha", Float) = 0
- }
- SubShader
- {
- Tags
- {
- "Queue" = "Geometry"
- "IgnoreProjector" = "True"
- "RenderType" = "Opaque"
- "PreviewType" = "Plane"
- "CanUseSpriteAtlas" = "True"
- }
- Cull Off
- Lighting Off
- ZWrite Off
- Blend One OneMinusSrcAlpha
- Pass
- {
- Tags {"LightMode" = "ForwardBase"}
- CGPROGRAM
- #pragma vertex VectorVert
- #pragma fragment SpriteFrag
- #pragma target 2.0
- #pragma multi_compile_instancing
- #pragma multi_compile _ PIXELSNAP_ON
- #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
- #include "UnitySprites.cginc"
- sampler2D _NoiseTex;
- float _Intensity;
- v2f VectorVert(appdata_t IN)
- {
- v2f OUT;
- UNITY_SETUP_INSTANCE_ID(IN);
- UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
- OUT.vertex = UnityFlipSprite(IN.vertex, _Flip);
- float interval = 0.15f; // seconds between change
- float t = floor(_Time.y/interval);
- t = t % 3; // this is the number of variants
- t *= 0.1f; // this is necessary because the t's can't all be multiples of 1
- float4 hi = float4(IN.vertex.x + t, IN.vertex.y + t, 0, 0);
- half noiseVal = tex2Dlod(_NoiseTex, hi).r;
- OUT.vertex.x += noiseVal * _Intensity;
- OUT.vertex = UnityObjectToClipPos(OUT.vertex);
- OUT.texcoord = IN.texcoord;
- #ifdef UNITY_COLORSPACE_GAMMA
- fixed4 color = IN.color;
- #else
- fixed4 color = fixed4(GammaToLinearSpace(IN.color.rgb), IN.color.a);
- #endif
- OUT.color = color * _Color * _RendererColor;
- #ifdef PIXELSNAP_ON
- OUT.vertex = UnityPixelSnap(OUT.vertex);
- #endif
- return OUT;
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement