Search Unity

Why does this shader won't work on android?(diffuse legacy shows instead)

Discussion in 'Shaders' started by Dexter_Legseto, Nov 20, 2017.

  1. Dexter_Legseto

    Dexter_Legseto

    Joined:
    May 26, 2017
    Posts:
    1
    I putted it in the "Resources" folder and added in "Always included shaders" list.
    What could go wrong? Is there something with possible difference in OpenGL compability on android and PC?

    Thanks!

    Code (HSLS):
    1. Shader "Olanigan/Glass" {
    2.     Properties {
    3.         _snow ("snow", 2D) = "white" {}
    4.         _Color ("Color", Color) = (0.5019608,0.5019608,0.5019608,1)
    5.         _Metallic ("Metallic", Range(0, 1)) = 0.6030321
    6.         _Gloss ("Gloss", Range(0, 1)) = 0.3252537
    7.         _BumpMap ("Normal Map I", 2D) = "bump" {}
    8.         _NormalMapII ("Normal Map II", 2D) = "bump" {}
    9.         _snow_slider ("snow_slider", Range(0, 10)) = 7.705339
    10.         _Freezeeffectnormal ("Freeze effect (normal)", Range(0, 10)) = 4.77537
    11.         [MaterialToggle] _LocalGlobal ("Local/Global", Float ) = 0
    12.         _Transparency ("Transparency", Range(-1, 1)) = 0
    13.         _Ice_fresnel ("Ice_fresnel", Range(0, 3)) = 0
    14.         [HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
    15.     }
    16.     SubShader {
    17.         Tags {
    18.             "IgnoreProjector"="True"
    19.             "Queue"="Transparent"
    20.             "RenderType"="Transparent"
    21.         }
    22.         GrabPass{ }
    23.         Pass {
    24.             Name "FORWARD"
    25.             Tags {
    26.                 "LightMode"="ForwardBase"
    27.             }
    28.             Blend SrcAlpha OneMinusSrcAlpha
    29.             ZWrite Off
    30.          
    31.             CGPROGRAM
    32.             #pragma vertex vert
    33.             #pragma fragment frag
    34.             #define UNITY_PASS_FORWARDBASE
    35.             #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
    36.             #define _GLOSSYENV 1
    37.             #include "UnityCG.cginc"
    38.             #include "Lighting.cginc"
    39.             #include "UnityPBSLighting.cginc"
    40.             #include "UnityStandardBRDF.cginc"
    41.             #pragma multi_compile_fwdbase
    42.             #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
    43.             #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
    44.             #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
    45.             #pragma multi_compile_fog
    46.             #pragma only_renderers d3d9 d3d11 glcore gles n3ds wiiu
    47.             #pragma target 3.0
    48.             uniform sampler2D _GrabTexture;
    49.             uniform float4 _Color;
    50.             uniform sampler2D _BumpMap; uniform float4 _BumpMap_ST;
    51.             uniform float _Metallic;
    52.             uniform float _Gloss;
    53.             uniform sampler2D _snow; uniform float4 _snow_ST;
    54.             uniform float _Transparency;
    55.             uniform float _Ice_fresnel;
    56.             struct VertexInput {
    57.                 float4 vertex : POSITION;
    58.                 float3 normal : NORMAL;
    59.                 float4 tangent : TANGENT;
    60.                 float2 texcoord0 : TEXCOORD0;
    61.                 float2 texcoord1 : TEXCOORD1;
    62.                 float2 texcoord2 : TEXCOORD2;
    63.             };
    64.             struct VertexOutput {
    65.                 float4 pos : SV_POSITION;
    66.                 float2 uv0 : TEXCOORD0;
    67.                 float2 uv1 : TEXCOORD1;
    68.                 float2 uv2 : TEXCOORD2;
    69.                 float4 posWorld : TEXCOORD3;
    70.                 float3 normalDir : TEXCOORD4;
    71.                 float3 tangentDir : TEXCOORD5;
    72.                 float3 bitangentDir : TEXCOORD6;
    73.                 float4 screenPos : TEXCOORD7;
    74.                 UNITY_FOG_COORDS(8)
    75.                 #if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH)
    76.                     float4 ambientOrLightmapUV : TEXCOORD9;
    77.                 #endif
    78.             };
    79.             VertexOutput vert (VertexInput v) {
    80.                 VertexOutput o = (VertexOutput)0;
    81.                 o.uv0 = v.texcoord0;
    82.                 o.uv1 = v.texcoord1;
    83.                 o.uv2 = v.texcoord2;
    84.                 #ifdef LIGHTMAP_ON
    85.                     o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
    86.                     o.ambientOrLightmapUV.zw = 0;
    87.                 #elif UNITY_SHOULD_SAMPLE_SH
    88.                 #endif
    89.                 #ifdef DYNAMICLIGHTMAP_ON
    90.                     o.ambientOrLightmapUV.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
    91.                 #endif
    92.                 o.normalDir = UnityObjectToWorldNormal(v.normal);
    93.                 o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
    94.                 o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
    95.                 o.posWorld = mul(unity_ObjectToWorld, v.vertex);
    96.                 float3 lightColor = _LightColor0.rgb;
    97.                 o.pos = UnityObjectToClipPos(v.vertex );
    98.                 UNITY_TRANSFER_FOG(o,o.pos);
    99.                 o.screenPos = o.pos;
    100.                 return o;
    101.             }
    102.             float4 frag(VertexOutput i) : COLOR {
    103.                 #if UNITY_UV_STARTS_AT_TOP
    104.                     float grabSign = -_ProjectionParams.x;
    105.                 #else
    106.                     float grabSign = _ProjectionParams.x;
    107.                 #endif
    108.                 i.normalDir = normalize(i.normalDir);
    109.                 i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
    110.                 i.screenPos.y *= _ProjectionParams.x;
    111.                 float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
    112.                 float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
    113.                 float3 _BumpMap_var = UnpackNormal(tex2D(_BumpMap,TRANSFORM_TEX(i.uv0, _BumpMap)));
    114.                 float3 normalLocal = _BumpMap_var.rgb;
    115.                 float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
    116.                 float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
    117.                 float node_1294 = pow(1.0-max(0,dot(normalDirection, viewDirection)),_Ice_fresnel);
    118.                 float2 sceneUVs = float2(1,grabSign)*i.screenPos.xy*0.5+0.5 + (i.uv0*node_1294);
    119.                 float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
    120.                 float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
    121.                 float3 lightColor = _LightColor0.rgb;
    122.                 float3 halfDirection = normalize(viewDirection+lightDirection);
    123. ////// Lighting:
    124.                 float attenuation = 1;
    125.                 float3 attenColor = attenuation * _LightColor0.xyz;
    126.                 float Pi = 3.141592654;
    127.                 float InvPi = 0.31830988618;
    128. ///////// Gloss:
    129.                 float gloss = (_Gloss*0.7);
    130.                 float perceptualRoughness = 1.0 - (_Gloss*0.7);
    131.                 float roughness = perceptualRoughness * perceptualRoughness;
    132.                 float specPow = exp2( gloss * 10.0 + 1.0 );
    133. /////// GI Data:
    134.                 UnityLight light;
    135.                 #ifdef LIGHTMAP_OFF
    136.                     light.color = lightColor;
    137.                     light.dir = lightDirection;
    138.                     light.ndotl = LambertTerm (normalDirection, light.dir);
    139.                 #else
    140.                     light.color = half3(0.f, 0.f, 0.f);
    141.                     light.ndotl = 0.0f;
    142.                     light.dir = half3(0.f, 0.f, 0.f);
    143.                 #endif
    144.                 UnityGIInput d;
    145.                 d.light = light;
    146.                 d.worldPos = i.posWorld.xyz;
    147.                 d.worldViewDir = viewDirection;
    148.                 d.atten = attenuation;
    149.                 #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
    150.                     d.ambient = 0;
    151.                     d.lightmapUV = i.ambientOrLightmapUV;
    152.                 #else
    153.                     d.ambient = i.ambientOrLightmapUV;
    154.                 #endif
    155.                 #if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION
    156.                     d.boxMin[0] = unity_SpecCube0_BoxMin;
    157.                     d.boxMin[1] = unity_SpecCube1_BoxMin;
    158.                 #endif
    159.                 #if UNITY_SPECCUBE_BOX_PROJECTION
    160.                     d.boxMax[0] = unity_SpecCube0_BoxMax;
    161.                     d.boxMax[1] = unity_SpecCube1_BoxMax;
    162.                     d.probePosition[0] = unity_SpecCube0_ProbePosition;
    163.                     d.probePosition[1] = unity_SpecCube1_ProbePosition;
    164.                 #endif
    165.                 d.probeHDR[0] = unity_SpecCube0_HDR;
    166.                 d.probeHDR[1] = unity_SpecCube1_HDR;
    167.                 Unity_GlossyEnvironmentData ugls_en_data;
    168.                 ugls_en_data.roughness = 1.0 - gloss;
    169.                 ugls_en_data.reflUVW = viewReflectDirection;
    170.                 UnityGI gi = UnityGlobalIllumination(d, 1, normalDirection, ugls_en_data );
    171.                 lightDirection = gi.light.dir;
    172.                 lightColor = gi.light.color;
    173. ////// Specular:
    174.                 float NdotL = saturate(dot( normalDirection, lightDirection ));
    175.                 float LdotH = saturate(dot(lightDirection, halfDirection));
    176.                 float3 specularColor = (_Metallic*1.0);
    177.                 float specularMonochrome;
    178.                 float4 _snow_var = tex2D(_snow,TRANSFORM_TEX(i.uv0, _snow));
    179.                 float3 diffuseColor = (_Color.rgb*_snow_var.rgb); // Need this for specular when using metallic
    180.                 diffuseColor = DiffuseAndSpecularFromMetallic( diffuseColor, specularColor, specularColor, specularMonochrome );
    181.                 specularMonochrome = 1.0-specularMonochrome;
    182.                 float NdotV = abs(dot( normalDirection, viewDirection ));
    183.                 float NdotH = saturate(dot( normalDirection, halfDirection ));
    184.                 float VdotH = saturate(dot( viewDirection, halfDirection ));
    185.                 float visTerm = SmithJointGGXVisibilityTerm( NdotL, NdotV, roughness );
    186.                 float normTerm = GGXTerm(NdotH, roughness);
    187.                 float specularPBL = (visTerm*normTerm) * UNITY_PI;
    188.                 #ifdef UNITY_COLORSPACE_GAMMA
    189.                     specularPBL = sqrt(max(1e-4h, specularPBL));
    190.                 #endif
    191.                 specularPBL = max(0, specularPBL * NdotL);
    192.                 #if defined(_SPECULARHIGHLIGHTS_OFF)
    193.                     specularPBL = 0.0;
    194.                 #endif
    195.                 half surfaceReduction;
    196.                 #ifdef UNITY_COLORSPACE_GAMMA
    197.                     surfaceReduction = 1.0-0.28*roughness*perceptualRoughness;
    198.                 #else
    199.                     surfaceReduction = 1.0/(roughness*roughness + 1.0);
    200.                 #endif
    201.                 specularPBL *= any(specularColor) ? 1.0 : 0.0;
    202.                 float3 directSpecular = attenColor*specularPBL*FresnelTerm(specularColor, LdotH);
    203.                 half grazingTerm = saturate( gloss + specularMonochrome );
    204.                 float3 indirectSpecular = (gi.indirect.specular);
    205.                 indirectSpecular *= FresnelLerp (specularColor, grazingTerm, NdotV);
    206.                 indirectSpecular *= surfaceReduction;
    207.                 float3 specular = (directSpecular + indirectSpecular);
    208. /////// Diffuse:
    209.                 NdotL = max(0.0,dot( normalDirection, lightDirection ));
    210.                 half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
    211.                 float nlPow5 = Pow5(1-NdotL);
    212.                 float nvPow5 = Pow5(1-NdotV);
    213.                 float3 directDiffuse = ((1 +(fd90 - 1)*nlPow5) * (1 + (fd90 - 1)*nvPow5) * NdotL) * attenColor;
    214.                 float3 indirectDiffuse = float3(0,0,0);
    215.                 indirectDiffuse += gi.indirect.diffuse;
    216.                 float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;
    217. /// Final Color:
    218.                 float3 finalColor = diffuse + specular;
    219.                 fixed4 finalRGBA = fixed4(lerp(sceneColor.rgb, finalColor,lerp(node_1294,1.0,_Transparency)),1);
    220.                 UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
    221.                 return finalRGBA;
    222.             }
    223.             ENDCG
    224.         }
    225.         Pass {
    226.             Name "FORWARD_DELTA"
    227.             Tags {
    228.                 "LightMode"="ForwardAdd"
    229.             }
    230.             Blend One One
    231.             ZWrite Off
    232.          
    233.             CGPROGRAM
    234.             #pragma vertex vert
    235.             #pragma fragment frag
    236.             #define UNITY_PASS_FORWARDADD
    237.             #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
    238.             #define _GLOSSYENV 1
    239.             #include "UnityCG.cginc"
    240.             #include "AutoLight.cginc"
    241.             #include "Lighting.cginc"
    242.             #include "UnityPBSLighting.cginc"
    243.             #include "UnityStandardBRDF.cginc"
    244.             #pragma multi_compile_fwdadd
    245.             #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
    246.             #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
    247.             #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
    248.             #pragma multi_compile_fog
    249.             #pragma only_renderers d3d9 d3d11 glcore gles n3ds wiiu
    250.             #pragma target 3.0
    251.             uniform sampler2D _GrabTexture;
    252.             uniform float4 _Color;
    253.             uniform sampler2D _BumpMap; uniform float4 _BumpMap_ST;
    254.             uniform float _Metallic;
    255.             uniform float _Gloss;
    256.             uniform sampler2D _snow; uniform float4 _snow_ST;
    257.             uniform float _Transparency;
    258.             uniform float _Ice_fresnel;
    259.             struct VertexInput {
    260.                 float4 vertex : POSITION;
    261.                 float3 normal : NORMAL;
    262.                 float4 tangent : TANGENT;
    263.                 float2 texcoord0 : TEXCOORD0;
    264.                 float2 texcoord1 : TEXCOORD1;
    265.                 float2 texcoord2 : TEXCOORD2;
    266.             };
    267.             struct VertexOutput {
    268.                 float4 pos : SV_POSITION;
    269.                 float2 uv0 : TEXCOORD0;
    270.                 float2 uv1 : TEXCOORD1;
    271.                 float2 uv2 : TEXCOORD2;
    272.                 float4 posWorld : TEXCOORD3;
    273.                 float3 normalDir : TEXCOORD4;
    274.                 float3 tangentDir : TEXCOORD5;
    275.                 float3 bitangentDir : TEXCOORD6;
    276.                 float4 screenPos : TEXCOORD7;
    277.                 LIGHTING_COORDS(8,9)
    278.                 UNITY_FOG_COORDS(10)
    279.             };
    280.             VertexOutput vert (VertexInput v) {
    281.                 VertexOutput o = (VertexOutput)0;
    282.                 o.uv0 = v.texcoord0;
    283.                 o.uv1 = v.texcoord1;
    284.                 o.uv2 = v.texcoord2;
    285.                 o.normalDir = UnityObjectToWorldNormal(v.normal);
    286.                 o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
    287.                 o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
    288.                 o.posWorld = mul(unity_ObjectToWorld, v.vertex);
    289.                 float3 lightColor = _LightColor0.rgb;
    290.                 o.pos = UnityObjectToClipPos(v.vertex );
    291.                 UNITY_TRANSFER_FOG(o,o.pos);
    292.                 o.screenPos = o.pos;
    293.                 TRANSFER_VERTEX_TO_FRAGMENT(o)
    294.                 return o;
    295.             }
    296.             float4 frag(VertexOutput i) : COLOR {
    297.                 #if UNITY_UV_STARTS_AT_TOP
    298.                     float grabSign = -_ProjectionParams.x;
    299.                 #else
    300.                     float grabSign = _ProjectionParams.x;
    301.                 #endif
    302.                 i.normalDir = normalize(i.normalDir);
    303.                 i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
    304.                 i.screenPos.y *= _ProjectionParams.x;
    305.                 float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
    306.                 float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
    307.                 float3 _BumpMap_var = UnpackNormal(tex2D(_BumpMap,TRANSFORM_TEX(i.uv0, _BumpMap)));
    308.                 float3 normalLocal = _BumpMap_var.rgb;
    309.                 float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
    310.                 float node_1294 = pow(1.0-max(0,dot(normalDirection, viewDirection)),_Ice_fresnel);
    311.                 float2 sceneUVs = float2(1,grabSign)*i.screenPos.xy*0.5+0.5 + (i.uv0*node_1294);
    312.                 float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
    313.                 float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
    314.                 float3 lightColor = _LightColor0.rgb;
    315.                 float3 halfDirection = normalize(viewDirection+lightDirection);
    316. ////// Lighting:
    317.                 float attenuation = LIGHT_ATTENUATION(i);
    318.                 float3 attenColor = attenuation * _LightColor0.xyz;
    319.                 float Pi = 3.141592654;
    320.                 float InvPi = 0.31830988618;
    321. ///////// Gloss:
    322.                 float gloss = (_Gloss*0.7);
    323.                 float perceptualRoughness = 1.0 - (_Gloss*0.7);
    324.                 float roughness = perceptualRoughness * perceptualRoughness;
    325.                 float specPow = exp2( gloss * 10.0 + 1.0 );
    326. ////// Specular:
    327.                 float NdotL = saturate(dot( normalDirection, lightDirection ));
    328.                 float LdotH = saturate(dot(lightDirection, halfDirection));
    329.                 float3 specularColor = (_Metallic*1.0);
    330.                 float specularMonochrome;
    331.                 float4 _snow_var = tex2D(_snow,TRANSFORM_TEX(i.uv0, _snow));
    332.                 float3 diffuseColor = (_Color.rgb*_snow_var.rgb); // Need this for specular when using metallic
    333.                 diffuseColor = DiffuseAndSpecularFromMetallic( diffuseColor, specularColor, specularColor, specularMonochrome );
    334.                 specularMonochrome = 1.0-specularMonochrome;
    335.                 float NdotV = abs(dot( normalDirection, viewDirection ));
    336.                 float NdotH = saturate(dot( normalDirection, halfDirection ));
    337.                 float VdotH = saturate(dot( viewDirection, halfDirection ));
    338.                 float visTerm = SmithJointGGXVisibilityTerm( NdotL, NdotV, roughness );
    339.                 float normTerm = GGXTerm(NdotH, roughness);
    340.                 float specularPBL = (visTerm*normTerm) * UNITY_PI;
    341.                 #ifdef UNITY_COLORSPACE_GAMMA
    342.                     specularPBL = sqrt(max(1e-4h, specularPBL));
    343.                 #endif
    344.                 specularPBL = max(0, specularPBL * NdotL);
    345.                 #if defined(_SPECULARHIGHLIGHTS_OFF)
    346.                     specularPBL = 0.0;
    347.                 #endif
    348.                 specularPBL *= any(specularColor) ? 1.0 : 0.0;
    349.                 float3 directSpecular = attenColor*specularPBL*FresnelTerm(specularColor, LdotH);
    350.                 float3 specular = directSpecular;
    351. /////// Diffuse:
    352.                 NdotL = max(0.0,dot( normalDirection, lightDirection ));
    353.                 half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
    354.                 float nlPow5 = Pow5(1-NdotL);
    355.                 float nvPow5 = Pow5(1-NdotV);
    356.                 float3 directDiffuse = ((1 +(fd90 - 1)*nlPow5) * (1 + (fd90 - 1)*nvPow5) * NdotL) * attenColor;
    357.                 float3 diffuse = directDiffuse * diffuseColor;
    358. /// Final Color:
    359.                 float3 finalColor = diffuse + specular;
    360.                 fixed4 finalRGBA = fixed4(finalColor * lerp(node_1294,1.0,_Transparency),0);
    361.                 UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
    362.                 return finalRGBA;
    363.             }
    364.             ENDCG
    365.         }
    366.         Pass {
    367.             Name "Meta"
    368.             Tags {
    369.                 "LightMode"="Meta"
    370.             }
    371.             Cull Off
    372.          
    373.             CGPROGRAM
    374.             #pragma vertex vert
    375.             #pragma fragment frag
    376.             #define UNITY_PASS_META 1
    377.             #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
    378.             #define _GLOSSYENV 1
    379.             #include "UnityCG.cginc"
    380.             #include "Lighting.cginc"
    381.             #include "UnityPBSLighting.cginc"
    382.             #include "UnityStandardBRDF.cginc"
    383.             #include "UnityMetaPass.cginc"
    384.             #pragma fragmentoption ARB_precision_hint_fastest
    385.             #pragma multi_compile_shadowcaster
    386.             #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
    387.             #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
    388.             #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
    389.             #pragma multi_compile_fog
    390.             #pragma only_renderers d3d9 d3d11 glcore gles n3ds wiiu
    391.             #pragma target 3.0
    392.             uniform float4 _Color;
    393.             uniform float _Metallic;
    394.             uniform float _Gloss;
    395.             uniform sampler2D _snow; uniform float4 _snow_ST;
    396.             struct VertexInput {
    397.                 float4 vertex : POSITION;
    398.                 float2 texcoord0 : TEXCOORD0;
    399.                 float2 texcoord1 : TEXCOORD1;
    400.                 float2 texcoord2 : TEXCOORD2;
    401.             };
    402.             struct VertexOutput {
    403.                 float4 pos : SV_POSITION;
    404.                 float2 uv0 : TEXCOORD0;
    405.                 float2 uv1 : TEXCOORD1;
    406.                 float2 uv2 : TEXCOORD2;
    407.                 float4 posWorld : TEXCOORD3;
    408.             };
    409.             VertexOutput vert (VertexInput v) {
    410.                 VertexOutput o = (VertexOutput)0;
    411.                 o.uv0 = v.texcoord0;
    412.                 o.uv1 = v.texcoord1;
    413.                 o.uv2 = v.texcoord2;
    414.                 o.posWorld = mul(unity_ObjectToWorld, v.vertex);
    415.                 o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST );
    416.                 return o;
    417.             }
    418.             float4 frag(VertexOutput i) : SV_Target {
    419.                 float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
    420.                 UnityMetaInput o;
    421.                 UNITY_INITIALIZE_OUTPUT( UnityMetaInput, o );
    422.              
    423.                 o.Emission = 0;
    424.              
    425.                 float4 _snow_var = tex2D(_snow,TRANSFORM_TEX(i.uv0, _snow));
    426.                 float3 diffColor = (_Color.rgb*_snow_var.rgb);
    427.                 float specularMonochrome;
    428.                 float3 specColor;
    429.                 diffColor = DiffuseAndSpecularFromMetallic( diffColor, (_Metallic*1.0), specColor, specularMonochrome );
    430.                 float roughness = 1.0 - (_Gloss*0.7);
    431.                 o.Albedo = diffColor + specColor * roughness * roughness * 0.5;
    432.              
    433.                 return UnityMetaFragment( o );
    434.             }
    435.             ENDCG
    436.         }
    437.     }
    438.     FallBack "Diffuse"
    439.     CustomEditor "ShaderForgeMaterialInspector"
    440. }