源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

91 行
2.0 KiB

  1. Shader "SuYou/CustomTerrain"
  2. {
  3. Properties
  4. {
  5. _Splat0 ("Layer 1", 2D) = "white" {}
  6. _Splat1 ("Layer 2", 2D) = "white" {}
  7. _Splat2 ("Layer 3", 2D) = "white" {}
  8. _Splat3 ("Layer 4", 2D) = "white" {}
  9. _Control ("Control (RGBA)", 2D) = "white" {}
  10. }
  11. CGINCLUDE
  12. sampler2D _Splat0, _Splat1, _Splat2, _Splat3, _Control;
  13. ENDCG
  14. SubShader {
  15. Tags { "SplatCount" = "4" "RenderType" = "Opaque" }
  16. Pass {
  17. CGPROGRAM
  18. #pragma vertex vert
  19. #pragma fragment frag
  20. #pragma multi_compile_fog
  21. #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  22. #include "UnityCG.cginc"
  23. struct appdata_t
  24. {
  25. float4 vertex : POSITION;
  26. float2 texcoord : TEXCOORD0;
  27. float2 texcoord1 : TEXCOORD1;
  28. };
  29. struct v2f
  30. {
  31. half4 pos : SV_POSITION;
  32. half2 uv_Control : TEXCOORD0;
  33. half4 uv_Splat0 : TEXCOORD1;
  34. half4 uv_Splat1 : TEXCOORD2;
  35. #ifdef LIGHTMAP_ON
  36. half2 lmuv : TEXCOORD3;
  37. #endif
  38. UNITY_FOG_COORDS(4)
  39. };
  40. half4 _Splat0_ST, _Splat1_ST, _Splat2_ST, _Splat3_ST;
  41. v2f vert (appdata_t v)
  42. {
  43. v2f o;
  44. o.pos = UnityObjectToClipPos (v.vertex);
  45. o.uv_Control = v.texcoord;
  46. o.uv_Splat0.xy = TRANSFORM_TEX(v.texcoord, _Splat0);
  47. o.uv_Splat0.zw = TRANSFORM_TEX(v.texcoord, _Splat1);
  48. o.uv_Splat1.xy = TRANSFORM_TEX(v.texcoord, _Splat2);
  49. o.uv_Splat1.zw = TRANSFORM_TEX(v.texcoord, _Splat3);
  50. #ifdef LIGHTMAP_ON
  51. o.lmuv = v.texcoord1 * unity_LightmapST.xy + unity_LightmapST.zw;
  52. #endif
  53. UNITY_TRANSFER_FOG(o,o.pos);
  54. return o;
  55. }
  56. fixed4 frag (v2f i) : COLOR0
  57. {
  58. fixed4 splat_control = tex2D (_Control, i.uv_Control).rgba;
  59. fixed3 lay1 = tex2D (_Splat0, i.uv_Splat0.xy);
  60. fixed3 lay2 = tex2D (_Splat1, i.uv_Splat0.zw);
  61. fixed3 lay3 = tex2D (_Splat2, i.uv_Splat1.xy);
  62. fixed3 lay4 = tex2D (_Splat3, i.uv_Splat1.zw);
  63. fixed4 resultColor;
  64. resultColor.rgb = (lay1 * splat_control.r + lay2 * splat_control.g + lay3 * splat_control.b + lay4 * splat_control.a);
  65. #ifdef LIGHTMAP_ON
  66. fixed3 lm = DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap,i.lmuv));
  67. resultColor.rgb *= lm;
  68. #endif
  69. UNITY_APPLY_FOG(i.fogCoord, resultColor);
  70. return resultColor;
  71. }
  72. ENDCG
  73. }
  74. }
  75. Fallback Off
  76. }