1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- Shader "PlaceHolder/WorldSpaceGrid"
- {
- Properties
- {
- [Toggle] _EnableWorldSpace("Enable World Space", int) = 1
- _Color ("Color", Color) = (0.61,0.61,0.61,1)
- _MainTex ("Albedo (RGB)", 2D) = "white" {}
- _Scale("Scale", float) = 1.0
- _Glossiness ("Smoothness", Range(0,1)) = 0.5
- _Metallic ("Metallic", Range(0,1)) = 0.0
- }
- SubShader
- {
- Tags { "RenderType"="Opaque" }
- LOD 200
- CGPROGRAM
-
- #pragma surface surf Standard fullforwardshadows
-
- #pragma target 3.0
- sampler2D _MainTex;
- struct Input
- {
- float4 color : COLOR;
- float2 uv_MainTex;
- float3 worldPos;
- float3 worldNormal;
- };
- half _Glossiness;
- half _Metallic;
- int _EnableWorldSpace;
- fixed4 _Color;
- half _Scale;
-
-
-
- UNITY_INSTANCING_BUFFER_START(Props)
-
- UNITY_INSTANCING_BUFFER_END(Props)
- void surf (Input IN, inout SurfaceOutputStandard o)
- {
- float2 UV;
- fixed4 c;
- if (_EnableWorldSpace == 1)
- {
- if (abs(IN.worldNormal.x) > 0.5)
- {
- UV = IN.worldPos.yz;
- c = tex2D(_MainTex, UV* _Scale);
- }
- else if (abs(IN.worldNormal.z) > 0.5)
- {
- UV = IN.worldPos.xy;
- c = tex2D(_MainTex, UV* _Scale);
- }
- else
- {
- UV = IN.worldPos.xz;
- c = tex2D(_MainTex, UV* _Scale);
- }
- o.Albedo = c.rgb * _Color;
- }
- else
- {
- fixed4 c = tex2D(_MainTex, IN.uv_MainTex*_Scale) * _Color;
- o.Albedo = c.rgb * _Color;
- }
-
- o.Metallic = _Metallic;
- o.Smoothness = _Glossiness;
- o.Alpha = c.a;
- }
- ENDCG
- }
- FallBack "Diffuse"
- }
|