T4M 3 Textures.shader 1.5 KB

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