Advertisement
Guest User

Untitled

a guest
Jan 28th, 2018
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.61 KB | None | 0 0
  1. Shader "Custom/Watercol"
  2. {
  3.     Properties
  4.     {
  5.         _MainTex ("Texture", 2D) = "white" {}
  6.         _PaintTex ("Texture", 2D) = "white" {}
  7.     }
  8.     SubShader
  9.     {
  10.         Tags { "RenderType"="Opaque" }
  11.         LOD 100
  12.  
  13.         Pass
  14.         {
  15.             CGPROGRAM
  16.             #pragma vertex vert
  17.             #pragma fragment frag
  18.             //#pragma multi_compile_fog
  19.            
  20.             #include "UnityCG.cginc"
  21.             #include "UnityLightingCommon.cginc"
  22.  
  23.             struct v2f
  24.             {
  25.                 float2 uv : TEXCOORD0;
  26.                 float2 uvpaint : TEXCOORD1;
  27.                 fixed4 diff : COLOR0;
  28.                 float4 vertex : SV_POSITION;
  29.                 //UNITY_FOG_COORDS(1)
  30.             };
  31.  
  32.             sampler2D _MainTex;
  33.             float4 _MainTex_ST;
  34.             sampler2D _PaintTex;
  35.            
  36.             v2f vert (appdata_base v)
  37.             {
  38.                 v2f o;
  39.                 o.vertex = UnityObjectToClipPos(v.vertex);
  40.                 o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
  41.                 o.uvpaint = v.vertex.xy + v.vertex.zz;
  42.  
  43.                 half3 worldNormal = UnityObjectToWorldNormal(-v.normal);
  44.                 half nl = max(0, dot(worldNormal, _WorldSpaceLightPos0.xyz));
  45.                 o.diff = nl * _LightColor0;
  46.                 o.diff.rgb += ShadeSH9(half4(worldNormal,1));
  47.  
  48.                 //UNITY_TRANSFER_FOG(o,o.vertex);
  49.  
  50.                 return o;
  51.             }
  52.            
  53.             fixed4 frag (v2f i) : SV_Target
  54.             {
  55.                 // sample the texture
  56.                 fixed4 col = tex2D(_MainTex, i.uv);
  57.                 fixed paint = tex2D(_PaintTex, i.uvpaint * 0.2 + col.xy * 0.35).r;
  58.  
  59.                 float f = 2.5;
  60.                 i.diff *= f;
  61.                 i.diff = round(i.diff);
  62.                 i.diff /= f;
  63.                 i.diff = max(i.diff, 0.675);
  64.  
  65.                 col *= i.diff;
  66.  
  67.                 col.rgb += col.rgb * (paint - 0.5) * 0.8;
  68.  
  69.                 //UNITY_APPLY_FOG(i.fogCoord, col);
  70.  
  71.                 return col;
  72.             }
  73.             ENDCG
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement