Advertisement
emclick

TassellationTransparentStandard

Jul 18th, 2016
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "EMCLICK/TassellationTransparentStandard" {
  2.     Properties {
  3.         _Color("Color", Color) = (1,1,1,1)
  4.         _MainTex("Albedo", 2D) = "white" {}
  5.        
  6.         _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
  7.  
  8.         _Glossiness("Glossiness", Range(0.0, 1.0)) = 0.5
  9.         [Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
  10.         _MetallicGlossMap("Metallic", 2D) = "white" {}
  11.  
  12.         _EdgeLength ("Edge length", Range(3,50)) = 10
  13.         _Smoothness ("Smoothness", Range(0,1)) = 0.5
  14.  
  15.         _BumpScale("Scale", Float) = 1.0
  16.         _BumpMap("Normal Map", 2D) = "bump" {}
  17.  
  18.         _Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02
  19.         _ParallaxMap ("Height Map", 2D) = "black" {}
  20.  
  21.         _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
  22.         _OcclusionMap("Occlusion", 2D) = "white" {}
  23.  
  24.         _EmissionColor("Color", Color) = (0,0,0)
  25.         _EmissionMap("Emission", 2D) = "white" {}
  26.        
  27.         _DetailMask("Detail Mask", 2D) = "white" {}
  28.  
  29.         _DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}
  30.         _DetailNormalMapScale("Scale", Float) = 1.0
  31.         _DetailNormalMap("Normal Map", 2D) = "bump" {}
  32.  
  33.         [Enum(UV0,0,UV1,1)] _UVSec ("UV Set for secondary textures", Float) = 0
  34.  
  35.  
  36.         // Blending state
  37.         [HideInInspector] _Mode ("__mode", Float) = 0.0
  38.         [HideInInspector] _SrcBlend ("__src", Float) = 1.0
  39.         [HideInInspector] _DstBlend ("__dst", Float) = 0.0
  40.         [HideInInspector] _ZWrite ("__zw", Float) = 1.0
  41.     }
  42.  
  43.     SubShader {
  44.         Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
  45.         LOD 100
  46.         Blend [_SrcBlend] [_DstBlend]
  47.         ZWrite [_ZWrite]
  48.         Cull Off
  49.        
  50.         CGPROGRAM
  51.         // Physically based Standard lighting model, and enable shadows on all light types
  52.         #pragma surface surf Standard fullforwardshadows vertex:disp tessellate:tessEdge tessphong:_Smoothness alpha:fade
  53.         #pragma multi_compile_fog
  54.         // Use shader model 3.0 target, to get nicer looking lighting
  55.         #pragma target 5.0
  56.         #include "Tessellation.cginc"
  57.  
  58.         sampler2D _MainTex;
  59.         sampler2D _BumpMap;
  60.         sampler2D _DetailAlbedoMap;
  61.         sampler2D _DetailNormalMap;
  62.         sampler2D _EmissionMap;
  63.         sampler2D _ParallaxMap;
  64.         sampler2D _OcclusionMap;
  65.  
  66.         float _BumpScale;
  67.         float _EdgeLength;
  68.         float _Smoothness;
  69.         float _Parallax;
  70.         float _OcclusionStrength;
  71.         half _Glossiness;
  72.         half _Metallic;
  73.         float _DetailNormalMapScale;
  74.         fixed4 _Color;
  75.         fixed4 _EmissionColor;
  76.         float _Mode;
  77.  
  78.         struct Input {
  79.             float2 uv_MainTex;
  80.             float2 uv_BumpMap;
  81.             float2 uv_DetailAlbedoMap;
  82.             float2 uv_DetailNormalMap;
  83.             float2 uv_EmissionMap;
  84.             float2 uv_OcclusionMap;
  85.         };
  86.  
  87.         struct appdata {
  88.             float4 vertex : POSITION;
  89.             float4 tangent : TANGENT;
  90.             float3 normal : NORMAL;
  91.             float2 texcoord : TEXCOORD0;
  92.             float2 texcoord1 : TEXCOORD1;
  93.             float2 texcoord2 : TEXCOORD2;
  94.         };
  95.  
  96.         float4 tessEdge(appdata v0, appdata v1, appdata v2)
  97.         {
  98.             return UnityEdgeLengthBasedTessCull(v0.vertex, v1.vertex, v2.vertex, _EdgeLength, 0.0);
  99.         }
  100.  
  101.         void disp(inout appdata v)
  102.         {
  103.             float d = tex2Dlod(_ParallaxMap, float4(v.texcoord.xy, 0, 0)).a * _Parallax;
  104.             v.vertex.xyz += v.normal * d;
  105.         }
  106.  
  107.         /*half alphaStandard()
  108.         {
  109.             if (_Mode == 3)
  110.                 return fade();
  111.         }*/
  112.  
  113.         void surf (Input IN, inout SurfaceOutputStandard o) {
  114.             // Albedo comes from a texture tinted by color
  115.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
  116.             fixed4 d = tex2D(_DetailAlbedoMap, IN.uv_DetailAlbedoMap);
  117.  
  118.             o.Albedo = c.rgb * d.rgb * _Color.rgb;
  119.             o.Occlusion = tex2D(_OcclusionMap, IN.uv_OcclusionMap) * _OcclusionStrength;
  120.             o.Emission = c.rgb * tex2D(_EmissionMap, IN.uv_EmissionMap).a *_EmissionColor.rrr;
  121. #if defined (UNITY_PASS_META)
  122.             o.Emission *= _EmissionColor.rrr;
  123. #endif
  124.  
  125.             o.Metallic = _Metallic;
  126.             o.Smoothness = _Glossiness;
  127.             o.Alpha = c.a * d.a * _Color.a;
  128.             fixed4 db = tex2D(_DetailNormalMap, IN.uv_DetailNormalMap);
  129.             o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap) * (db * _DetailNormalMapScale)) * _BumpScale;
  130.         }
  131.         ENDCG
  132.     }
  133.     FallBack "Diffuse"
  134.     CustomEditor "TassellationStandardShaderGUI"
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement