T4M 2 TexturesBumpSpec.shader 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. Shader "T4MShaders/ShaderModel3/BumpSpec/T4M 2 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. _BumpSplat0 ("Layer1Normalmap", 2D) = "bump" {}
  9. _BumpSplat1 ("Layer2Normalmap", 2D) = "bump" {}
  10. _Control ("Control (RGBA)", 2D) = "white" {}
  11. _MainTex ("Never Used", 2D) = "white" {}
  12. }
  13. SubShader {
  14. Tags {
  15. "SplatCount" = "2"
  16. "Queue" = "Geometry-100"
  17. "RenderType" = "Opaque"
  18. }
  19. CGPROGRAM
  20. #pragma surface surf BlinnPhong vertex:vert
  21. #pragma target 3.0
  22. #pragma exclude_renderers gles xbox360 ps3
  23. #include "UnityCG.cginc"
  24. struct Input {
  25. float3 worldPos;
  26. float2 uv_Control : TEXCOORD0;
  27. float2 uv_Splat0 : TEXCOORD1;
  28. float2 uv_Splat1 : TEXCOORD2;
  29. };
  30. void vert (inout appdata_full v) {
  31. float3 T1 = float3(1, 0, 1);
  32. float3 Bi = cross(T1, v.normal);
  33. float3 newTangent = cross(v.normal, Bi);
  34. normalize(newTangent);
  35. v.tangent.xyz = newTangent.xyz;
  36. if (dot(cross(v.normal,newTangent),Bi) < 0)
  37. v.tangent.w = -1.0f;
  38. else
  39. v.tangent.w = 1.0f;
  40. }
  41. sampler2D _Control;
  42. sampler2D _BumpSplat0, _BumpSplat1;
  43. sampler2D _Splat0,_Splat1;
  44. fixed _ShininessL0;
  45. fixed _ShininessL1;
  46. void surf (Input IN, inout SurfaceOutput o) {
  47. half2 splat_control = tex2D (_Control, IN.uv_Control);
  48. half3 col;
  49. half4 splat0 = tex2D (_Splat0, IN.uv_Splat0);
  50. half4 splat1 = tex2D (_Splat1, IN.uv_Splat1);
  51. col = splat_control.r * splat0.rgb;
  52. o.Normal = splat_control.r * UnpackNormal(tex2D(_BumpSplat0, IN.uv_Splat0));
  53. o.Gloss = splat0.a * splat_control.r ;
  54. o.Specular = _ShininessL0 * splat_control.r;
  55. col += splat_control.g * splat1.rgb;
  56. o.Normal += splat_control.g * UnpackNormal(tex2D(_BumpSplat1, IN.uv_Splat1));
  57. o.Gloss += splat1.a * splat_control.g;
  58. o.Specular += _ShininessL1 * splat_control.g;
  59. o.Albedo = col;
  60. o.Alpha = 0.0;
  61. }
  62. ENDCG
  63. }
  64. //FallBack "Specular"
  65. }