T4M 2 TexturesBump.shader 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. Shader "T4MShaders/ShaderModel3/Bump/T4M 2 Textures Bump" {
  2. Properties {
  3. _Splat0 ("Layer 1 (R)", 2D) = "white" {}
  4. _Splat1 ("Layer 2 (G)", 2D) = "white" {}
  5. _BumpSplat0 ("Layer1Normalmap", 2D) = "bump" {}
  6. _BumpSplat1 ("Layer2Normalmap", 2D) = "bump" {}
  7. _Control ("Control (RGBA)", 2D) = "white" {}
  8. _MainTex ("Never Used", 2D) = "white" {}
  9. }
  10. SubShader {
  11. Tags {
  12. "SplatCount" = "2"
  13. "Queue" = "Geometry-100"
  14. "RenderType" = "Opaque"
  15. }
  16. CGPROGRAM
  17. #pragma surface surf Lambert vertex:vert
  18. #pragma target 3.0
  19. #pragma exclude_renderers gles xbox360 ps3
  20. #include "UnityCG.cginc"
  21. struct Input {
  22. float3 worldPos;
  23. float2 uv_Control : TEXCOORD0;
  24. float2 uv_Splat0 : TEXCOORD1;
  25. float2 uv_Splat1 : TEXCOORD2;
  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 _BumpSplat0, _BumpSplat1;
  40. sampler2D _Splat0,_Splat1;
  41. void surf (Input IN, inout SurfaceOutput o) {
  42. half2 splat_control = tex2D (_Control, IN.uv_Control);
  43. half3 col;
  44. half3 splat0 = tex2D (_Splat0, IN.uv_Splat0);
  45. half3 splat1 = tex2D (_Splat1, IN.uv_Splat1);
  46. col = splat_control.r * splat0.rgb;
  47. o.Normal = splat_control.r * UnpackNormal(tex2D(_BumpSplat0, IN.uv_Splat0));
  48. col += splat_control.g * splat1.rgb;
  49. o.Normal += splat_control.g * UnpackNormal(tex2D(_BumpSplat1, IN.uv_Splat1));
  50. o.Albedo = col;
  51. o.Alpha = 0.0;
  52. }
  53. ENDCG
  54. }
  55. //FallBack "Diffuse"
  56. }