Vegetation.shader 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. Shader "Custom/Vegetation" {
  2. Properties {
  3. _Color ("Color", Color) = (1,1,1,1)
  4. _MainTex ("Albedo (RGB)", 2D) = "white" {}
  5. _BumpMap ("Normal", 2D)= "bump" {}
  6. _OcclusionMap ("Occlusion", 2D) = "white" {}
  7. _OcclusionStrength ("Occlusion Strength", Range(0,1)) = 0.0
  8. _MetallicGlossMap ("Metaillic Smoothness (R/A)", 2D) = "white" {}
  9. _EmissionMap ("Emissive", 2D) = "white" {}
  10. [hdr]_EmissiveColor ("Emissive Color", Color) = (0,0,0,0)
  11. _Glossiness ("Smoothness", Range(0,1)) = 0.5
  12. _Metallic ("Metallic", Range(0,1)) = 0.0
  13. }
  14. SubShader {
  15. Tags { "RenderType"="TransparentCutout" "Queue"="AlphaTest" }
  16. LOD 200
  17. CGPROGRAM
  18. #pragma multi_compile _ LOD_FADE_CROSSFADE
  19. // Physically based Standard lighting model, and enable shadows on all light types
  20. #pragma surface surf Standard fullforwardshadows vertex:vert
  21. // Use shader model 3.0 target, to get nicer looking lighting
  22. #pragma target 3.0
  23. sampler2D _MainTex, _OcclusionMap, _BumpMap, _MetallicGlossMap, _EmissionMap;
  24. struct Input {
  25. float2 uv_MainTex;
  26. float4 screenPos;
  27. };
  28. half _Glossiness, _Metallic, _OcclusionStrength;
  29. fixed4 _Color, _EmissiveColor;
  30. void vert (inout appdata_full v, out Input o) {
  31. UNITY_INITIALIZE_OUTPUT(Input,o);
  32. //float3 worldPos = mul (unity_ObjectToWorld, v.vertex).xyz;
  33. //float vLength = length(v.vertex);
  34. //v.vertex.x += sin(_Time * 5) * 0.2 * vLength;
  35. }
  36. // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
  37. // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
  38. // #pragma instancing_options assumeuniformscaling
  39. UNITY_INSTANCING_BUFFER_START(Props)
  40. // put more per-instance properties here
  41. UNITY_INSTANCING_BUFFER_END(Props)
  42. void surf (Input IN, inout SurfaceOutputStandard o) {
  43. #ifdef LOD_FADE_CROSSFADE
  44. float2 vpos = IN.screenPos.xy / IN.screenPos.w * _ScreenParams.xy;
  45. UnityApplyDitherCrossFade(vpos);
  46. #endif
  47. fixed4 ms = tex2D (_MetallicGlossMap, IN.uv_MainTex);
  48. o.Albedo = tex2D (_MainTex, IN.uv_MainTex) * _Color;
  49. o.Normal = UnpackNormal(tex2D (_BumpMap, IN.uv_MainTex));
  50. o.Metallic = ms.r * _Metallic;
  51. o.Smoothness = ms.a * _Glossiness;
  52. o.Occlusion = LerpOneTo (tex2D (_OcclusionMap, IN.uv_MainTex), _OcclusionStrength);
  53. o.Emission = tex2D (_EmissionMap, IN.uv_MainTex) * _EmissiveColor;
  54. //o.Alpha = c.a;
  55. }
  56. ENDCG
  57. }
  58. FallBack "Diffuse"
  59. }