T4M 3 TexturesBumpSpec.shader 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. Shader "T4MShaders/ShaderModel3/BumpSpec/T4M 3 Textures Bump Spec" {
  2. Properties {
  3. _SpecColor ("Specular Color", Color) = (1, 1, 1, 1)
  4. _ShininessL0 ("Layer1Shininess", Range (0.03, 1)) = 0.078125
  5. _Splat0 ("Layer 1 (R)", 2D) = "white" {}
  6. _ShininessL1 ("Layer2Shininess", Range (0.03, 1)) = 0.078125
  7. _Splat1 ("Layer 2 (G)", 2D) = "white" {}
  8. _ShininessL2 ("Layer3Shininess", Range (0.03, 1)) = 0.078125
  9. _Splat2 ("Layer 3 (B)", 2D) = "white" {}
  10. _BumpSplat0 ("Layer1Normalmap", 2D) = "bump" {}
  11. _BumpSplat1 ("Layer2Normalmap", 2D) = "bump" {}
  12. _BumpSplat2 ("Layer3Normalmap", 2D) = "bump" {}
  13. _Control ("Control (RGBA)", 2D) = "white" {}
  14. _MainTex ("Never Used", 2D) = "white" {}
  15. }
  16. SubShader {
  17. Tags {
  18. "SplatCount" = "3"
  19. "Queue" = "Geometry-100"
  20. "RenderType" = "Opaque"
  21. }
  22. CGPROGRAM
  23. #pragma surface surf BlinnPhong vertex:vert
  24. #pragma target 3.0
  25. #pragma exclude_renderers gles xbox360 ps3
  26. #include "UnityCG.cginc"
  27. struct Input {
  28. float3 worldPos;
  29. float2 uv_Control : TEXCOORD0;
  30. float2 uv_Splat0 : TEXCOORD1;
  31. float2 uv_Splat1 : TEXCOORD2;
  32. float2 uv_Splat2 : TEXCOORD3;
  33. };
  34. void vert (inout appdata_full v) {
  35. float3 T1 = float3(1, 0, 1);
  36. float3 Bi = cross(T1, v.normal);
  37. float3 newTangent = cross(v.normal, Bi);
  38. normalize(newTangent);
  39. v.tangent.xyz = newTangent.xyz;
  40. if (dot(cross(v.normal,newTangent),Bi) < 0)
  41. v.tangent.w = -1.0f;
  42. else
  43. v.tangent.w = 1.0f;
  44. }
  45. sampler2D _Control;
  46. sampler2D _BumpSplat0, _BumpSplat1, _BumpSplat2;
  47. sampler2D _Splat0,_Splat1,_Splat2;
  48. fixed _ShininessL0;
  49. fixed _ShininessL1;
  50. fixed _ShininessL2;
  51. void surf (Input IN, inout SurfaceOutput o) {
  52. half3 splat_control = tex2D (_Control, IN.uv_Control);
  53. half3 col;
  54. half4 splat0 = tex2D (_Splat0, IN.uv_Splat0);
  55. half4 splat1 = tex2D (_Splat1, IN.uv_Splat1);
  56. half4 splat2 = tex2D (_Splat2, IN.uv_Splat2);
  57. col = splat_control.r * splat0.rgb;
  58. o.Normal = splat_control.r * UnpackNormal(tex2D(_BumpSplat0, IN.uv_Splat0));
  59. o.Gloss = splat0.a * splat_control.r ;
  60. o.Specular = _ShininessL0 * splat_control.r;
  61. col += splat_control.g * splat1.rgb;
  62. o.Normal += splat_control.g * UnpackNormal(tex2D(_BumpSplat1, IN.uv_Splat1));
  63. o.Gloss += splat1.a * splat_control.g;
  64. o.Specular += _ShininessL1 * splat_control.g;
  65. col += splat_control.b * splat2.rgb;
  66. o.Normal += splat_control.b * UnpackNormal(tex2D(_BumpSplat2, IN.uv_Splat2));
  67. o.Gloss += splat2.a * splat_control.b;
  68. o.Specular += _ShininessL2 * splat_control.b;
  69. o.Albedo = col;
  70. o.Alpha = 0.0;
  71. }
  72. ENDCG
  73. }
  74. //FallBack "Specular"
  75. }