Advertisement
Guest User

Unity terrain billboard shader with no highlights

a guest
Oct 22nd, 2012
2,099
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. Shader "Hidden/TerrainEngine/BillboardTree" {
  2. Properties {
  3. _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
  4. }
  5.  
  6. SubShader {
  7. Tags { "Queue" = "Transparent-100" "IgnoreProjector"="True" "RenderType"="TreeBillboard" }
  8.  
  9. Pass {
  10. ColorMask rgb
  11. Blend SrcAlpha OneMinusSrcAlpha
  12. AlphaTest Greater 0.9
  13. ZWrite Off Cull Off
  14.  
  15. CGPROGRAM
  16. #pragma vertex vert
  17. #include "UnityCG.cginc"
  18. #include "TerrainEngine.cginc"
  19. #pragma fragment frag
  20.  
  21. struct v2f {
  22. float4 pos : POSITION;
  23. fixed4 color : COLOR0;
  24. float2 uv : TEXCOORD0;
  25. };
  26.  
  27. v2f vert (appdata_tree_billboard v) {
  28. v2f o;
  29. TerrainBillboardTree(v.vertex, v.texcoord1.xy, v.texcoord.y);
  30. o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
  31. o.uv.x = v.texcoord.x;
  32. o.uv.y = v.texcoord.y > 0;
  33. o.color = v.color;
  34. return o;
  35. }
  36.  
  37. sampler2D _MainTex;
  38. fixed4 frag(v2f input) : COLOR
  39. {
  40. fixed4 col = tex2D( _MainTex, input.uv);
  41. col.rgb *= input.color.rgb;
  42. clip(col.a);
  43. return col;
  44. }
  45. ENDCG
  46. }
  47. }
  48.  
  49. SubShader {
  50. Tags { "Queue" = "Transparent-100" "IgnoreProjector"="True" "RenderType"="TreeBillboard" }
  51.  
  52. Pass {
  53.  
  54. CGPROGRAM
  55. #pragma vertex vert
  56. #pragma exclude_renderers shaderonly
  57. #include "UnityCG.cginc"
  58. #include "TerrainEngine.cginc"
  59.  
  60. struct v2f {
  61. float4 pos : POSITION;
  62. fixed4 color : COLOR0;
  63. float2 uv : TEXCOORD0;
  64. };
  65.  
  66. v2f vert (appdata_tree_billboard v) {
  67. v2f o;
  68. TerrainBillboardTree(v.vertex, v.texcoord1.xy, v.texcoord.y);
  69. o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
  70. o.uv.x = v.texcoord.x;
  71. o.uv.y = v.texcoord.y > 0;
  72. o.color = v.color;
  73. return o;
  74. }
  75. ENDCG
  76.  
  77. ColorMask rgb
  78. Blend SrcAlpha OneMinusSrcAlpha
  79.  
  80. ZWrite Off Cull Off
  81.  
  82. AlphaTest Greater 0.9
  83. SetTexture [_MainTex] { combine texture * primary, texture }
  84. }
  85. }
  86.  
  87. Fallback Off
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement