Advertisement
tonynogo

Demo 29 - Soccer lawn field

Jul 6th, 2017
4,758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/SoccerLawnField" {
  2.     Properties {
  3.       _MainTex ("Texture", 2D) = "white" {}
  4.       _BumpMap ("Bumpmap", 2D) = "bump" {}
  5.       _ColorMain ("Main color", Color) = (1, 1, 1, 1)
  6.       _ColorSec ("Secondary color", Color) = (1, 1, 1, 1)
  7.       _Width ("Width", float) = 10
  8.       _Offset ("Offset", float) = 0
  9.     }
  10.  
  11.     SubShader {
  12.       Tags { "RenderType" = "Opaque" }
  13.       CGPROGRAM
  14.       #pragma surface surf Lambert vertex:vert
  15.  
  16.       struct Input {
  17.         float2 uv_MainTex;
  18.         float2 uv_BumpMap;
  19.         float3 modelPos;
  20.       };
  21.  
  22.       sampler2D _MainTex;
  23.       sampler2D _BumpMap;
  24.       fixed4 _ColorSec;
  25.       fixed4 _ColorMain;
  26.       fixed _Width;
  27.       fixed _Offset;
  28.  
  29.       void vert(inout appdata_full v, out Input o) {
  30.         UNITY_INITIALIZE_OUTPUT(Input, o);
  31.         o.modelPos = v.vertex;
  32.       }
  33.  
  34.       void surf (Input IN, inout SurfaceOutput o) {
  35.  
  36.         fixed val = ceil(frac(floor((IN.modelPos.x - _Offset) / _Width)/ 2));
  37.         fixed3 col1 = tex2D(_MainTex, IN.uv_MainTex).rgb;
  38.         o.Albedo = lerp(col1 * _ColorMain, col1 * _ColorSec, val);
  39.         o.Alpha = 1;
  40.         o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  41.       }
  42.  
  43.       ENDCG
  44.     }
  45.     Fallback "Diffuse"
  46.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement