Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2015
1,900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.18 KB | None | 0 0
  1. Shader "Standard (Tesselation)" {
  2.     Properties {
  3.         _Color ("Color", Color) = (1,1,1,1)
  4.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
  5.         _BumpMap ("Normal Map (RGB)", 2D) = "bump" {}
  6.         _BumpScale ("Normal Power" , Float) = 1
  7.         _Occlusion ("Occlusion Map (R)" , 2D) = "white" {}
  8.         _Metallic ("Metallic (R) , Smoothness (A)" , 2D) = "black" {}
  9.         _ParallaxMap ("Heightmap (A)", 2D) = "black" {}
  10.         _EdgeLength ("Edge length", Range(3,50)) = 10
  11.         _Parallax ("Height", Range (0.0, 1.0)) = 0.5
  12.  
  13.     }
  14.     SubShader {
  15.         Tags { "RenderType"="Opaque" }
  16.         LOD 200
  17.        
  18.         CGPROGRAM
  19.         // Physically based Standard lighting model, and enable shadows on all light types
  20.        
  21.         #pragma surface surf Standard fullforwardshadows vertex:disp tessellate:tessEdge
  22.         #include "Tessellation.cginc"
  23.        
  24.         sampler2D _ParallaxMap;
  25.         float _EdgeLength;
  26.         fixed _Parallax;
  27.         float _BumpScale;
  28.         sampler2D _MainTex;
  29.         sampler2D _Occlusion;
  30.         sampler2D _BumpMap;
  31.         sampler2D _Metallic;
  32.        
  33.         struct appdata {
  34.             float4 vertex : POSITION;
  35.             float4 tangent : TANGENT;
  36.             float3 normal : NORMAL;
  37.             float2 texcoord : TEXCOORD0;
  38.             float2 texcoord1 : TEXCOORD1;
  39.             float2 texcoord2 : TEXCOORD2;
  40.         };
  41.        
  42.         float4 tessEdge (appdata v0, appdata v1,appdata v2)
  43.         {
  44.             return UnityEdgeLengthBasedTessCull (v0.vertex, v1.vertex, v2.vertex, _EdgeLength, _Parallax * 1.5f);
  45.         }  
  46.    
  47.         void disp (inout appdata v)
  48.         {
  49.             float d = tex2Dlod(_ParallaxMap, float4(v.texcoord.xy,0,0)).a * _Parallax;
  50.             v.vertex.xyz += v.normal * d;
  51.         }
  52.  
  53.         // Use shader model 3.0 target, to get nicer looking lighting
  54.         #pragma target 3.0
  55.  
  56.  
  57.         struct Input {
  58.             float2 uv_MainTex;
  59.         };
  60.  
  61.         fixed4 _Color;
  62.  
  63.         void surf (Input IN, inout SurfaceOutputStandard o) {
  64.             // Albedo comes from a texture tinted by color
  65.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
  66.             o.Albedo = c.rgb;
  67.             // Metallic and smoothness come from slider variables
  68.             fixed4 m = tex2D(_Metallic,IN.uv_MainTex);
  69.             o.Metallic = m.r;
  70.             o.Occlusion = tex2D(_Occlusion,IN.uv_MainTex).x;
  71.             o.Smoothness = m.a;
  72.             o.Normal = normalize(UnpackScaleNormal(tex2D(_BumpMap, IN.uv_MainTex), _BumpScale));
  73.             o.Alpha = c.a;
  74.         }
  75.         ENDCG
  76.     }
  77.     FallBack "Diffuse"
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement