3TexturesUnlit.shader 2.1 KB

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