Advertisement
Wolfos

Unity tessellation tiling

Dec 27th, 2013
9,451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.66 KB | None | 0 0
  1.     Shader "Tessellation/Bumped Specular (displacement)" {
  2. Properties {
  3.     _Color ("Main Color", Color) = (1,1,1,1)
  4.     _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
  5.     _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
  6.     _Parallax ("Height", Range (0.0, 1.0)) = 0.5
  7.     _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
  8.     _BumpMap ("Normalmap", 2D) = "bump" {}
  9.     _ParallaxMap ("Heightmap (A)", 2D) = "black" {}
  10.  
  11.     _EdgeLength ("Edge length", Range(3,50)) = 10
  12. }
  13. SubShader {
  14.     Tags { "RenderType"="Opaque" }
  15.     LOD 800
  16.    
  17. CGPROGRAM
  18. #pragma surface surf BlinnPhong addshadow vertex:disp tessellate:tessEdge
  19. #include "Tessellation.cginc"
  20.  
  21. struct appdata {
  22.     float4 vertex : POSITION;
  23.     float4 tangent : TANGENT;
  24.     float3 normal : NORMAL;
  25.     float2 texcoord : TEXCOORD0;
  26.     float2 texcoord1 : TEXCOORD1;
  27. };
  28.  
  29. float _EdgeLength;
  30. float _Parallax;
  31.  
  32. float4 tessEdge (appdata v0, appdata v1, appdata v2)
  33. {
  34.     return UnityEdgeLengthBasedTessCull (v0.vertex, v1.vertex, v2.vertex, _EdgeLength, _Parallax * 1.5f);
  35. }
  36.  
  37. sampler2D _ParallaxMap;
  38. float4 _ParallaxMap_ST;
  39.  
  40. void disp (inout appdata v)
  41. {
  42.     float d = tex2Dlod(_ParallaxMap, float4(v.texcoord.xy * _ParallaxMap_ST,0,0)).a * _Parallax;
  43.     v.vertex.xyz += v.normal * d;
  44. }
  45.  
  46. sampler2D _MainTex;
  47. sampler2D _BumpMap;
  48. fixed4 _Color;
  49. half _Shininess;
  50.  
  51. struct Input {
  52.     float2 uv_MainTex;
  53.     float2 uv_BumpMap;
  54. };
  55.  
  56. void surf (Input IN, inout SurfaceOutput o) {
  57.     fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
  58.     o.Albedo = tex.rgb * _Color.rgb;
  59.     o.Gloss = tex.a;
  60.     o.Alpha = tex.a * _Color.a;
  61.     o.Specular = _Shininess;
  62.     o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  63. }
  64. ENDCG
  65. }
  66.  
  67. FallBack "Bumped Specular"
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement