Standard-Metallic.shader 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. Shader "GLTFUtility/Standard (Metallic)" {
  2. Properties {
  3. _Color ("Color", Color) = (1,1,1,1)
  4. _MainTex ("Albedo (RGB)", 2D) = "white" {}
  5. _MetallicGlossMap ("Metallic (B) Gloss (G)", 2D) = "white" {}
  6. _Roughness ("Roughness", Range(0,1)) = 1
  7. _Metallic ("Metallic", Range(0,1)) = 1
  8. [Normal] _BumpMap ("Normal", 2D) = "bump" {}
  9. _BumpScale("NormalScale", Float) = 1.0
  10. _OcclusionMap ("Occlusion (R)", 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 Standard lighting model, and enable shadows on all light types
  20. #pragma surface surf Standard fullforwardshadows
  21. // Use shader model 3.0 target, to get nicer looking lighting
  22. #pragma target 3.0
  23. sampler2D _MainTex;
  24. sampler2D _MetallicGlossMap;
  25. sampler2D _BumpMap;
  26. sampler2D _OcclusionMap;
  27. sampler2D _EmissionMap;
  28. struct Input {
  29. float2 uv_MainTex;
  30. float2 uv_BumpMap;
  31. float2 uv_MetallicGlossMap;
  32. float2 uv_OcclusionMap;
  33. float2 uv_EmissionMap;
  34. float4 color : COLOR;
  35. };
  36. half _Roughness;
  37. half _Metallic;
  38. half _AlphaCutoff;
  39. half _BumpScale;
  40. fixed4 _Color;
  41. fixed4 _EmissionColor;
  42. // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
  43. // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
  44. // #pragma instancing_options assumeuniformscaling
  45. UNITY_INSTANCING_BUFFER_START(Props)
  46. // put more per-instance properties here
  47. UNITY_INSTANCING_BUFFER_END(Props)
  48. void surf (Input IN, inout SurfaceOutputStandard o) {
  49. // Albedo comes from a texture tinted by color
  50. fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
  51. o.Albedo = c.rgb * IN.color;
  52. clip(c.a - _AlphaCutoff);
  53. // Metallic comes from blue channel tinted by slider variables
  54. fixed4 m = tex2D (_MetallicGlossMap, IN.uv_MetallicGlossMap);
  55. o.Metallic = m.b * _Metallic;
  56. // Smoothness comes from blue channel tinted by slider variables
  57. o.Smoothness = 1 - (m.g * _Roughness);
  58. // Normal comes from a bump map
  59. o.Normal = UnpackScaleNormal (tex2D (_BumpMap, IN.uv_BumpMap), _BumpScale);
  60. // Ambient Occlusion comes from red channel
  61. o.Occlusion = tex2D (_OcclusionMap, IN.uv_OcclusionMap).r;
  62. // Emission comes from a texture tinted by color
  63. o.Emission = tex2D (_EmissionMap, IN.uv_EmissionMap) * _EmissionColor;
  64. }
  65. ENDCG
  66. }
  67. FallBack "Diffuse"
  68. }