StandardCrossfade (Specular).shader 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. Shader "HQ FPS Weapons/Standard Crossfade (Specular)"
  2. {
  3. Properties {
  4. _Color ("Color", Color) = (1,1,1,1)
  5. _Cutoff ("Cutoff", Range(0,1)) = 0.5
  6. _MainTex ("Albedo", 2D) = "white" {}
  7. _BumpMap ("Normal Map", 2D) = "bump" {}
  8. _Specular ("Specular", 2D) = "black" {}
  9. _Occlusion("Occlusion", 2D) = "white" {}
  10. [HideInInspector] _FlatMap ("Flat Normal Map", 2D) = "bump" {}
  11. _BumpIntensity ("Normal Intensity", Range(0,1)) = 1
  12. _Glossiness ("Smoothness", Range(0.0, 1.0)) = 0.5
  13. }
  14. SubShader
  15. {
  16. Tags
  17. { "RenderType"="Opaque"
  18. "IgnoreProjector"="True"
  19. "RenderType"="Grass"
  20. // "DisableBatching"="True"
  21. }
  22. LOD 300
  23. //Cull off
  24. CGPROGRAM
  25. #pragma multi_compile _ LOD_FADE_CROSSFADE
  26. #pragma surface surf StandardSpecular alphatest:_Cutoff
  27. #pragma target 3.0
  28. sampler2D _MainTex;
  29. sampler2D _BumpMap;
  30. sampler2D _FlatMap;
  31. sampler2D _Specular;
  32. sampler2D _Occlusion;
  33. struct Input
  34. {
  35. float4 screenPos;
  36. float2 uv_MainTex;
  37. float2 uv_BumpMap;
  38. float2 uv_Specular;
  39. float2 uv_Occlusion;
  40. };
  41. half _BumpIntensity;
  42. half _Glossiness;
  43. fixed4 _Color;
  44. void surf (Input IN, inout SurfaceOutputStandardSpecular o)
  45. {
  46. #ifdef LOD_FADE_CROSSFADE
  47. float2 vpos = IN.screenPos.xy / IN.screenPos.w * _ScreenParams.xy;
  48. UnityApplyDitherCrossFade(vpos);
  49. #endif
  50. fixed4 tex = tex2D (_MainTex, IN.uv_MainTex) * _Color;
  51. o.Albedo = tex.rgb;
  52. fixed3 normal1 = UnpackNormal(tex2D(_FlatMap, IN.uv_BumpMap));
  53. fixed3 normal2 = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  54. o.Normal = lerp(normal1, normal2, _BumpIntensity);
  55. o.Smoothness = tex2D(_Specular, IN.uv_Specular).a * _Glossiness;
  56. o.Specular = tex2D(_Specular, IN.uv_MainTex).rgb;
  57. o.Alpha = tex.a;
  58. o.Occlusion = tex2D(_Occlusion, IN.uv_Occlusion).g;
  59. }
  60. ENDCG
  61. }
  62. FallBack "Diffuse"
  63. }