2TexturesUnlit.shader 1.9 KB

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