1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- Shader "Custom/Tree_leavf"
- {
- Properties
- {
- _Color ("Color", Color) = (1,1,1,1)
- _MainTex ("Albedo (RGB)", 2D) = "white" {}
- _MaskTex("MaskTex",2D) = "white" {}
- _BumpMap("Normal",2D)= "bump" {}
- _AlphaCut("CutOff",Range(0,1)) = 0.5
- _Glossiness ("Smoothness", Range(0,1)) = 0.5
- _Metallic ("Metallic", Range(0,1)) = 0.0
- _OccColor ("OccColor", Color) = (1,1,1,1)
- _NoisTex("NoisTex",2D)="white" {}
- _TreeCol1("TreeCol1",Color) = (1,1,1,1)
- _TreeCol2("TreeCol2",Color) = (1,1,1,1)
- }
- SubShader
- {
- Cull Off
- Tags { "RenderType"="Opaque" }
- LOD 200
- CGPROGRAM
- fixed _AlphaCut;
- // Physically based Standard lighting model, and enable shadows on all light types
- #pragma surface surf Standard addshadow
- // Use shader model 3.0 target, to get nicer looking lighting
- #pragma target 3.0
- sampler2D _MainTex,_BumpMap,_MaskTex,_NoisTex;
- float4 _NoisTex_ST;
- struct Input
- {
- float2 uv_MainTex;
- float2 uv_BumpMap;
- float2 uv_MaskTex;
- fixed face : VFACE;
- float2 uv2 : TEXCOORD1;
- float3 worldPos;
- float3 vertexColor:COLOR;
- };
- half _Glossiness;
- half _Metallic;
- fixed4 _Color,_OccColor,_TreeCol1,_TreeCol2;
- // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
- // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
- // #pragma instancing_options assumeuniformscaling
- UNITY_INSTANCING_BUFFER_START(Props)
- //UNITY_DEFINE_INSTANCED_PROP(float4, _WorldPointPos)
- UNITY_INSTANCING_BUFFER_END(Props)
- void surf (Input IN, inout SurfaceOutputStandard o)
- {
- // Albedo comes from a texture tinted by color
- fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
- clip(c.a-_AlphaCut);
-
- //float4 point=UNITY_ACCESS_INSTANCED_PROP(Props, _WorldPointPos);
- fixed colfactor = tex2D(_NoisTex,IN.worldPos.xz*_NoisTex_ST.xy+_NoisTex_ST.zw).r;
- fixed3 worldcol = lerp(_TreeCol1.rgb,_TreeCol2.rgb,colfactor);
- // Metallic and smoothness come from slider variables
- o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
- o.Normal = IN.face?o.Normal:-o.Normal;
- fixed4 mask = tex2D (_MaskTex, IN.uv_MaskTex);
- fixed3 acc = lerp(_OccColor.rgb,fixed3(1,1,1),IN.vertexColor.g);
- fixed3 updowCol = lerp(_TreeCol1.rgb,_TreeCol2.rgb,IN.worldPos.y/30);
- o.Albedo = c.rgb*acc*_Color*worldcol*updowCol;
- //o.Albedo=colfactor;
- o.Metallic = _Metallic*mask.r;
- o.Smoothness = _Glossiness*mask.a;
- o.Alpha = c.a;
- }
- ENDCG
- }
- FallBack "Diffuse"
- }
|