Hyluss

2 Pass normal surface shader

Nov 29th, 2020
548
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. Shader "Custom/NewSurfaceShader"
  2. {
  3. Properties
  4. {
  5. _MainTex2("Albedo (RGB) 2", 2D) = "white" {}
  6.  
  7. _Color ("Color", Color) = (1,1,1,1)
  8. _MainTex ("Albedo (RGB)", 2D) = "white" {}
  9. _Glossiness ("Smoothness", Range(0,1)) = 0.5
  10. _Metallic ("Metallic", Range(0,1)) = 0.0
  11.  
  12. _CutTex("Cutout (A)", 2D) = "white" {}
  13. _Cutoff("Alpha cutoff", Range(0,1)) = 0.5
  14. }
  15. SubShader
  16. {
  17.  
  18. // first pass
  19.  
  20. Tags { "RenderType"="Opaque" }
  21. LOD 200
  22.  
  23. CGPROGRAM
  24. // Physically based Standard lighting model, and enable shadows on all light types
  25. #pragma surface surf Standard fullforwardshadows
  26.  
  27. // Use shader model 3.0 target, to get nicer looking lighting
  28. #pragma target 3.0
  29.  
  30. sampler2D _MainTex;
  31.  
  32. struct Input
  33. {
  34. float2 uv_MainTex;
  35. };
  36.  
  37. half _Glossiness;
  38. half _Metallic;
  39. fixed4 _Color;
  40.  
  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.  
  48. void surf (Input IN, inout SurfaceOutputStandard o)
  49. {
  50. // Albedo comes from a texture tinted by color
  51. fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
  52. o.Albedo = c.rgb;
  53. // Metallic and smoothness come from slider variables
  54. o.Metallic = _Metallic;
  55. o.Smoothness = _Glossiness;
  56. o.Alpha = c.a;
  57. }
  58. ENDCG
  59.  
  60. // end first pass
  61.  
  62.  
  63. Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
  64. LOD 200
  65.  
  66. CGPROGRAM
  67. #pragma surface surf Lambert alpha
  68.  
  69. sampler2D _MainTex2;
  70. sampler2D _CutTex;
  71. fixed4 _Color;
  72. float _Cutoff;
  73.  
  74. struct Input {
  75. float2 uv_MainTex;
  76. };
  77.  
  78. void surf(Input IN, inout SurfaceOutput o) {
  79.  
  80.  
  81. fixed4 c = tex2D(_MainTex2, IN.uv_MainTex) * _Color;
  82. float ca = tex2D(_CutTex, IN.uv_MainTex).a;
  83. o.Albedo = c.rgb;
  84.  
  85. if (ca > _Cutoff)
  86. o.Alpha = c.a;
  87. else
  88. o.Alpha = 0;
  89. }
  90. ENDCG
  91.  
  92.  
  93.  
  94. }
  95. FallBack "Diffuse"
  96. }
  97.  
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment