Advertisement
KpoKec

Untitled

May 22nd, 2019
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/Debug Grid" {
  2.     Properties
  3.     {
  4.         _Color("Color", Color) = (1,1,1,1)
  5.         [NoScaleOffset]_MainTex("Main texture", 2D) = "white" {}
  6.          _Repeatance("Repeatance",float) = 1.0
  7.     }
  8.  
  9.     SubShader {
  10.         Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
  11.        
  12.         CGPROGRAM
  13.         #pragma surface surf Standard vertex:vert
  14.         #pragma target 3.0
  15.  
  16.         sampler2D _MainTex;
  17.          struct vertexInput {
  18.             float4 vertex : POSITION;
  19.             float3 normal : NORMAL;
  20.             float4 tangent : TANGENT;
  21.  
  22.          };
  23.  
  24.         struct Input {
  25.             float3 worldPos;
  26.             float4 vert;  
  27.             float3 normal;
  28.         };
  29.  
  30.         half _Repeatance;
  31.         fixed4 _Color;
  32.  
  33.         void vert (inout vertexInput v, out Input o) {
  34.           o.worldPos= mul(unity_ObjectToWorld,v.vertex).xyz;
  35.           o.vert = v.vertex;
  36.           o.normal = v.normal;
  37.         }
  38.      
  39.         void surf (Input IN, inout SurfaceOutputStandard o) {
  40.             float2 uv = (IN.worldPos.xz * IN.normal.y + IN.worldPos.xy * IN.normal.z + IN.worldPos.yz * IN.normal.x) * _Repeatance;
  41.             fixed4 c = tex2D (_MainTex, uv) * _Color;
  42.             o.Albedo = c.rgb;  
  43.             o.Alpha = _Color.a;                      
  44.         }
  45.         ENDCG
  46.     }
  47.     FallBack "Diffuse"
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement