Standard-Metallic-Blend.shader 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. Shader "GLTFUtility/Standard Transparent (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. }
  14. SubShader {
  15. Tags { "RenderType"="Transparent" "Queue"="Transparent" }
  16. LOD 200
  17. CGPROGRAM
  18. // Physically based Standard lighting model, and enable shadows on all light types
  19. #pragma surface surf Standard fullforwardshadows alpha:fade
  20. // Use shader model 3.0 target, to get nicer looking lighting
  21. #pragma target 3.0
  22. sampler2D _MainTex;
  23. sampler2D _MetallicGlossMap;
  24. sampler2D _BumpMap;
  25. sampler2D _OcclusionMap;
  26. sampler2D _EmissionMap;
  27. struct Input {
  28. float2 uv_MainTex;
  29. float2 uv_BumpMap;
  30. float2 uv_MetallicGlossMap;
  31. float2 uv_OcclusionMap;
  32. float2 uv_EmissionMap;
  33. float4 color : COLOR;
  34. };
  35. half _Roughness;
  36. half _Metallic;
  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 SurfaceOutputStandard 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. o.Alpha = c.a;
  52. // Metallic comes from blue channel tinted by slider variables
  53. fixed4 m = tex2D (_MetallicGlossMap, IN.uv_MetallicGlossMap);
  54. o.Metallic = m.b * _Metallic;
  55. // Smoothness comes from blue channel tinted by slider variables
  56. o.Smoothness = 1 - (m.g * _Roughness);
  57. // Normal comes from a bump map
  58. o.Normal = UnpackScaleNormal(tex2D (_BumpMap, IN.uv_BumpMap), _BumpScale);
  59. // Ambient Occlusion comes from red channel
  60. o.Occlusion = tex2D (_OcclusionMap, IN.uv_OcclusionMap).r;
  61. // Emission comes from a texture tinted by color
  62. o.Emission = tex2D (_EmissionMap, IN.uv_EmissionMap) * _EmissionColor;
  63. }
  64. ENDCG
  65. }
  66. FallBack "Diffuse"
  67. }