Advertisement
tonynogo

Demo 08 - Circle on terrain

Jul 6th, 2017
8,180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/CircleOnTerrain" {
  2.     Properties {
  3.         _MainTex ("Base (RGB)", 2D) = "white" {}
  4.         _AreaColor ("Area Color", Color) = (1, 1, 1)
  5.         _Center ("Center", Vector) = (0,0,0,0)
  6.         _Radius ("Radius", Range(0, 500)) = 20
  7.         _Border ("Border", Range(0, 100)) = 5
  8.     }
  9.     SubShader {
  10.         Tags { "RenderType"="Opaque" }
  11.        
  12.         CGPROGRAM
  13.         #pragma surface surf Lambert
  14.  
  15.         sampler2D _MainTex;
  16.         fixed3 _AreaColor;
  17.         float3 _Center;
  18.         float _Border;
  19.         float _Radius;
  20.  
  21.         struct Input {
  22.             float2 uv_MainTex;
  23.             float3 worldPos;
  24.         };
  25.  
  26.         void surf (Input IN, inout SurfaceOutput o) {
  27.             half4 c = tex2D (_MainTex, IN.uv_MainTex);
  28.             float dist = distance(_Center, IN.worldPos);
  29.  
  30.             if(dist > _Radius && dist < (_Radius + _Border))
  31.                 o.Albedo = _AreaColor;
  32.             else
  33.                 o.Albedo = c.rgb;
  34.  
  35.             o.Alpha = c.a;
  36.         }
  37.         ENDCG
  38.     }
  39.     FallBack "Diffuse"
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement