T4M 4 Textures.shader 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. Shader "T4MShaders/ShaderModel3/Diffuse/T4M 4 Textures"
  2. {
  3. Properties {
  4. _Splat0 ("Layer 1 (R)", 2D) = "white" {}
  5. _Splat1 ("Layer 2 (G)", 2D) = "white" {}
  6. _Splat2 ("Layer 3 (B)", 2D) = "white" {}
  7. _Splat3 ("Layer 4 (A)", 2D) = "white" {}
  8. _Control ("Control (RGBA)", 2D) = "white" {}
  9. _MainTex ("Never Used", 2D) = "white" {}
  10. }
  11. SubShader
  12. {
  13. Tags {
  14. "SplatCount" = "4"
  15. "Queue" = "Geometry-100"
  16. "RenderType" = "Opaque"
  17. }
  18. CGPROGRAM
  19. #pragma surface surf Lambert vertex:vert
  20. #pragma target 4.0
  21. #pragma exclude_renderers gles xbox360 ps3
  22. #include "UnityCG.cginc"
  23. struct Input {
  24. float3 worldPos;
  25. float2 uv_Control : TEXCOORD0;
  26. float2 uv_Splat0 : TEXCOORD1;
  27. float2 uv_Splat1 : TEXCOORD2;
  28. float2 uv_Splat2 : TEXCOORD3;
  29. float2 uv_Splat3 : TEXCOORD4;
  30. };
  31. void vert (inout appdata_full v)
  32. {
  33. float3 T1 = float3(1, 0, 1);
  34. float3 Bi = cross(T1, v.normal);
  35. float3 newTangent = cross(v.normal, Bi);
  36. normalize(newTangent);
  37. v.tangent.xyz = newTangent.xyz;
  38. if (dot(cross(v.normal,newTangent),Bi) < 0)
  39. v.tangent.w = -1.0f;
  40. else
  41. v.tangent.w = 1.0f;
  42. }
  43. sampler2D _Control;
  44. sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
  45. void surf (Input IN, inout SurfaceOutput o)
  46. {
  47. half4 splat_control = tex2D (_Control, IN.uv_Control);
  48. half4 splat0 = tex2D (_Splat0, IN.uv_Splat0);
  49. half4 splat1 = tex2D (_Splat1, IN.uv_Splat1);
  50. half4 splat2 = tex2D (_Splat2, IN.uv_Splat2);
  51. half4 splat3 = tex2D (_Splat3, IN.uv_Splat3);
  52. half3 col = splat_control.r * splat0.rgb;
  53. col += splat_control.g * splat1.rgb;
  54. col += splat_control.b * splat2.rgb;
  55. col += splat_control.a * splat3.rgb;
  56. o.Albedo = col;
  57. o.Alpha = 0.0;
  58. }
  59. ENDCG
  60. }
  61. //FallBack "Diffuse"
  62. }