Advertisement
Bagserk

Glass Shader Mix

May 24th, 2019
784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Shader created with Shader Forge v1.30
  2. // Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
  3. // Note: Manually altering this data may prevent you from opening it in Shader Forge
  4. /*SF_DATA;ver:1.30;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,lico:1,lgpr:1,limd:3,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:True,hqlp:True,rprd:True,enco:False,rmgx:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:3,bdst:7,dpts:2,wrdp:True,dith:0,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:False,igpj:True,qofs:0,qpre:3,rntp:2,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:1,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False;n:type:ShaderForge.SFN_Final,id:3643,x:33181,y:32743,varname:node_3643,prsc:2|diff-827-OUT,spec-5417-OUT,gloss-2940-OUT,normal-6784-OUT,difocc-3858-R,spcocc-3858-R,alpha-3582-OUT,refract-4233-OUT;n:type:ShaderForge.SFN_Multiply,id:7407,x:32216,y:33892,varname:node_7407,prsc:2|A-6551-OUT,B-9229-OUT;n:type:ShaderForge.SFN_Tex2d,id:2479,x:31515,y:32296,ptovrint:False,ptlb:Normal Map,ptin:_NormalMap,varname:_NormalMap,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:3,isnm:True|UVIN-9416-UVOUT;n:type:ShaderForge.SFN_Lerp,id:6784,x:31910,y:32248,varname:node_6784,prsc:2|A-4537-OUT,B-2479-RGB,T-7768-OUT;n:type:ShaderForge.SFN_Vector3,id:4537,x:31515,y:32186,varname:node_4537,prsc:2,v1:0,v2:0,v3:1;n:type:ShaderForge.SFN_TexCoord,id:9416,x:31255,y:32296,varname:node_9416,prsc:2,uv:0;n:type:ShaderForge.SFN_ComponentMask,id:6551,x:32040,y:33747,varname:node_6551,prsc:2,cc1:0,cc2:-1,cc3:-1,cc4:-1|IN-2479-RGB;n:type:ShaderForge.SFN_Slider,id:5293,x:31102,y:34012,ptovrint:False,ptlb:Refraction,ptin:_Refraction,varname:_Refraction,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;n:type:ShaderForge.SFN_Vector1,id:5984,x:30920,y:33598,varname:node_5984,prsc:2,v1:0;n:type:ShaderForge.SFN_Vector1,id:4313,x:30953,y:33529,varname:node_4313,prsc:2,v1:1;n:type:ShaderForge.SFN_Slider,id:7768,x:31358,y:32493,ptovrint:False,ptlb:Normal Intensity,ptin:_NormalIntensity,varname:_NormalIntensity,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:1,max:1;n:type:ShaderForge.SFN_Tex2d,id:5796,x:31547,y:31220,ptovrint:False,ptlb:MainTex,ptin:_MainTex,varname:_MainTex,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Color,id:8761,x:30111,y:29615,ptovrint:False,ptlb:Color,ptin:_Color,varname:_Color,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:1,c3:1,c4:1;n:type:ShaderForge.SFN_Slider,id:2590,x:29368,y:33152,ptovrint:False,ptlb:Smoothness,ptin:_Smoothness,varname:_Smoothness,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.5,max:1;n:type:ShaderForge.SFN_Slider,id:2152,x:30963,y:31936,ptovrint:False,ptlb:Reflection Edges,ptin:_ReflectionEdges,varname:_ReflectionEdges,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.5,max:1;n:type:ShaderForge.SFN_Vector1,id:803,x:31120,y:31736,varname:node_803,prsc:2,v1:0;n:type:ShaderForge.SFN_Vector1,id:7746,x:31120,y:31632,varname:node_7746,prsc:2,v1:10;n:type:ShaderForge.SFN_Lerp,id:49,x:31396,y:31823,varname:node_49,prsc:2|A-7746-OUT,B-803-OUT,T-2152-OUT;n:type:ShaderForge.SFN_Fresnel,id:3559,x:31492,y:31623,varname:node_3559,prsc:2|EXP-49-OUT;n:type:ShaderForge.SFN_RemapRange,id:2540,x:31710,y:31764,varname:node_2540,prsc:2,frmn:0,frmx:1,tomn:0,tomx:1|IN-3559-OUT;n:type:ShaderForge.SFN_Multiply,id:1017,x:31856,y:31598,varname:node_1017,prsc:2|A-3559-OUT,B-2540-OUT,C-3559-OUT,D-3559-OUT;n:type:ShaderForge.SFN_Add,id:1577,x:32062,y:31818,varname:node_1577,prsc:2|A-1457-OUT,B-1017-OUT;n:type:ShaderForge.SFN_Multiply,id:1457,x:31404,y:31370,varname:node_1457,prsc:2|A-6677-RGB,B-8157-OUT;n:type:ShaderForge.SFN_Lerp,id:8157,x:31067,y:31341,varname:node_8157,prsc:2|A-64-OUT,B-4805-OUT,T-2565-OUT;n:type:ShaderForge.SFN_Slider,id:2565,x:30142,y:31208,ptovrint:False,ptlb:Reflection Intensity,ptin:_ReflectionIntensity,varname:_ReflectionIntensity,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.5083579,max:1;n:type:ShaderForge.SFN_Vector1,id:4805,x:30826,y:31250,varname:node_4805,prsc:2,v1:2;n:type:ShaderForge.SFN_Vector1,id:64,x:30826,y:31180,varname:node_64,prsc:2,v1:0;n:type:ShaderForge.SFN_Cubemap,id:6677,x:30878,y:30929,ptovrint:False,ptlb:Cube map ,ptin:_Cubemap,varname:_Cubemap,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,pvfc:1|MIP-2669-OUT;n:type:ShaderForge.SFN_ConstantLerp,id:2669,x:30636,y:30929,varname:node_2669,prsc:2,a:0,b:6|IN-3835-OUT;n:type:ShaderForge.SFN_Slider,id:3835,x:30248,y:30988,ptovrint:False,ptlb:Blur Reflection,ptin:_BlurReflection,varname:_BlurReflection,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;n:type:ShaderForge.SFN_Multiply,id:2418,x:32773,y:32017,varname:node_2418,prsc:2|A-4488-OUT,B-1577-OUT;n:type:ShaderForge.SFN_Tex2d,id:8936,x:29123,y:31579,ptovrint:False,ptlb:MaskTex,ptin:_MaskTex,varname:_MaskTex,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Clamp,id:3582,x:31485,y:33613,varname:node_3582,prsc:2|IN-7679-OUT,MIN-5984-OUT,MAX-4313-OUT;n:type:ShaderForge.SFN_Add,id:7679,x:30890,y:33727,varname:node_7679,prsc:2|A-2111-OUT,B-5796-A;n:type:ShaderForge.SFN_Color,id:2112,x:29932,y:30008,ptovrint:False,ptlb:Color_2,ptin:_Color_2,varname:_Color_2,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:1,c3:1,c4:1;n:type:ShaderForge.SFN_Color,id:7337,x:30017,y:30274,ptovrint:False,ptlb:Color_3,ptin:_Color_3,varname:_Color_3,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:1,c3:1,c4:1;n:type:ShaderForge.SFN_Color,id:5487,x:30111,y:29818,ptovrint:False,ptlb:SpecColor,ptin:_SpecColor,varname:_SpecColor,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:0.5,c2:0.5,c3:0.5,c4:1;n:type:ShaderForge.SFN_Slider,id:8706,x:29422,y:32493,ptovrint:False,ptlb:Metallic,ptin:_Metallic,varname:_Metalness,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.6381867,max:1;n:type:ShaderForge.SFN_Slider,id:2473,x:29463,y:32639,ptovrint:False,ptlb:Metallic_2,ptin:_Metallic_2,varname:_Metalness_2,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;n:type:ShaderForge.SFN_Color,id:2847,x:30171,y:32685,ptovrint:False,ptlb:SpecColor_3,ptin:_SpecColor_3,varname:_SpecColor_3,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:1,c3:1,c4:1;n:type:ShaderForge.SFN_Clamp01,id:2111,x:31210,y:33001,varname:node_2111,prsc:2|IN-2847-B;n:type:ShaderForge.SFN_Slider,id:1485,x:29409,y:33295,ptovrint:False,ptlb:Smoothness_2,ptin:_Smoothness_2,varname:_Smoothness_2,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.5155692,max:1;n:type:ShaderForge.SFN_Tex2d,id:6196,x:29883,y:32299,ptovrint:False,ptlb:MetallicMap,ptin:_MetallicMap,varname:_MetallicMap,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Lerp,id:827,x:32832,y:32353,varname:node_827,prsc:2|A-4488-OUT,B-2418-OUT,T-7112-OUT;n:type:ShaderForge.SFN_Multiply,id:9229,x:31742,y:33819,varname:node_9229,prsc:2|A-8936-A,B-5293-OUT;n:type:ShaderForge.SFN_ComponentMask,id:4233,x:32384,y:33689,varname:node_4233,prsc:2,cc1:0,cc2:0,cc3:-1,cc4:-1|IN-7407-OUT;n:type:ShaderForge.SFN_Tex2d,id:3858,x:32685,y:32913,ptovrint:False,ptlb:_OcclusionMap,ptin:__OcclusionMap,varname:__OcclusionMap,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Min,id:5598,x:29444,y:31029,varname:node_5598,prsc:2|A-6767-OUT,B-1650-OUT;n:type:ShaderForge.SFN_Add,id:1650,x:29711,y:31419,varname:node_1650,prsc:2|A-8936-R,B-8936-G,C-8936-B;n:type:ShaderForge.SFN_Vector1,id:6767,x:29646,y:31206,varname:node_6767,prsc:2,v1:1;n:type:ShaderForge.SFN_Code,id:4488,x:30708,y:29801,varname:node_4488,prsc:2,code:ZgBsAG8AYQB0ADMAIABtAF8AYwBvAGwAbwByACAAPQAgAGMALgByAGcAYgAgACoAIAAoADEAIAAtACAAYwBtAGEAcwBrACkAIAAqACAAXwBDAG8AbABvAHIAXwAyACAAKwAgACgAYwAgACoAIABfAEMAbwBsAG8AcgAgACoAIABtAGEAcwBrAC4AcgApACAAKwAgACgAYwAgACoAIABfAFMAcABlAGMAQwBvAGwAbwByAC4AcgBnAGIAIAAqACAAbQBhAHMAawAuAGcAKQAgACsAIAAoAGMAIAAqACAAXwBDAG8AbABvAHIAXwAzACAAKgAgAG0AYQBzAGsALgBiACkAOwAKAHIAZQB0AHUAcgBuACAAbQBfAGMAbwBsAG8AcgA7AAoA,output:2,fname:maskedcolor,width:751,height:188,input:2,input:0,input:2,input:2,input:2,input:2,input:2,input_1_label:c,input_2_label:cmask,input_3_label:c_color,input_4_label:c_color_2,input_5_label:c_color_3,input_6_label:c_speccolor,input_7_label:mask|A-5796-RGB,B-5598-OUT,C-8761-RGB,D-2112-RGB,E-7337-RGB,F-5487-RGB,G-9948-OUT;n:type:ShaderForge.SFN_Code,id:5417,x:30361,y:32144,varname:node_5417,prsc:2,code:aABhAGwAZgAgAG0AXwBjAG8AbABvAHIAIAA9ACAAYwBsAGEAbQBwACgAbQAuAHIAIAAqACAAKAAxACAALQAgAGMAbQBhAHMAawApACAAKgAgAGMAXwBtAGUAdABhAGwAXwAyACAAKwAgACgAbQAuAHIAIAAqACAAYwBfAG0AZQB0AGEAbAAgACoAIABtAGEAcwBrAC4AcgApACAAKwAgACgAbQAuAHIAIAAqACAAYwBfAHMAcABlAGMAYwBvAGwAbwByADMAXwBnACAAKgAgAG0AYQBzAGsALgBnACkAIAArACAAKABtAC4AcgAgACoAIABtAGEAcwBrAC4AYgApACwAMAAsADEAKQA7AAoAcgBlAHQAdQByAG4AIABtAF8AYwBvAGwAbwByADsACgA=,output:4,fname:maskedmetal,width:1203,height:188,input:2,input:0,input:4,input:4,input:4,input:2,input_1_label:m,input_2_label:cmask,input_3_label:c_metal,input_4_label:c_metal_2,input_5_label:c_speccolor3_g,input_6_label:mask|A-6196-RGB,B-5598-OUT,C-8706-OUT,D-2473-OUT,E-2847-G,F-9948-OUT;n:type:ShaderForge.SFN_Code,id:2940,x:29436,y:32913,varname:node_2940,prsc:2,code:aABhAGwAZgAgAHMAXwBjAG8AbABvAHIAIAA9ACAAYwBsAGEAbQBwACgAcwAgACoAIAAoADEAIAAtACAAYwBtAGEAcwBrACkAIAAqACAAYwBfAHMAbQBvAG8AdABoAF8AMgAgACsAIAAoACgAcwAgACoAIABjAF8AcwBtAG8AbwB0AGgAKQAgACoAIABtAGEAcwBrAC4AcgApACAAKwAgACgAKABzACAAKgAgAGMAXwBzAHAAZQBjAGMAbwBsAG8AcgAzAF8AYQApACAAKgAgAG0AYQBzAGsALgBnACkAIAArACAAKABzACAAKgAgAG0AYQBzAGsALgBiACkALAAwACwAMQApADsACgByAGUAdAB1AHIAbgAgAHMAXwBjAG8AbABvAHIAOwAKAA==,output:4,fname:maskedgloss,width:1222,height:188,input:4,input:0,input:4,input:4,input:4,input:2,input:4,input_1_label:s,input_2_label:cmask,input_3_label:c_smooth,input_4_label:c_smooth_2,input_5_label:c_speccolor3_a,input_6_label:mask,input_7_label:c_speccolor3_r|A-6196-A,B-5598-OUT,C-2590-OUT,D-1485-OUT,E-2847-A,F-9948-OUT,G-2847-R;n:type:ShaderForge.SFN_Slider,id:170,x:28866,y:31064,ptovrint:False,ptlb:MaskStrength,ptin:_MaskStrength,varname:node_7533,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:1,max:1;n:type:ShaderForge.SFN_Color,id:1231,x:28925,y:30905,ptovrint:False,ptlb:MaskColor,ptin:_MaskColor,varname:node_6253,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:0,c3:0,c4:1;n:type:ShaderForge.SFN_Multiply,id:6549,x:29189,y:30995,varname:node_6549,prsc:2|A-1231-RGB,B-8936-RGB;n:type:ShaderForge.SFN_Vector4,id:8132,x:29017,y:30630,varname:node_8132,prsc:2,v1:0,v2:0,v3:0,v4:0;n:type:ShaderForge.SFN_Lerp,id:6462,x:29440,y:30653,varname:node_6462,prsc:2|A-8132-OUT,B-6549-OUT,T-170-OUT;n:type:ShaderForge.SFN_ComponentMask,id:9948,x:29645,y:30653,varname:node_9948,prsc:2,cc1:0,cc2:1,cc3:2,cc4:-1|IN-6462-OUT;n:type:ShaderForge.SFN_Multiply,id:9849,x:30142,y:31391,varname:node_9849,prsc:2|A-2565-OUT,B-8936-A;n:type:ShaderForge.SFN_Clamp01,id:7112,x:30432,y:31381,varname:node_7112,prsc:2|IN-9849-OUT;proporder:8761-5796-2590-2479-7768-5293-6677-2152-2565-3835-2112-7337-5487-8706-2847-2473-1485-8936-6196-3858-170-1231;pass:END;sub:END;*/
  5.  
  6. Shader "Ciconia Studio/Effects/Glass/Advanced Reflection (Mix)" {
  7.     Properties {
  8.         _Color ("Color", Color) = (1,1,1,1)
  9.         _MainTex ("MainTex", 2D) = "white" {}
  10.         _Smoothness ("Smoothness", Range(0, 1)) = 0.5
  11.         _NormalMap ("Normal Map", 2D) = "bump" {}
  12.         _NormalIntensity ("Normal Intensity", Range(0, 1)) = 1
  13.         _Refraction ("Refraction", Range(0, 1)) = 0
  14.         _Cubemap ("Cube map ", Cube) = "_Skybox" {}
  15.         _ReflectionEdges ("Reflection Edges", Range(0, 1)) = 0.5
  16.         _ReflectionIntensity ("Reflection Intensity", Range(0, 1)) = 0.5083579
  17.         _BlurReflection ("Blur Reflection", Range(0, 1)) = 0
  18.         _Color_2 ("Color_2", Color) = (1,1,1,1)
  19.         _Color_3 ("Color_3", Color) = (1,1,1,1)
  20.         _SpecColor ("SpecColor", Color) = (0.5,0.5,0.5,1)
  21.         _Metallic ("Metallic", Range(0, 1)) = 0.6381867
  22.         _SpecColor_3 ("SpecColor_3", Color) = (1,1,1,1)
  23.         _Metallic_2 ("Metallic_2", Range(0, 1)) = 0
  24.         _Smoothness_2 ("Smoothness_2", Range(0, 1)) = 0.5155692
  25.         _MaskTex ("MaskTex", 2D) = "white" {}
  26.         _MetallicMap ("MetallicMap", 2D) = "white" {}
  27.         __OcclusionMap ("_OcclusionMap", 2D) = "white" {}
  28.         _MaskStrength ("MaskStrength", Range(0, 1)) = 1
  29.         _MaskColor ("MaskColor", Color) = (1,0,0,1)
  30.         [HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
  31.     }
  32.     SubShader {
  33.         Tags {
  34.             "IgnoreProjector"="True"
  35.             "Queue"="Transparent"
  36.             "RenderType"="Transparent"
  37.         }
  38.         GrabPass{ }
  39.         Pass {
  40.             Name "FORWARD"
  41.             Tags {
  42.                 "LightMode"="ForwardBase"
  43.             }
  44.             Blend SrcAlpha OneMinusSrcAlpha
  45.            
  46.            
  47.             CGPROGRAM
  48.             #pragma vertex vert
  49.             #pragma fragment frag
  50.             #define UNITY_PASS_FORWARDBASE
  51.             #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
  52.             #define _GLOSSYENV 1
  53.             #include "UnityCG.cginc"
  54.             #include "Lighting.cginc"
  55.             #include "UnityPBSLighting.cginc"
  56.             #include "UnityStandardBRDF.cginc"
  57.             #pragma multi_compile_fwdbase
  58.             #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  59.             #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
  60.             #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
  61.             #pragma multi_compile_fog
  62.             #pragma exclude_renderers metal d3d11_9x xbox360 xboxone ps3 ps4 psp2
  63.             #pragma target 3.0
  64.             #pragma glsl
  65.             uniform sampler2D _GrabTexture;
  66.             uniform sampler2D _NormalMap; uniform float4 _NormalMap_ST;
  67.             uniform float _Refraction;
  68.             uniform float _NormalIntensity;
  69.             uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
  70.             uniform float4 _Color;
  71.             uniform float _Smoothness;
  72.             uniform float _ReflectionEdges;
  73.             uniform float _ReflectionIntensity;
  74.             uniform samplerCUBE _Cubemap;
  75.             uniform float _BlurReflection;
  76.             uniform sampler2D _MaskTex; uniform float4 _MaskTex_ST;
  77.             uniform float4 _Color_2;
  78.             uniform float4 _Color_3;
  79.             uniform float _Metallic;
  80.             uniform float _Metallic_2;
  81.             uniform float4 _SpecColor_3;
  82.             uniform float _Smoothness_2;
  83.             uniform sampler2D _MetallicMap; uniform float4 _MetallicMap_ST;
  84.             uniform sampler2D __OcclusionMap; uniform float4 __OcclusionMap_ST;
  85.             float3 maskedcolor( float3 c , float cmask , float3 c_color , float3 c_color_2 , float3 c_color_3 , float3 c_speccolor , float3 mask ){
  86.             float3 m_color = c.rgb * (1 - cmask) * _Color_2 + (c * _Color * mask.r) + (c * _SpecColor.rgb * mask.g) + (c * _Color_3 * mask.b);
  87.             return m_color;
  88.            
  89.             }
  90.            
  91.             half maskedmetal( float3 m , float cmask , half c_metal , half c_metal_2 , half c_speccolor3_g , float3 mask ){
  92.             half m_color = clamp(m.r * (1 - cmask) * c_metal_2 + (m.r * c_metal * mask.r) + (m.r * c_speccolor3_g * mask.g) + (m.r * mask.b),0,1);
  93.             return m_color;
  94.            
  95.             }
  96.            
  97.             half maskedgloss( half s , float cmask , half c_smooth , half c_smooth_2 , half c_speccolor3_a , float3 mask , half c_speccolor3_r ){
  98.             half s_color = clamp(s * (1 - cmask) * c_smooth_2 + ((s * c_smooth) * mask.r) + ((s * c_speccolor3_a) * mask.g) + (s * mask.b),0,1);
  99.             return s_color;
  100.            
  101.             }
  102.            
  103.             uniform float _MaskStrength;
  104.             uniform float4 _MaskColor;
  105.             struct VertexInput {
  106.                 float4 vertex : POSITION;
  107.                 float3 normal : NORMAL;
  108.                 float4 tangent : TANGENT;
  109.                 float2 texcoord0 : TEXCOORD0;
  110.                 float2 texcoord1 : TEXCOORD1;
  111.                 float2 texcoord2 : TEXCOORD2;
  112.             };
  113.             struct VertexOutput {
  114.                 float4 pos : SV_POSITION;
  115.                 float2 uv0 : TEXCOORD0;
  116.                 float2 uv1 : TEXCOORD1;
  117.                 float2 uv2 : TEXCOORD2;
  118.                 float4 posWorld : TEXCOORD3;
  119.                 float3 normalDir : TEXCOORD4;
  120.                 float3 tangentDir : TEXCOORD5;
  121.                 float3 bitangentDir : TEXCOORD6;
  122.                 float4 screenPos : TEXCOORD7;
  123.                 UNITY_FOG_COORDS(8)
  124.                 #if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH)
  125.                     float4 ambientOrLightmapUV : TEXCOORD9;
  126.                 #endif
  127.             };
  128.             VertexOutput vert (VertexInput v) {
  129.                 VertexOutput o = (VertexOutput)0;
  130.                 o.uv0 = v.texcoord0;
  131.                 o.uv1 = v.texcoord1;
  132.                 o.uv2 = v.texcoord2;
  133.                 #ifdef LIGHTMAP_ON
  134.                     o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
  135.                     o.ambientOrLightmapUV.zw = 0;
  136.                 #endif
  137.                 #ifdef DYNAMICLIGHTMAP_ON
  138.                     o.ambientOrLightmapUV.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
  139.                 #endif
  140.                 o.normalDir = UnityObjectToWorldNormal(v.normal);
  141.                 o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );
  142.                 o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
  143.                 o.posWorld = mul(_Object2World, v.vertex);
  144.                 float3 lightColor = _LightColor0.rgb;
  145.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
  146.                 UNITY_TRANSFER_FOG(o,o.pos);
  147.                 o.screenPos = o.pos;
  148.                 return o;
  149.             }
  150.             float4 frag(VertexOutput i) : COLOR {
  151.                 #if UNITY_UV_STARTS_AT_TOP
  152.                     float grabSign = -_ProjectionParams.x;
  153.                 #else
  154.                     float grabSign = _ProjectionParams.x;
  155.                 #endif
  156.                 i.normalDir = normalize(i.normalDir);
  157.                 i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
  158.                 i.screenPos.y *= _ProjectionParams.x;
  159.                 float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
  160.                 float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  161.                 float3 _NormalMap_var = UnpackNormal(tex2D(_NormalMap,TRANSFORM_TEX(i.uv0, _NormalMap)));
  162.                 float3 normalLocal = lerp(float3(0,0,1),_NormalMap_var.rgb,_NormalIntensity);
  163.                 float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
  164.                 float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
  165.                 float4 _MaskTex_var = tex2D(_MaskTex,TRANSFORM_TEX(i.uv0, _MaskTex));
  166.                 float2 sceneUVs = float2(1,grabSign)*i.screenPos.xy*0.5+0.5 + (_NormalMap_var.rgb.r*(_MaskTex_var.a*_Refraction)).rr;
  167.                 float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
  168.                 float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
  169.                 float3 lightColor = _LightColor0.rgb;
  170.                 float3 halfDirection = normalize(viewDirection+lightDirection);
  171. ////// Lighting:
  172.                 float attenuation = 1;
  173.                 float3 attenColor = attenuation * _LightColor0.xyz;
  174.                 float Pi = 3.141592654;
  175.                 float InvPi = 0.31830988618;
  176. ///////// Gloss:
  177.                 float4 _MetallicMap_var = tex2D(_MetallicMap,TRANSFORM_TEX(i.uv0, _MetallicMap));
  178.                 float node_5598 = min(1.0,(_MaskTex_var.r+_MaskTex_var.g+_MaskTex_var.b));
  179.                 float3 node_9948 = lerp(float4(0,0,0,0),float4((_MaskColor.rgb*_MaskTex_var.rgb),0.0),_MaskStrength).rgb;
  180.                 float gloss = maskedgloss( _MetallicMap_var.a , node_5598 , _Smoothness , _Smoothness_2 , _SpecColor_3.a , node_9948 , _SpecColor_3.r );
  181.                 float specPow = exp2( gloss * 10.0+1.0);
  182. /////// GI Data:
  183.                 UnityLight light;
  184.                 #ifdef LIGHTMAP_OFF
  185.                     light.color = lightColor;
  186.                     light.dir = lightDirection;
  187.                     light.ndotl = LambertTerm (normalDirection, light.dir);
  188.                 #else
  189.                     light.color = half3(0.f, 0.f, 0.f);
  190.                     light.ndotl = 0.0f;
  191.                     light.dir = half3(0.f, 0.f, 0.f);
  192.                 #endif
  193.                 UnityGIInput d;
  194.                 d.light = light;
  195.                 d.worldPos = i.posWorld.xyz;
  196.                 d.worldViewDir = viewDirection;
  197.                 d.atten = attenuation;
  198.                 #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
  199.                     d.ambient = 0;
  200.                     d.lightmapUV = i.ambientOrLightmapUV;
  201.                 #else
  202.                     d.ambient = i.ambientOrLightmapUV;
  203.                 #endif
  204.                 d.boxMax[0] = unity_SpecCube0_BoxMax;
  205.                 d.boxMin[0] = unity_SpecCube0_BoxMin;
  206.                 d.probePosition[0] = unity_SpecCube0_ProbePosition;
  207.                 d.probeHDR[0] = unity_SpecCube0_HDR;
  208.                 d.boxMax[1] = unity_SpecCube1_BoxMax;
  209.                 d.boxMin[1] = unity_SpecCube1_BoxMin;
  210.                 d.probePosition[1] = unity_SpecCube1_ProbePosition;
  211.                 d.probeHDR[1] = unity_SpecCube1_HDR;
  212.                 Unity_GlossyEnvironmentData ugls_en_data;
  213.                 ugls_en_data.roughness = 1.0 - gloss;
  214.                 ugls_en_data.reflUVW = viewReflectDirection;
  215.                 UnityGI gi = UnityGlobalIllumination(d, 1, normalDirection, ugls_en_data );
  216.                 lightDirection = gi.light.dir;
  217.                 lightColor = gi.light.color;
  218. ////// Specular:
  219.                 float NdotL = max(0, dot( normalDirection, lightDirection ));
  220.                 float4 __OcclusionMap_var = tex2D(__OcclusionMap,TRANSFORM_TEX(i.uv0, __OcclusionMap));
  221.                 float3 specularAO = __OcclusionMap_var.r;
  222.                 float LdotH = max(0.0,dot(lightDirection, halfDirection));
  223.                 float3 specularColor = maskedmetal( _MetallicMap_var.rgb , node_5598 , _Metallic , _Metallic_2 , _SpecColor_3.g , node_9948 );
  224.                 float specularMonochrome;
  225.                 float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
  226.                 float3 node_4488 = maskedcolor( _MainTex_var.rgb , node_5598 , _Color.rgb , _Color_2.rgb , _Color_3.rgb , _SpecColor.rgb , node_9948 );
  227.                 float node_3559 = pow(1.0-max(0,dot(normalDirection, viewDirection)),lerp(10.0,0.0,_ReflectionEdges));
  228.                 float3 diffuseColor = lerp(node_4488,(node_4488*((texCUBElod(_Cubemap,float4(viewReflectDirection,lerp(0,6,_BlurReflection))).rgb*lerp(0.0,2.0,_ReflectionIntensity))+(node_3559*(node_3559*1.0+0.0)*node_3559*node_3559))),saturate((_ReflectionIntensity*_MaskTex_var.a))); // Need this for specular when using metallic
  229.                 diffuseColor = DiffuseAndSpecularFromMetallic( diffuseColor, specularColor, specularColor, specularMonochrome );
  230.                 specularMonochrome = 1.0-specularMonochrome;
  231.                 float NdotV = max(0.0,dot( normalDirection, viewDirection ));
  232.                 float NdotH = max(0.0,dot( normalDirection, halfDirection ));
  233.                 float VdotH = max(0.0,dot( viewDirection, halfDirection ));
  234.                 float visTerm = SmithJointGGXVisibilityTerm( NdotL, NdotV, 1.0-gloss );
  235.                 float normTerm = max(0.0, GGXTerm(NdotH, 1.0-gloss));
  236.                 float specularPBL = (NdotL*visTerm*normTerm) * (UNITY_PI / 4);
  237.                 if (IsGammaSpace())
  238.                     specularPBL = sqrt(max(1e-4h, specularPBL));
  239.                 specularPBL = max(0, specularPBL * NdotL);
  240.                 float3 directSpecular = (floor(attenuation) * _LightColor0.xyz)*specularPBL*FresnelTerm(specularColor, LdotH);
  241.                 half grazingTerm = saturate( gloss + specularMonochrome );
  242.                 float3 indirectSpecular = (gi.indirect.specular) * specularAO;
  243.                 indirectSpecular *= FresnelLerp (specularColor, grazingTerm, NdotV);
  244.                 float3 specular = (directSpecular + indirectSpecular);
  245. /////// Diffuse:
  246.                 NdotL = max(0.0,dot( normalDirection, lightDirection ));
  247.                 half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
  248.                 float nlPow5 = Pow5(1-NdotL);
  249.                 float nvPow5 = Pow5(1-NdotV);
  250.                 float3 directDiffuse = ((1 +(fd90 - 1)*nlPow5) * (1 + (fd90 - 1)*nvPow5) * NdotL) * attenColor;
  251.                 float3 indirectDiffuse = float3(0,0,0);
  252.                 indirectDiffuse += gi.indirect.diffuse;
  253.                 indirectDiffuse *= __OcclusionMap_var.r; // Diffuse AO
  254.                 float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;
  255. /// Final Color:
  256.                 float3 finalColor = diffuse + specular;
  257.                 fixed4 finalRGBA = fixed4(lerp(sceneColor.rgb, finalColor,clamp((saturate(_SpecColor_3.b)+_MainTex_var.a),0.0,1.0)),1);
  258.                 UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
  259.                 return finalRGBA;
  260.             }
  261.             ENDCG
  262.         }
  263.         Pass {
  264.             Name "FORWARD_DELTA"
  265.             Tags {
  266.                 "LightMode"="ForwardAdd"
  267.             }
  268.             Blend One One
  269.            
  270.            
  271.             CGPROGRAM
  272.             #pragma vertex vert
  273.             #pragma fragment frag
  274.             #define UNITY_PASS_FORWARDADD
  275.             #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
  276.             #define _GLOSSYENV 1
  277.             #include "UnityCG.cginc"
  278.             #include "AutoLight.cginc"
  279.             #include "Lighting.cginc"
  280.             #include "UnityPBSLighting.cginc"
  281.             #include "UnityStandardBRDF.cginc"
  282.             #pragma multi_compile_fwdadd
  283.             #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  284.             #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
  285.             #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
  286.             #pragma multi_compile_fog
  287.             #pragma exclude_renderers metal d3d11_9x xbox360 xboxone ps3 ps4 psp2
  288.             #pragma target 3.0
  289.             #pragma glsl
  290.             uniform sampler2D _GrabTexture;
  291.             uniform sampler2D _NormalMap; uniform float4 _NormalMap_ST;
  292.             uniform float _Refraction;
  293.             uniform float _NormalIntensity;
  294.             uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
  295.             uniform float4 _Color;
  296.             uniform float _Smoothness;
  297.             uniform float _ReflectionEdges;
  298.             uniform float _ReflectionIntensity;
  299.             uniform samplerCUBE _Cubemap;
  300.             uniform float _BlurReflection;
  301.             uniform sampler2D _MaskTex; uniform float4 _MaskTex_ST;
  302.             uniform float4 _Color_2;
  303.             uniform float4 _Color_3;
  304.             uniform float _Metallic;
  305.             uniform float _Metallic_2;
  306.             uniform float4 _SpecColor_3;
  307.             uniform float _Smoothness_2;
  308.             uniform sampler2D _MetallicMap; uniform float4 _MetallicMap_ST;
  309.             float3 maskedcolor( float3 c , float cmask , float3 c_color , float3 c_color_2 , float3 c_color_3 , float3 c_speccolor , float3 mask ){
  310.             float3 m_color = c.rgb * (1 - cmask) * _Color_2 + (c * _Color * mask.r) + (c * _SpecColor.rgb * mask.g) + (c * _Color_3 * mask.b);
  311.             return m_color;
  312.            
  313.             }
  314.            
  315.             half maskedmetal( float3 m , float cmask , half c_metal , half c_metal_2 , half c_speccolor3_g , float3 mask ){
  316.             half m_color = clamp(m.r * (1 - cmask) * c_metal_2 + (m.r * c_metal * mask.r) + (m.r * c_speccolor3_g * mask.g) + (m.r * mask.b),0,1);
  317.             return m_color;
  318.            
  319.             }
  320.            
  321.             half maskedgloss( half s , float cmask , half c_smooth , half c_smooth_2 , half c_speccolor3_a , float3 mask , half c_speccolor3_r ){
  322.             half s_color = clamp(s * (1 - cmask) * c_smooth_2 + ((s * c_smooth) * mask.r) + ((s * c_speccolor3_a) * mask.g) + (s * mask.b),0,1);
  323.             return s_color;
  324.            
  325.             }
  326.            
  327.             uniform float _MaskStrength;
  328.             uniform float4 _MaskColor;
  329.             struct VertexInput {
  330.                 float4 vertex : POSITION;
  331.                 float3 normal : NORMAL;
  332.                 float4 tangent : TANGENT;
  333.                 float2 texcoord0 : TEXCOORD0;
  334.                 float2 texcoord1 : TEXCOORD1;
  335.                 float2 texcoord2 : TEXCOORD2;
  336.             };
  337.             struct VertexOutput {
  338.                 float4 pos : SV_POSITION;
  339.                 float2 uv0 : TEXCOORD0;
  340.                 float2 uv1 : TEXCOORD1;
  341.                 float2 uv2 : TEXCOORD2;
  342.                 float4 posWorld : TEXCOORD3;
  343.                 float3 normalDir : TEXCOORD4;
  344.                 float3 tangentDir : TEXCOORD5;
  345.                 float3 bitangentDir : TEXCOORD6;
  346.                 float4 screenPos : TEXCOORD7;
  347.                 LIGHTING_COORDS(8,9)
  348.                 UNITY_FOG_COORDS(10)
  349.             };
  350.             VertexOutput vert (VertexInput v) {
  351.                 VertexOutput o = (VertexOutput)0;
  352.                 o.uv0 = v.texcoord0;
  353.                 o.uv1 = v.texcoord1;
  354.                 o.uv2 = v.texcoord2;
  355.                 o.normalDir = UnityObjectToWorldNormal(v.normal);
  356.                 o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );
  357.                 o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
  358.                 o.posWorld = mul(_Object2World, v.vertex);
  359.                 float3 lightColor = _LightColor0.rgb;
  360.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
  361.                 UNITY_TRANSFER_FOG(o,o.pos);
  362.                 o.screenPos = o.pos;
  363.                 TRANSFER_VERTEX_TO_FRAGMENT(o)
  364.                 return o;
  365.             }
  366.             float4 frag(VertexOutput i) : COLOR {
  367.                 #if UNITY_UV_STARTS_AT_TOP
  368.                     float grabSign = -_ProjectionParams.x;
  369.                 #else
  370.                     float grabSign = _ProjectionParams.x;
  371.                 #endif
  372.                 i.normalDir = normalize(i.normalDir);
  373.                 i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
  374.                 i.screenPos.y *= _ProjectionParams.x;
  375.                 float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
  376.                 float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  377.                 float3 _NormalMap_var = UnpackNormal(tex2D(_NormalMap,TRANSFORM_TEX(i.uv0, _NormalMap)));
  378.                 float3 normalLocal = lerp(float3(0,0,1),_NormalMap_var.rgb,_NormalIntensity);
  379.                 float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
  380.                 float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
  381.                 float4 _MaskTex_var = tex2D(_MaskTex,TRANSFORM_TEX(i.uv0, _MaskTex));
  382.                 float2 sceneUVs = float2(1,grabSign)*i.screenPos.xy*0.5+0.5 + (_NormalMap_var.rgb.r*(_MaskTex_var.a*_Refraction)).rr;
  383.                 float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
  384.                 float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
  385.                 float3 lightColor = _LightColor0.rgb;
  386.                 float3 halfDirection = normalize(viewDirection+lightDirection);
  387. ////// Lighting:
  388.                 float attenuation = LIGHT_ATTENUATION(i);
  389.                 float3 attenColor = attenuation * _LightColor0.xyz;
  390.                 float Pi = 3.141592654;
  391.                 float InvPi = 0.31830988618;
  392. ///////// Gloss:
  393.                 float4 _MetallicMap_var = tex2D(_MetallicMap,TRANSFORM_TEX(i.uv0, _MetallicMap));
  394.                 float node_5598 = min(1.0,(_MaskTex_var.r+_MaskTex_var.g+_MaskTex_var.b));
  395.                 float3 node_9948 = lerp(float4(0,0,0,0),float4((_MaskColor.rgb*_MaskTex_var.rgb),0.0),_MaskStrength).rgb;
  396.                 float gloss = maskedgloss( _MetallicMap_var.a , node_5598 , _Smoothness , _Smoothness_2 , _SpecColor_3.a , node_9948 , _SpecColor_3.r );
  397.                 float specPow = exp2( gloss * 10.0+1.0);
  398. ////// Specular:
  399.                 float NdotL = max(0, dot( normalDirection, lightDirection ));
  400.                 float LdotH = max(0.0,dot(lightDirection, halfDirection));
  401.                 float3 specularColor = maskedmetal( _MetallicMap_var.rgb , node_5598 , _Metallic , _Metallic_2 , _SpecColor_3.g , node_9948 );
  402.                 float specularMonochrome;
  403.                 float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
  404.                 float3 node_4488 = maskedcolor( _MainTex_var.rgb , node_5598 , _Color.rgb , _Color_2.rgb , _Color_3.rgb , _SpecColor.rgb , node_9948 );
  405.                 float node_3559 = pow(1.0-max(0,dot(normalDirection, viewDirection)),lerp(10.0,0.0,_ReflectionEdges));
  406.                 float3 diffuseColor = lerp(node_4488,(node_4488*((texCUBElod(_Cubemap,float4(viewReflectDirection,lerp(0,6,_BlurReflection))).rgb*lerp(0.0,2.0,_ReflectionIntensity))+(node_3559*(node_3559*1.0+0.0)*node_3559*node_3559))),saturate((_ReflectionIntensity*_MaskTex_var.a))); // Need this for specular when using metallic
  407.                 diffuseColor = DiffuseAndSpecularFromMetallic( diffuseColor, specularColor, specularColor, specularMonochrome );
  408.                 specularMonochrome = 1.0-specularMonochrome;
  409.                 float NdotV = max(0.0,dot( normalDirection, viewDirection ));
  410.                 float NdotH = max(0.0,dot( normalDirection, halfDirection ));
  411.                 float VdotH = max(0.0,dot( viewDirection, halfDirection ));
  412.                 float visTerm = SmithJointGGXVisibilityTerm( NdotL, NdotV, 1.0-gloss );
  413.                 float normTerm = max(0.0, GGXTerm(NdotH, 1.0-gloss));
  414.                 float specularPBL = (NdotL*visTerm*normTerm) * (UNITY_PI / 4);
  415.                 if (IsGammaSpace())
  416.                     specularPBL = sqrt(max(1e-4h, specularPBL));
  417.                 specularPBL = max(0, specularPBL * NdotL);
  418.                 float3 directSpecular = attenColor*specularPBL*FresnelTerm(specularColor, LdotH);
  419.                 float3 specular = directSpecular;
  420. /////// Diffuse:
  421.                 NdotL = max(0.0,dot( normalDirection, lightDirection ));
  422.                 half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
  423.                 float nlPow5 = Pow5(1-NdotL);
  424.                 float nvPow5 = Pow5(1-NdotV);
  425.                 float3 directDiffuse = ((1 +(fd90 - 1)*nlPow5) * (1 + (fd90 - 1)*nvPow5) * NdotL) * attenColor;
  426.                 float3 diffuse = directDiffuse * diffuseColor;
  427. /// Final Color:
  428.                 float3 finalColor = diffuse + specular;
  429.                 fixed4 finalRGBA = fixed4(finalColor * clamp((saturate(_SpecColor_3.b)+_MainTex_var.a),0.0,1.0),0);
  430.                 UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
  431.                 return finalRGBA;
  432.             }
  433.             ENDCG
  434.         }
  435.         Pass {
  436.             Name "Meta"
  437.             Tags {
  438.                 "LightMode"="Meta"
  439.             }
  440.             Cull Off
  441.            
  442.             CGPROGRAM
  443.             #pragma vertex vert
  444.             #pragma fragment frag
  445.             #define UNITY_PASS_META 1
  446.             #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
  447.             #define _GLOSSYENV 1
  448.             #include "UnityCG.cginc"
  449.             #include "Lighting.cginc"
  450.             #include "UnityPBSLighting.cginc"
  451.             #include "UnityStandardBRDF.cginc"
  452.             #include "UnityMetaPass.cginc"
  453.             #pragma fragmentoption ARB_precision_hint_fastest
  454.             #pragma multi_compile_shadowcaster
  455.             #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  456.             #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
  457.             #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
  458.             #pragma multi_compile_fog
  459.             #pragma exclude_renderers metal d3d11_9x xbox360 xboxone ps3 ps4 psp2
  460.             #pragma target 3.0
  461.             #pragma glsl
  462.             uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
  463.             uniform float4 _Color;
  464.             uniform float _Smoothness;
  465.             uniform float _ReflectionEdges;
  466.             uniform float _ReflectionIntensity;
  467.             uniform samplerCUBE _Cubemap;
  468.             uniform float _BlurReflection;
  469.             uniform sampler2D _MaskTex; uniform float4 _MaskTex_ST;
  470.             uniform float4 _Color_2;
  471.             uniform float4 _Color_3;
  472.             uniform float _Metallic;
  473.             uniform float _Metallic_2;
  474.             uniform float4 _SpecColor_3;
  475.             uniform float _Smoothness_2;
  476.             uniform sampler2D _MetallicMap; uniform float4 _MetallicMap_ST;
  477.             float3 maskedcolor( float3 c , float cmask , float3 c_color , float3 c_color_2 , float3 c_color_3 , float3 c_speccolor , float3 mask ){
  478.             float3 m_color = c.rgb * (1 - cmask) * _Color_2 + (c * _Color * mask.r) + (c * _SpecColor.rgb * mask.g) + (c * _Color_3 * mask.b);
  479.             return m_color;
  480.            
  481.             }
  482.            
  483.             half maskedmetal( float3 m , float cmask , half c_metal , half c_metal_2 , half c_speccolor3_g , float3 mask ){
  484.             half m_color = clamp(m.r * (1 - cmask) * c_metal_2 + (m.r * c_metal * mask.r) + (m.r * c_speccolor3_g * mask.g) + (m.r * mask.b),0,1);
  485.             return m_color;
  486.            
  487.             }
  488.            
  489.             half maskedgloss( half s , float cmask , half c_smooth , half c_smooth_2 , half c_speccolor3_a , float3 mask , half c_speccolor3_r ){
  490.             half s_color = clamp(s * (1 - cmask) * c_smooth_2 + ((s * c_smooth) * mask.r) + ((s * c_speccolor3_a) * mask.g) + (s * mask.b),0,1);
  491.             return s_color;
  492.            
  493.             }
  494.            
  495.             uniform float _MaskStrength;
  496.             uniform float4 _MaskColor;
  497.             struct VertexInput {
  498.                 float4 vertex : POSITION;
  499.                 float3 normal : NORMAL;
  500.                 float2 texcoord0 : TEXCOORD0;
  501.                 float2 texcoord1 : TEXCOORD1;
  502.                 float2 texcoord2 : TEXCOORD2;
  503.             };
  504.             struct VertexOutput {
  505.                 float4 pos : SV_POSITION;
  506.                 float2 uv0 : TEXCOORD0;
  507.                 float2 uv1 : TEXCOORD1;
  508.                 float2 uv2 : TEXCOORD2;
  509.                 float4 posWorld : TEXCOORD3;
  510.                 float3 normalDir : TEXCOORD4;
  511.             };
  512.             VertexOutput vert (VertexInput v) {
  513.                 VertexOutput o = (VertexOutput)0;
  514.                 o.uv0 = v.texcoord0;
  515.                 o.uv1 = v.texcoord1;
  516.                 o.uv2 = v.texcoord2;
  517.                 o.normalDir = UnityObjectToWorldNormal(v.normal);
  518.                 o.posWorld = mul(_Object2World, v.vertex);
  519.                 o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST );
  520.                 return o;
  521.             }
  522.             float4 frag(VertexOutput i) : SV_Target {
  523.                 i.normalDir = normalize(i.normalDir);
  524.                 float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  525.                 float3 normalDirection = i.normalDir;
  526.                 float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
  527.                 UnityMetaInput o;
  528.                 UNITY_INITIALIZE_OUTPUT( UnityMetaInput, o );
  529.                
  530.                 o.Emission = 0;
  531.                
  532.                 float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
  533.                 float4 _MaskTex_var = tex2D(_MaskTex,TRANSFORM_TEX(i.uv0, _MaskTex));
  534.                 float node_5598 = min(1.0,(_MaskTex_var.r+_MaskTex_var.g+_MaskTex_var.b));
  535.                 float3 node_9948 = lerp(float4(0,0,0,0),float4((_MaskColor.rgb*_MaskTex_var.rgb),0.0),_MaskStrength).rgb;
  536.                 float3 node_4488 = maskedcolor( _MainTex_var.rgb , node_5598 , _Color.rgb , _Color_2.rgb , _Color_3.rgb , _SpecColor.rgb , node_9948 );
  537.                 float node_3559 = pow(1.0-max(0,dot(normalDirection, viewDirection)),lerp(10.0,0.0,_ReflectionEdges));
  538.                 float3 diffColor = lerp(node_4488,(node_4488*((texCUBElod(_Cubemap,float4(viewReflectDirection,lerp(0,6,_BlurReflection))).rgb*lerp(0.0,2.0,_ReflectionIntensity))+(node_3559*(node_3559*1.0+0.0)*node_3559*node_3559))),saturate((_ReflectionIntensity*_MaskTex_var.a)));
  539.                 float specularMonochrome;
  540.                 float3 specColor;
  541.                 float4 _MetallicMap_var = tex2D(_MetallicMap,TRANSFORM_TEX(i.uv0, _MetallicMap));
  542.                 diffColor = DiffuseAndSpecularFromMetallic( diffColor, maskedmetal( _MetallicMap_var.rgb , node_5598 , _Metallic , _Metallic_2 , _SpecColor_3.g , node_9948 ), specColor, specularMonochrome );
  543.                 float roughness = 1.0 - maskedgloss( _MetallicMap_var.a , node_5598 , _Smoothness , _Smoothness_2 , _SpecColor_3.a , node_9948 , _SpecColor_3.r );
  544.                 o.Albedo = diffColor + specColor * roughness * roughness * 0.5;
  545.                
  546.                 return UnityMetaFragment( o );
  547.             }
  548.             ENDCG
  549.         }
  550.     }
  551.     FallBack "Diffuse"
  552.     CustomEditor "ShaderForgeMaterialInspector"
  553. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement