Advertisement
tonynogo

Demo 37 - Post rendering noise

Jul 6th, 2017
3,565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/PostRenderNoise"
  2. {
  3.     Properties
  4.     {
  5.         _MainTex ("Texture", 2D) = "white" {}
  6.         _SecondaryTex ("Secondary Texture", 2D) = "white" {}
  7.         _OffsetX ("OffsetX", float) = 0.0
  8.         _OffsetY ("OffsetY", float) = 0.0
  9.         _Intensity ("Mask Intensity", Range(0, 1)) = 1.0
  10.         _Color ("Color", Color) = (1.0, 1.0, 1.0, 1.0)
  11.     }
  12.     SubShader
  13.     {
  14.         Pass
  15.         {
  16.             CGPROGRAM
  17.             #pragma vertex vert
  18.             #pragma fragment frag
  19.             #include "UnityCG.cginc"
  20.  
  21.             struct v2f
  22.             {
  23.                 float4 pos : SV_POSITION;
  24.                 float2 uv : TEXCOORD0;
  25.                 float2 uv2 : TEXCOORD1;
  26.             };
  27.  
  28.             half _OffsetX;
  29.             half _OffsetY;
  30.  
  31.             v2f vert (appdata_base v)
  32.             {
  33.                 v2f o;
  34.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
  35.                 o.uv = v.texcoord;
  36.                 o.uv2 = v.texcoord + float2(_OffsetX, _OffsetY);
  37.                 return o;
  38.             }
  39.            
  40.             sampler2D _MainTex;
  41.             sampler2D _SecondaryTex;
  42.             fixed4 _Color;
  43.             fixed _Intensity;
  44.  
  45.             fixed4 frag (v2f i) : SV_Target
  46.             {
  47.                 fixed4 col = tex2D(_MainTex, i.uv);
  48.                 fixed4 col2 = tex2D(_SecondaryTex, i.uv2);
  49.                 return lerp(col, _Color, ceil(saturate(1 - col2.r - _Intensity)));
  50.             }
  51.             ENDCG
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement