T4M 2 Textures.shader 1.3 KB

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