Advertisement
dnnkeeper

Standard4ColorMask

Mar 27th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. Shader "Custom/Standard4ColorMask" {
  2.     Properties {
  3.         _Mask ("mask (RGBA)", 2D) = "black" {}
  4.  
  5.         _ColorR ("ColorR", Color) = (1,1,1,1)
  6.         _ColorG ("ColorG", Color) = (1,1,1,1)
  7.         _ColorB ("ColorB", Color) = (1,1,1,1)
  8.         _ColorA ("ColorA", Color) = (1,1,1,1)
  9.  
  10.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
  11.         _Glossiness ("Smoothness", Range(0,1)) = 0.5
  12.         _Metallic ("Metallic", Range(0,1)) = 0.0
  13.     }
  14.     SubShader {
  15.         Tags { "RenderType"="Opaque" }
  16.         LOD 200
  17.        
  18.         CGPROGRAM
  19.         // Physically based Standard lighting model, and enable shadows on all light types
  20.         #pragma surface surf Standard fullforwardshadows
  21.  
  22.         // Use shader model 3.0 target, to get nicer looking lighting
  23.         #pragma target 3.0
  24.  
  25.         sampler2D _MainTex,_Mask;
  26.  
  27.         struct Input {
  28.             float2 uv_MainTex;
  29.         };
  30.  
  31.         half _Glossiness;
  32.         half _Metallic;
  33.         fixed4 _ColorR,_ColorG,_ColorB,_ColorA;
  34.  
  35.         void surf (Input IN, inout SurfaceOutputStandard o) {
  36.  
  37.             fixed4 mask = tex2D (_Mask, IN.uv_MainTex);
  38.             // Albedo comes from a texture tinted by color
  39.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * ( _ColorR * mask.r + _ColorG * mask.g + _ColorB * mask.b + _ColorA * mask.a) ;
  40.             o.Albedo = c.rgb;
  41.             // Metallic and smoothness come from slider variables
  42.             o.Metallic = _Metallic;
  43.             o.Smoothness = _Glossiness;
  44.             o.Alpha = c.a;
  45.         }
  46.         ENDCG
  47.     }
  48.     FallBack "Diffuse"
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement