T4M 3 Textures Spec.shader 1.9 KB

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