Advertisement
tonynogo

Demo 62 - Pseudo Random

Jul 6th, 2017
5,696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/Noise/PseudoRandom"
  2. {
  3.     Properties
  4.     {
  5.         _Factor1 ("Factor 1", float) = 1
  6.         _Factor2 ("Factor 2", float) = 1
  7.         _Factor3 ("Factor 3", float) = 1
  8.     }
  9.  
  10.     SubShader
  11.     {
  12.         Tags { "RenderType"="Opaque" }
  13.  
  14.         Pass
  15.         {
  16.             CGPROGRAM
  17.             #pragma vertex vert_img
  18.             #pragma fragment frag
  19.            
  20.             #include "UnityCG.cginc"
  21.            
  22.             float _Factor1;
  23.             float _Factor2;
  24.             float _Factor3;
  25.  
  26.             float noise(half2 uv)
  27.             {
  28.                 return frac(sin(dot(uv, float2(_Factor1, _Factor2))) * _Factor3);
  29.             }
  30.  
  31.             fixed4 frag (v2f_img i) : SV_Target
  32.             {
  33.                 fixed4 col = noise(i.uv);
  34.                 return col;
  35.             }
  36.             ENDCG
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement