Advertisement
tonynogo

Demo 46 - Tessellation depending distance camera

Jul 6th, 2017
3,880
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/Tessellation"
  2. {
  3.     Properties {
  4.         _Tess ("Tessellation value", Range(0, 20)) = 1
  5.         _DistMin ("Distance min", float) = 0
  6.         _DistMax ("Distance max", float) = 1
  7.     }
  8.     Subshader {
  9.        
  10.         Tags { "Queue"="Geometry" }
  11.  
  12.             CGPROGRAM
  13.             #pragma surface surf Standard vertex:vert tessellate:tess
  14.             #pragma target 4.6
  15.             #include "UnityCG.cginc"
  16.             #include "Tessellation.cginc"
  17.  
  18.             struct Input {
  19.                 float3 worldPos;
  20.             };
  21.  
  22.             float _Tess;
  23.  
  24.             float _DistMin;
  25.             float _DistMax;
  26.  
  27.             float4 tess(appdata_base v0, appdata_base v1, appdata_base v2)
  28.             {
  29.                 return UnityDistanceBasedTess(v0.vertex, v1.vertex, v2.vertex, _DistMin, _DistMax, _Tess);
  30.             }
  31.  
  32.             void vert(inout appdata_base v ){}
  33.  
  34.             void surf(Input IN, inout SurfaceOutputStandard o)
  35.             {
  36.                 o.Albedo = fixed4(1, 1, 1, 1);
  37.             }
  38.  
  39.             ENDCG
  40.     }  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement