StandardAlpha.shader 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. Shader "Custom/StandardAlpha"
  2. {
  3. Properties
  4. {
  5. [NoScaleOffset]_MainTex("_MainTex", 2D) = "white" {}
  6. [HDR]_Color("_Color", Color) = (1, 1, 1, 1)
  7. _Cutoff("_Cutoff", Range(0, 1)) = 0.5
  8. [NoScaleOffset][Normal]_BumpMap("_BumpMap", 2D) = "white" {}
  9. _BumpScale("_BumpScale", Range(0, 1)) = 1
  10. [NoScaleOffset]_EmissionMap("_EmissionMap", 2D) = "white" {}
  11. [HDR]_EmissionColor("_EmissionColor", Color) = (0, 0, 0, 0)
  12. _Metallic("_Metallic", Range(0, 1)) = 0
  13. _Glossiness("_Glossiness", Range(0, 1)) = 0
  14. [NoScaleOffset]_OcclusionMap("_OcclusionMap", 2D) = "white" {}
  15. _OcclusionStrength("_OcclusionStrength", Float) = 1
  16. _Tilling("_Tilling", Vector) = (1, 1, 0, 0)
  17. _Offset("_Offset", Vector) = (0, 0, 0, 0)
  18. [KeywordEnum(Fade, Transparent)] _TRANSPARENCY("_TRANSPARENCY", Float) = 1
  19. [KeywordEnum(Standard, Specular, Roughness)] _TYPE("_TYPE", Float) = 0
  20. }
  21. SubShader
  22. {
  23. Tags { "Queue" = "Transparent" "RenderType" = "Transparent"}
  24. LOD 200
  25. CGPROGRAM
  26. #if _TRANSPARENCY_FADE
  27. #if _TYPE_STANDARD
  28. #pragma surface surf Standard fullforwardshadows alpha:fade
  29. #elif _TYPE_SPECULAR
  30. #pragma surface surf StandardSpecular fullforwardshadows alpha:fade
  31. #else
  32. #pragma surface surf Standard fullforwardshadows alpha:fade
  33. #endif
  34. #else
  35. #if _TYPE_STANDARD
  36. #pragma surface surf Standard fullforwardshadows alpha:blend
  37. #elif _TYPE_SPECULAR
  38. #pragma surface surf StandardSpecular fullforwardshadows alpha:blend
  39. #else
  40. //todo
  41. #pragma surface surf Standard fullforwardshadows alpha:blend
  42. #endif
  43. #endif
  44. #pragma target 3.0
  45. struct Input
  46. {
  47. float2 uv_MainTex;
  48. };
  49. sampler2D _MainTex;
  50. float4 _Color;
  51. float _Cutoff;
  52. sampler2D _BumpMap;
  53. float _BumpScale;
  54. sampler2D _EmissionMap;
  55. float4 _EmissionColor;
  56. float _Metallic;
  57. float _Glossiness;
  58. sampler2D _OcclusionMap;
  59. float _OcclusionStrength;
  60. float2 _Tilling;
  61. float2 _Offset;
  62. UNITY_INSTANCING_BUFFER_START(Props)
  63. UNITY_INSTANCING_BUFFER_END(Props)
  64. void surf (Input IN, inout SurfaceOutputStandard o)
  65. {
  66. float2 uv = IN.uv_MainTex + _Offset * _Tilling;
  67. fixed4 c = tex2D(_MainTex, uv) * _Color;
  68. if (c.a > _Cutoff) {
  69. discard;
  70. }
  71. o.Albedo = c.xyz;
  72. o.Metallic = _Metallic;
  73. o.Smoothness = _Glossiness;
  74. o.Occlusion = tex2D(_OcclusionMap, uv) * _OcclusionStrength;
  75. o.Normal = tex2D(_BumpMap, uv).xyz * _BumpScale;
  76. o.Emission = tex2D(_EmissionMap, uv).xyz * _EmissionColor.xyz;
  77. o.Alpha = c.a;
  78. }
  79. ENDCG
  80. }
  81. FallBack "Diffuse"
  82. }