Advertisement
emclick

TassellationStandard

Jul 18th, 2016
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "EMCLICK/TassellationStandard" {
  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 { "RenderType"="Opaque" }
  45.         LOD 700
  46.        
  47.         CGPROGRAM
  48.         // Physically based Standard lighting model, and enable shadows on all light types
  49.         #pragma surface surf Standard addshadow vertex:disp tessellate:tessEdge tessphong:_Smoothness
  50.         //#pragma multi_compile_fog
  51.         // Use shader model 3.0 target, to get nicer looking lighting
  52.         #pragma target 5.0
  53.         #include "Tessellation.cginc"
  54.  
  55.         sampler2D _MainTex;
  56.         sampler2D _MetallicGlossMap;
  57.         sampler2D _BumpMap;
  58.         sampler2D _DetailAlbedoMap;
  59.         sampler2D _DetailNormalMap;
  60.         sampler2D _EmissionMap;
  61.         sampler2D _ParallaxMap;
  62.         sampler2D _OcclusionMap;
  63.  
  64.         float _BumpScale;
  65.         float _EdgeLength;
  66.         float _Smoothness;
  67.         float _Parallax;
  68.         float _OcclusionStrength;
  69.         half _Glossiness;
  70.         half _Metallic;
  71.         float _DetailNormalMapScale;
  72.         fixed4 _Color;
  73.         fixed4 _EmissionColor;
  74.         float _Mode;
  75.  
  76.         struct Input {
  77.             float2 uv_MainTex;
  78.             float2 uv_MetallicGlossMap;
  79.             float2 uv_BumpMap;
  80.             float2 uv_DetailAlbedoMap;
  81.             float2 uv_DetailNormalMap;
  82.             float2 uv_EmissionMap;
  83.             float2 uv_OcclusionMap;
  84.         };
  85.  
  86.         struct appdata {
  87.             float4 vertex : POSITION;
  88.             float4 tangent : TANGENT;
  89.             float3 normal : NORMAL;
  90.             float2 texcoord : TEXCOORD0;
  91.             float2 texcoord1 : TEXCOORD1;
  92.             float2 texcoord2 : TEXCOORD2;
  93.         };
  94.  
  95.         float4 tessEdge(appdata v0, appdata v1, appdata v2)
  96.         {
  97.             return UnityEdgeLengthBasedTessCull(v0.vertex, v1.vertex, v2.vertex, _EdgeLength, 0.0);
  98.         }
  99.  
  100.         void disp(inout appdata v)
  101.         {
  102.             float d = tex2Dlod(_ParallaxMap, float4(v.texcoord.xy, 0, 0)).a * _Parallax;
  103.             v.vertex.xyz += v.normal * d;
  104.         }
  105.  
  106.         /*half alphaStandard()
  107.         {
  108.             if (_Mode == 3)
  109.                 return fade();
  110.         }*/
  111.  
  112.         void surf (Input IN, inout SurfaceOutputStandard o) {
  113.             // Albedo comes from a texture tinted by color
  114.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
  115.             fixed4 d = tex2D(_DetailAlbedoMap, IN.uv_DetailAlbedoMap);
  116.  
  117.             o.Albedo = c.rgb * d.rgb * _Color.rgb;
  118.             o.Occlusion = tex2D(_OcclusionMap, IN.uv_OcclusionMap) * _OcclusionStrength;
  119.             o.Emission = c.rgb * tex2D(_EmissionMap, IN.uv_EmissionMap).a *_EmissionColor.rrr;
  120. #if defined (UNITY_PASS_META)
  121.             o.Emission *= _EmissionColor.rrr;
  122. #endif
  123.  
  124.             o.Metallic = tex2D(_MetallicGlossMap, IN.uv_MetallicGlossMap).a * _Metallic;
  125.             o.Smoothness = tex2D(_MetallicGlossMap, IN.uv_MetallicGlossMap).r * _Glossiness;
  126.             o.Alpha = c.a * d.a * _Color.a;
  127.             fixed4 db = tex2D(_DetailNormalMap, IN.uv_DetailNormalMap);
  128.             o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap) * (db * _DetailNormalMapScale)) * _BumpScale;
  129.         }
  130.         ENDCG
  131.     }
  132.     FallBack "Diffuse"
  133.     CustomEditor "TassellationStandardShaderGUI"
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement