Advertisement
Bagserk

ColorMask3Layer (Metallic)

Feb 9th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.77 KB | None | 0 0
  1. Shader "Custom/ColorMask3LayerMetal" {
  2.     Properties
  3.     {
  4.         _Color ("Color", Color) = (1,1,1,1)
  5.         _Color_2 ("Color_2", Color) = (1,1,1,1)
  6.         _Color_3 ("Color_3", Color) = (1,1,1,1)    
  7.         _MainTex ("Texture", 2D) = "white" {}
  8.         _MaskTex ("MaskTexture", 2D) = "white" {}
  9.         _MaskColor("MaskColor", Color) = (1,0,0,1)
  10.         _MaskStrength("Mask Strength", Range(0.0, 1.0)) = 1
  11.         _BumpMap ("Bumpmap", 2D) = "bump" {}
  12.         _MetalGlossMap("Metallic Texture", 2D) = "white" {}
  13.         _SpecColor_3 ("SpecColor_3", Color) = (1,1,1,1)
  14.         _OcclusionStrength("Occlusion Strength", Range(0.0, 1.0)) = 1
  15.         _OcclusionMap("Occlusion Map", 2D) = "white" {}
  16.         _Metallic ("Metallic", Range(0,1)) = 1     
  17.         _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5       
  18.         _Smoothness_2("Smoothness_2", Range(0.0, 1.0)) = 0.5
  19.         _EmissionColor("Emission Color", Color) = (0,0,0)
  20.         _EmissionMap("Emission", 2D) = "black" {}
  21.     }
  22.     SubShader {
  23.         Tags { "RenderType"="Opaque" }
  24.  
  25.         LOD 200
  26.        
  27.         CGPROGRAM
  28.         #include "UnityPBSLighting.cginc"
  29.         // Physically based Standard lighting model, and enable shadows on all light types
  30.         #pragma surface surf Standard fullforwardshadows
  31.  
  32.         // Use shader model 3.0 target, to get nicer looking lighting
  33.         #pragma target 3.0
  34.  
  35.         sampler2D _MainTex, _MaskTex, _BumpMap, _MetalGlossMap, _OcclusionMap, _EmissionMap;
  36.         fixed4 _Color, _Color_2, _Color_3;
  37.         fixed4 _SpecColor_3;   
  38.         fixed4 _MaskColor;
  39.         half3 _EmissionColor;
  40.         half _Metallic;
  41.         half _Smoothness, _Smoothness_2;
  42.         half _OcclusionStrength;
  43.         half _MaskStrength;
  44.         //float4 mask;
  45.  
  46.         struct Input {
  47.             float2 uv_MainTex;
  48.             float2 uv_MaskTex;
  49.             float2 uv_BumpMap;
  50.             float2 uv_MetalGlossMap;
  51.             float2 uv_EmissionMap;
  52.             float2 uv_OcclusionMap;
  53.         };
  54.  
  55.  
  56.  
  57.         void surf (Input IN, inout SurfaceOutputStandard o) {
  58.             // Albedo comes from a texture tinted by colo
  59.             float4 c = tex2D (_MainTex, IN.uv_MainTex);
  60.             float4 mask = tex2D (_MaskTex, IN.uv_MaskTex);         
  61.             float cmask = min(1.0 ,mask.r + mask.g + mask.b);
  62.             float4 n = tex2D (_BumpMap, IN.uv_BumpMap);
  63.             float4 sp = tex2D (_MetalGlossMap, IN.uv_MainTex);
  64.             float oc = tex2D(_OcclusionMap, IN.uv_MainTex).rgb;
  65.             float em = tex2D(_EmissionMap, IN.uv_EmissionMap).r;
  66.            
  67.             mask = lerp(float4(0,0,0,0), mask * _MaskColor, _MaskStrength);
  68.            
  69.             c.rgb = c.rgb * (1 - cmask) + (c * _Color * mask.r) + (c * _Color_2 * mask.g) + (c * _Color_3 * mask.b);
  70.             sp.rgb = sp.rgb * _Metallic;
  71.            
  72.             o.Albedo = c.rgb;          
  73.             o.Normal = UnpackNormal (n);           
  74.             o.Metallic = sp.rgb;
  75.             o.Smoothness = (sp.a * (1 - cmask) + ((sp.a * _Smoothness) * mask.r) + ((sp.a * _Smoothness_2) * mask.g) + ((sp.a * _SpecColor_3.a) * mask.b));
  76.             o.Occlusion = lerp(float4(1,1,1,1), oc, _OcclusionStrength).rgba;          
  77.             o.Emission = em * _EmissionColor;
  78.         }
  79.         ENDCG
  80.     }
  81.     FallBack "Diffuse"
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement