Standard-Specular.shader 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. Shader "GLTFUtility/Standard (Specular)" {
  2. Properties {
  3. _Color ("Color", Color) = (1,1,1,1)
  4. _MainTex ("Albedo (RGB)", 2D) = "white" {}
  5. _SpecGlossMap ("Specular Map", 2D) = "white" {}
  6. _SpecColor ("Specular Color", Color) = (1,1,1,1)
  7. _GlossyReflections ("Glossiness", Range(0,1)) = 1
  8. [Normal] _BumpMap ("Normal", 2D) = "bump" {}
  9. _BumpScale("NormalScale", Float) = 1.0
  10. _OcclusionMap ("Occlusion", 2D) = "white" {}
  11. _EmissionMap ("Emission", 2D) = "black" {}
  12. _EmissionColor ("Emission Color", Color) = (0,0,0,0)
  13. _AlphaCutoff ("Alpha Cutoff", Range(0,1)) = 0
  14. }
  15. SubShader {
  16. Tags { "RenderType"="Opaque" }
  17. LOD 200
  18. CGPROGRAM
  19. // Physically based StandardSpecular lighting model, and enable shadows on all light types
  20. #pragma surface surf StandardSpecular fullforwardshadows
  21. // Use shader model 3.0 target, to get nicer looking lighting
  22. #pragma target 3.0
  23. sampler2D _MainTex;
  24. sampler2D _SpecGlossMap;
  25. sampler2D _BumpMap;
  26. sampler2D _OcclusionMap;
  27. sampler2D _EmissionMap;
  28. struct Input {
  29. float2 uv_MainTex;
  30. float2 uv_BumpMap;
  31. float2 uv_SpecGlossMap;
  32. float2 uv_OcclusionMap;
  33. float2 uv_EmissionMap;
  34. float4 color : COLOR;
  35. };
  36. half _GlossyReflections;
  37. half _AlphaCutoff;
  38. half _BumpScale;
  39. fixed4 _Color;
  40. fixed4 _EmissionColor;
  41. // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
  42. // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
  43. // #pragma instancing_options assumeuniformscaling
  44. UNITY_INSTANCING_BUFFER_START(Props)
  45. // put more per-instance properties here
  46. UNITY_INSTANCING_BUFFER_END(Props)
  47. void surf (Input IN, inout SurfaceOutputStandardSpecular o) {
  48. // Albedo comes from a texture tinted by color
  49. fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
  50. o.Albedo = c.rgb * IN.color;
  51. clip(c.a - _AlphaCutoff);
  52. // Specular / roughness
  53. fixed4 s = tex2D (_SpecGlossMap, IN.uv_SpecGlossMap);
  54. o.Specular = s.rgb * _SpecColor;
  55. o.Smoothness = s.a * _GlossyReflections;
  56. // Normal comes from a bump map
  57. o.Normal = UnpackScaleNormal (tex2D (_BumpMap, IN.uv_BumpMap), _BumpScale);
  58. // Ambient Occlusion comes from red channel
  59. o.Occlusion = tex2D (_OcclusionMap, IN.uv_OcclusionMap).r;
  60. // Emission comes from a texture tinted by color
  61. o.Emission = tex2D (_EmissionMap, IN.uv_EmissionMap) * _EmissionColor;
  62. }
  63. ENDCG
  64. }
  65. FallBack "Diffuse"
  66. }