T4M 4 Textures Spec.shader 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Shader "T4MShaders/ShaderModel2/Specular/T4M 4 Textures 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", 2D) = "white" {}
  6. _ShininessL1 ("Layer2Shininess", Range (0.03, 1)) = 0.078125
  7. _Splat1 ("Layer 2", 2D) = "white" {}
  8. _ShininessL2 ("Layer3Shininess", Range (0.03, 1)) = 0.078125
  9. _Splat2 ("Layer 3", 2D) = "white" {}
  10. _ShininessL3 ("Layer4Shininess", Range (0.03, 1)) = 0.078125
  11. _Splat3 ("Layer 4", 2D) = "white" {}
  12. _Control ("Control (RGBA)", 2D) = "white" {}
  13. _MainTex ("Never Used", 2D) = "white" {}
  14. }
  15. SubShader {
  16. Tags {
  17. "SplatCount" = "4"
  18. "RenderType" = "Opaque"
  19. }
  20. CGPROGRAM
  21. #pragma surface surf T4MBlinnPhong
  22. #pragma exclude_renderers xbox360 ps3
  23. inline fixed4 LightingT4MBlinnPhong (SurfaceOutput s, fixed3 lightDir, fixed3 halfDir, fixed atten)
  24. {
  25. fixed diff = max (0, dot (s.Normal, lightDir));
  26. fixed nh = max (0, dot (s.Normal, halfDir));
  27. fixed spec = pow (nh, s.Specular*128) * s.Gloss;
  28. fixed4 c;
  29. c.rgb = (s.Albedo * _LightColor0.rgb * diff + _SpecColor.rgb * spec) * (atten*2);
  30. c.a = 0.0;
  31. return c;
  32. }
  33. struct Input {
  34. float2 uv_Control : TEXCOORD0;
  35. float2 uv_Splat0 : TEXCOORD1;
  36. float2 uv_Splat1 : TEXCOORD2;
  37. float2 uv_Splat2 : TEXCOORD3;
  38. float2 uv_Splat3 : TEXCOORD4;
  39. };
  40. sampler2D _Control;
  41. sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
  42. fixed _ShininessL0;
  43. fixed _ShininessL1;
  44. fixed _ShininessL2;
  45. fixed _ShininessL3;
  46. void surf (Input IN, inout SurfaceOutput o) {
  47. fixed4 splat_control = tex2D (_Control, IN.uv_Control).rgba;
  48. fixed4 lay1 = tex2D (_Splat0, IN.uv_Splat0);
  49. fixed4 lay2 = tex2D (_Splat1, IN.uv_Splat1);
  50. fixed4 lay3 = tex2D (_Splat2, IN.uv_Splat2);
  51. fixed4 lay4 = tex2D (_Splat3, IN.uv_Splat3);
  52. o.Alpha = 0.0;
  53. o.Albedo.rgb = (lay1 * splat_control.r + lay2 * splat_control.g + lay3 * splat_control.b + lay4 * splat_control.a);
  54. o.Gloss = (lay1.a * splat_control.r + lay2.a * splat_control.g + lay3.a * splat_control.b + lay4.a * splat_control.a);
  55. o.Specular = (_ShininessL0 * splat_control.r + _ShininessL1 * splat_control.g + _ShininessL2 * splat_control.b + _ShininessL3 * splat_control.a);
  56. }
  57. ENDCG
  58. }
  59. //FallBack "Specular"
  60. }