Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Hidden/Pencil"
- {
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- _EdgeColor ("Edge Color", Color) = (1,1,1,1)
- _Noise ("Noise", 2D) = "white" {}
- _NoiseCoefficient ("Intensity Noise Coefficient", Range(0, 1)) = 1
- }
- SubShader
- {
- // No culling or depth
- Cull Off ZWrite Off ZTest Always
- Blend SrcAlpha OneMinusSrcAlpha
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
- struct appdata
- {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- };
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float2 noise_uv : TEXCOORD1;
- float4 vertex : SV_POSITION;
- };
- sampler2D _MainTex;
- float4 _Noise_ST;
- sampler2D _Noise;
- float _NoiseCoefficient;
- fixed4 _EdgeColor;
- #define PI 3.14159265359
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.uv = v.uv;
- o.noise_uv = TRANSFORM_TEX(v.uv, _Noise);
- return o;
- }
- fixed4 frag (v2f i) : SV_Target
- {
- float intensity = tex2D(_MainTex, i.uv);
- float direction = intensity*2;
- intensity = 1-abs(intensity-0.5)*2;
- //return fixed4(intensity.xxx, 1);
- float offset = fmod(floor(_Time.y*17)*PI, 1);
- fixed noise = tex2D(_Noise, i.noise_uv + float2(offset, direction*_NoiseCoefficient)).r;
- //float center = smoothstep(1, 0.9, intensity);
- //intensity = smoothstep(0, 0.8, intensity);
- float border = smoothstep(0.2, 0.5, intensity+0.2 - noise);
- fixed4 col = float4(_EdgeColor.rgb, border);
- return col;
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement