Diffuse-NoFog.shader 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. Shader "MTE/Standard/5 Textures/Diffuse/NoFog"
  2. {
  3. Properties
  4. {
  5. _Control ("Control (RGBA)", 2D) = "red" {}
  6. _ControlExtra ("Control Extra (R)", 2D) = "black" {}
  7. _Splat0 ("Layer 1", 2D) = "white" {}
  8. _Splat1 ("Layer 2", 2D) = "white" {}
  9. _Splat2 ("Layer 3", 2D) = "white" {}
  10. _Splat3 ("Layer 4", 2D) = "white" {}
  11. _Splat4 ("Layer 5", 2D) = "white" {}
  12. [Gamma] _Metallic0("Metallic 0", Range(0.0, 1.0)) = 0.0
  13. [Gamma] _Metallic1("Metallic 1", Range(0.0, 1.0)) = 0.0
  14. [Gamma] _Metallic2("Metallic 2", Range(0.0, 1.0)) = 0.0
  15. [Gamma] _Metallic3("Metallic 3", Range(0.0, 1.0)) = 0.0
  16. [Gamma] _Metallic4("Metallic 4", Range(0.0, 1.0)) = 0.0
  17. _Smoothness0("Smoothness 0", Range(0.0, 1.0)) = 1.0
  18. _Smoothness1("Smoothness 1", Range(0.0, 1.0)) = 1.0
  19. _Smoothness2("Smoothness 2", Range(0.0, 1.0)) = 1.0
  20. _Smoothness3("Smoothness 3", Range(0.0, 1.0)) = 1.0
  21. _Smoothness4("Smoothness 4", Range(0.0, 1.0)) = 1.0
  22. }
  23. CGINCLUDE
  24. #pragma surface surf Standard vertex:MTE_SplatmapVert finalcolor:MTE_SplatmapFinalColor finalprepass:MTE_SplatmapFinalPrepass finalgbuffer:MTE_SplatmapFinalGBuffer
  25. struct Input
  26. {
  27. float2 tc_Control : TEXCOORD0;
  28. float4 tc_Splat01 : TEXCOORD1;
  29. float4 tc_Splat23 : TEXCOORD2;
  30. float2 tc_Splat4 : TEXCOORD3;
  31. };
  32. sampler2D _Control,_ControlExtra;
  33. float4 _Control_ST,_ControlExtra_ST;
  34. sampler2D _Splat0,_Splat1,_Splat2,_Splat3,_Splat4;
  35. float4 _Splat0_ST,_Splat1_ST,_Splat2_ST,_Splat3_ST,_Splat4_ST;
  36. #define MTE_STANDARD_SHADER
  37. #include "UnityPBSLighting.cginc"
  38. #include "../../MTECommon.hlsl"
  39. half _Metallic0;
  40. half _Metallic1;
  41. half _Metallic2;
  42. half _Metallic3;
  43. half _Metallic4;
  44. half _Smoothness0;
  45. half _Smoothness1;
  46. half _Smoothness2;
  47. half _Smoothness3;
  48. half _Smoothness4;
  49. void MTE_SplatmapVert(inout appdata_full v, out Input data)
  50. {
  51. UNITY_INITIALIZE_OUTPUT(Input, data);
  52. data.tc_Control.xy = TRANSFORM_TEX(v.texcoord, _Control);
  53. data.tc_Splat01.xy = TRANSFORM_TEX(v.texcoord, _Splat0);
  54. data.tc_Splat01.zw = TRANSFORM_TEX(v.texcoord, _Splat1);
  55. data.tc_Splat23.xy = TRANSFORM_TEX(v.texcoord, _Splat2);
  56. data.tc_Splat23.zw = TRANSFORM_TEX(v.texcoord, _Splat3);
  57. data.tc_Splat4.xy = TRANSFORM_TEX(v.texcoord, _Splat4);
  58. float4 pos = UnityObjectToClipPos(v.vertex);
  59. }
  60. void MTE_SplatmapMix(Input IN, half smoothness[5], out half4 splat_control, out half4 splat_control_extra, out half weight, out fixed4 mixedDiffuse)
  61. {
  62. splat_control = tex2D(_Control, IN.tc_Control.xy);
  63. splat_control_extra = tex2D(_ControlExtra, IN.tc_Control.xy);
  64. weight = dot(splat_control, half4(1, 1, 1, 1));
  65. weight += dot(splat_control_extra.r, half(1));
  66. splat_control /= (weight + 1e-3f);
  67. splat_control_extra /= (weight + 1e-3f);
  68. mixedDiffuse = 0;
  69. mixedDiffuse += splat_control.r * tex2D(_Splat0, IN.tc_Splat01.xy) * half4(1.0, 1.0, 1.0, smoothness[0]);
  70. mixedDiffuse += splat_control.g * tex2D(_Splat1, IN.tc_Splat01.zw) * half4(1.0, 1.0, 1.0, smoothness[1]);
  71. mixedDiffuse += splat_control.b * tex2D(_Splat2, IN.tc_Splat23.xy) * half4(1.0, 1.0, 1.0, smoothness[2]);
  72. mixedDiffuse += splat_control.a * tex2D(_Splat3, IN.tc_Splat23.zw) * half4(1.0, 1.0, 1.0, smoothness[3]);
  73. mixedDiffuse += splat_control_extra.r * tex2D(_Splat4, IN.tc_Splat4) * half4(1.0, 1.0, 1.0, smoothness[4]);
  74. }
  75. void surf(Input IN, inout SurfaceOutputStandard o)
  76. {
  77. half4 splat_control, splat_control_extra;
  78. fixed4 mixedDiffuse;
  79. half weight;
  80. half smoothness[5]={_Smoothness0, _Smoothness1, _Smoothness2, _Smoothness3, _Smoothness4};
  81. MTE_SplatmapMix(IN, smoothness, splat_control, splat_control_extra, weight, mixedDiffuse);
  82. o.Albedo = mixedDiffuse.rgb;
  83. o.Alpha = weight;
  84. o.Smoothness = mixedDiffuse.a;
  85. o.Metallic = dot(splat_control, half4(_Metallic0, _Metallic1, _Metallic2, _Metallic3))
  86. + dot(splat_control_extra.r, half(_Metallic4));
  87. }
  88. ENDCG
  89. Category
  90. {
  91. Tags
  92. {
  93. "Queue" = "Geometry-99"
  94. "RenderType" = "Opaque"
  95. }
  96. SubShader//for target 3.0+
  97. {
  98. CGPROGRAM
  99. #pragma target 3.0
  100. ENDCG
  101. }
  102. SubShader//for target 2.0
  103. {
  104. CGPROGRAM
  105. ENDCG
  106. }
  107. }
  108. Fallback "Diffuse"
  109. CustomEditor "MTE.MTEShaderGUI"
  110. }