4TexturesUnlit.shader 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. // Upgrade NOTE: commented out 'sampler2D unity_Lightmap', a built-in variable
  3. // Upgrade NOTE: replaced tex2D unity_Lightmap with UNITY_SAMPLE_TEX2D
  4. Shader "T4MShaders/ShaderModel2/Unlit/T4M 4 Textures Unlit LM" {
  5. Properties {
  6. _Splat0 ("Layer1 (RGB)", 2D) = "white" {}
  7. _Splat1 ("Layer2 (RGB)", 2D) = "white" {}
  8. _Splat2 ("Layer3 (RGB)", 2D) = "white" {}
  9. _Splat3 ("Layer4 (RGB)", 2D) = "white" {}
  10. _Control ("Control (RGBA)", 2D) = "white" {}
  11. _MainTex ("Never Used", 2D) = "white" {}
  12. }
  13. SubShader {
  14. Pass {
  15. CGPROGRAM
  16. #include "UnityCG.cginc"
  17. #pragma vertex vert
  18. #pragma fragment frag
  19. #pragma multi_compile LIGHTMAP_ON LIGHTMAP_OFF
  20. #pragma exclude_renderers xbox360 ps3
  21. sampler2D _Splat0 ;
  22. sampler2D _Splat1 ;
  23. sampler2D _Splat2 ;
  24. sampler2D _Splat3;
  25. sampler2D _Control;
  26. struct v2f {
  27. float4 pos : SV_POSITION;
  28. #ifdef LIGHTMAP_ON
  29. float2 uv[6] : TEXCOORD0;
  30. #endif
  31. #ifdef LIGHTMAP_OFF
  32. float2 uv[5] : TEXCOORD0;
  33. #endif
  34. };
  35. float4 _Splat0_ST;
  36. float4 _Splat1_ST;
  37. float4 _Splat2_ST;
  38. float4 _Splat3_ST;
  39. float4 _Control_ST;
  40. #ifdef LIGHTMAP_ON
  41. //fixed4 unity_LightmapST;
  42. // sampler2D unity_Lightmap;
  43. #endif
  44. v2f vert (appdata_full v)
  45. {
  46. v2f o;
  47. o.pos = UnityObjectToClipPos (v.vertex);
  48. o.uv[0] = TRANSFORM_TEX (v.texcoord, _Splat0);
  49. o.uv[1] = TRANSFORM_TEX (v.texcoord, _Splat1);
  50. o.uv[2] = TRANSFORM_TEX (v.texcoord, _Splat2);
  51. o.uv[3] = TRANSFORM_TEX (v.texcoord, _Splat3);
  52. o.uv[4] = TRANSFORM_TEX (v.texcoord, _Control);
  53. #ifdef LIGHTMAP_ON
  54. o.uv[5] = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
  55. #endif
  56. return o;
  57. }
  58. fixed4 frag (v2f i) : COLOR
  59. {
  60. fixed4 Mask = tex2D( _Control, i.uv[4].xy );
  61. fixed3 lay1 = tex2D( _Splat0, i.uv[0].xy );
  62. fixed3 lay2 = tex2D( _Splat1, i.uv[1].xy );
  63. fixed3 lay3 = tex2D( _Splat2, i.uv[2].xy );
  64. fixed3 lay4 = tex2D( _Splat3, i.uv[3].xy );
  65. fixed4 c;
  66. c.xyz = (lay1.xyz * Mask.r + lay2.xyz * Mask.g + lay3.xyz * Mask.b + lay4.xyz * Mask.a);
  67. #ifdef LIGHTMAP_ON
  68. c.rgb *= DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uv[5]));
  69. #endif
  70. c.w = 0;
  71. return c;
  72. }
  73. ENDCG
  74. }
  75. }
  76. }