Advertisement
tonynogo

Demo 23 - Wireframe like

Jul 6th, 2017
11,331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/WireFrame" {
  2.     Properties {
  3.         _LineColor ("LineColor", Color) = (1, 1, 1, 1)
  4.         _MainColor ("_MainColor", Color) = (1, 1, 1, 1)
  5.         _LineWidth ("Line width", Range(0, 1)) = 0.1
  6.         _ParcelSize ("ParcelSize", Range(0, 100)) = 1
  7.     }
  8.     SubShader {
  9.         Tags { "Queue"="Transparent" "RenderType"="Transparent" }
  10.        
  11.         CGPROGRAM
  12.         #pragma surface surf Lambert alpha
  13.  
  14.         sampler2D _MainTex;
  15.         float4 _LineColor;
  16.         float4 _MainColor;
  17.         fixed _LineWidth;
  18.         float _ParcelSize;
  19.  
  20.         struct Input {
  21.             float2 uv_MainTex;
  22.             float3 worldPos;
  23.         };
  24.  
  25.         void surf (Input IN, inout SurfaceOutput o) {
  26.             half val1 = step(_LineWidth * 2, frac(IN.worldPos.x / _ParcelSize) + _LineWidth);
  27.             half val2 = step(_LineWidth * 2, frac(IN.worldPos.z / _ParcelSize) + _LineWidth);
  28.             fixed val = 1 - (val1 * val2);
  29.             o.Albedo = lerp(_MainColor, _LineColor, val);
  30.             o.Alpha = 1;
  31.         }
  32.         ENDCG
  33.     }
  34.     FallBack "Diffuse"
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement