Advertisement
dnnkeeper

Standard3ColorMask

Mar 27th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.83 KB | None | 0 0
  1. Shader "Custom/Standard3ColorMask" {
  2.     Properties {
  3.         _Mask ("mask (RGBA)", 2D) = "black" {}
  4.  
  5.         _MainTex ("AlbedoR (RGB)", 2D) = "white" {}
  6.         _Spec ("Spec (RGB)", 2D) = "black" {}
  7.         _Normal ("Normal", 2D) = "bump" {}
  8.         _Emission ("Emission (RGB)", 2D) = "white" {}
  9.  
  10.         _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
  11.         _OcclusionMap("Occlusion", 2D) = "white" {}
  12.  
  13.         _ColorR ("ColorR", Color) = (1,1,1,1)
  14.         _ColorG ("ColorG", Color) = (1,1,1,1)
  15.         _ColorB ("ColorB", Color) = (1,1,1,1)
  16.  
  17.         [HDR]
  18.         _EmissionColor("EmissionColor", Color) = (0,0,0)
  19.     }
  20.     SubShader {
  21.         Tags { "RenderType"="Opaque" }
  22.         LOD 200
  23.        
  24.         CGPROGRAM
  25.         // Physically based Standard lighting model, and enable shadows on all light types
  26.         #pragma surface surf StandardSpecular fullforwardshadows
  27.  
  28.         // Use shader model 3.0 target, to get nicer looking lighting
  29.         #pragma target 3.0
  30.  
  31.         sampler2D _MainTex,_Mask;
  32.         sampler2D _Normal;
  33.         sampler2D _Spec;
  34.         sampler2D _Emission;
  35.         sampler2D   _OcclusionMap;
  36.         half        _OcclusionStrength;
  37.         half4 _EmissionColor;
  38.  
  39.         struct Input {
  40.             float2 uv_MainTex;
  41.         };
  42.  
  43.         fixed4 _ColorR,_ColorG,_ColorB;
  44.  
  45.         void surf (Input IN, inout SurfaceOutputStandardSpecular o) {
  46.  
  47.             fixed4 mask = tex2D (_Mask, IN.uv_MainTex);
  48.             // Albedo comes from a texture tinted by color
  49.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * saturate( ( _ColorR * mask.r + _ColorG * mask.g + _ColorB * mask.b) );
  50.  
  51.             half occ = tex2D(_OcclusionMap, IN.uv_MainTex).g;
  52.             o.Occlusion = LerpOneTo (occ, _OcclusionStrength);
  53.  
  54.             o.Albedo = c.rgb;
  55.  
  56.             o.Normal = UnpackNormal ( tex2D (_Normal, IN.uv_MainTex) );
  57.  
  58.             fixed4 spec = tex2D (_Spec, IN.uv_MainTex);
  59.  
  60.             o.Specular = spec.rgb;
  61.  
  62.             o.Smoothness = spec.a;
  63.  
  64.             o.Emission = _EmissionColor * ( tex2D (_Emission, IN.uv_MainTex) );
  65.  
  66.             o.Alpha = c.a;
  67.         }
  68.         ENDCG
  69.     }
  70.     FallBack "Diffuse"
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement