1. Shader "Universal Render Pipeline/Unlit"
  2. {
  3. Properties
  4. {
  5. _BaseMap("Texture", 2D) = "white" {}
  6. _BaseColor("Color", Color) = (1, 1, 1, 1)
  7. _Cutoff("AlphaCutout", Range(0.0, 1.0)) = 0.5
  8.  
  9. // BlendMode
  10. [HideInInspector] _Surface("__surface", Float) = 0.0
  11. [HideInInspector] _Blend("__blend", Float) = 0.0
  12. [HideInInspector] _AlphaClip("__clip", Float) = 0.0
  13. [HideInInspector] _SrcBlend("Src", Float) = 1.0
  14. [HideInInspector] _DstBlend("Dst", Float) = 0.0
  15. [HideInInspector] _ZWrite("ZWrite", Float) = 1.0
  16. [HideInInspector] _Cull("__cull", Float) = 2.0
  17.  
  18. // Editmode props
  19. [HideInInspector] _QueueOffset("Queue offset", Float) = 0.0
  20.  
  21. // ObsoleteProperties
  22. [HideInInspector] _MainTex("BaseMap", 2D) = "white" {}
  23. [HideInInspector] _Color("Base Color", Color) = (0.5, 0.5, 0.5, 1)
  24. [HideInInspector] _SampleGI("SampleGI", float) = 0.0 // needed from bakedlit
  25. }
  26. SubShader
  27. {
  28. Tags { "RenderType" = "Opaque" "IgnoreProjector" = "True" "RenderPipeline" = "UniversalPipeline" }
  29. LOD 100
  30.  
  31. Blend [_SrcBlend][_DstBlend]
  32. ZWrite [_ZWrite]
  33. Cull [_Cull]
  34.  
  35. Pass
  36. {
  37. Name "Unlit"
  38. HLSLPROGRAM
  39. // Required to compile gles 2.0 with standard srp library
  40. #pragma prefer_hlslcc gles
  41. #pragma exclude_renderers d3d11_9x
  42.  
  43. #pragma vertex vert
  44. #pragma fragment frag
  45. #pragma shader_feature _ALPHATEST_ON
  46. #pragma shader_feature _ALPHAPREMULTIPLY_ON
  47.  
  48. // -------------------------------------
  49. // Unity defined keywords
  50. #pragma multi_compile_fog
  51. #pragma multi_compile_instancing
  52.  
  53. #include "UnlitInput.hlsl"
  54.  
  55. struct Attributes
  56. {
  57. float4 positionOS : POSITION;
  58. float2 uv : TEXCOORD0;
  59. UNITY_VERTEX_INPUT_INSTANCE_ID
  60. };
  61.  
  62. struct Varyings
  63. {
  64. float2 uv : TEXCOORD0;
  65. float fogCoord : TEXCOORD1;
  66. float4 vertex : SV_POSITION;
  67.  
  68. UNITY_VERTEX_INPUT_INSTANCE_ID
  69. UNITY_VERTEX_OUTPUT_STEREO
  70. };
  71.  
  72. Varyings vert(Attributes input)
  73. {
  74. Varyings output = (Varyings)0;
  75.  
  76. UNITY_SETUP_INSTANCE_ID(input);
  77. UNITY_TRANSFER_INSTANCE_ID(input, output);
  78. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  79.  
  80. VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
  81. output.vertex = vertexInput.positionCS;
  82. output.uv = TRANSFORM_TEX(input.uv, _BaseMap);
  83. output.fogCoord = ComputeFogFactor(vertexInput.positionCS.z);
  84.  
  85. return output;
  86. }
  87.  
  88. half4 frag(Varyings input) : SV_Target
  89. {
  90. UNITY_SETUP_INSTANCE_ID(input);
  91. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
  92.  
  93. half2 uv = input.uv;
  94. half4 texColor = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, uv);
  95. half3 color = texColor.rgb * _BaseColor.rgb;
  96. half alpha = texColor.a * _BaseColor.a;
  97. AlphaDiscard(alpha, _Cutoff);
  98.  
  99. #ifdef _ALPHAPREMULTIPLY_ON
  100. color *= alpha;
  101. #endif
  102.  
  103. color = MixFog(color, input.fogCoord);
  104.  
  105. return half4(color, alpha);
  106. }
  107. ENDHLSL
  108. }
  109. Pass
  110. {
  111. Tags{"LightMode" = "DepthOnly"}
  112.  
  113. ZWrite On
  114. ColorMask 0
  115.  
  116. HLSLPROGRAM
  117. // Required to compile gles 2.0 with standard srp library
  118. #pragma prefer_hlslcc gles
  119. #pragma exclude_renderers d3d11_9x
  120. #pragma target 2.0
  121.  
  122. #pragma vertex DepthOnlyVertex
  123. #pragma fragment DepthOnlyFragment
  124.  
  125. // -------------------------------------
  126. // Material Keywords
  127. #pragma shader_feature _ALPHATEST_ON
  128.  
  129. //--------------------------------------
  130. // GPU Instancing
  131. #pragma multi_compile_instancing
  132.  
  133. #include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitInput.hlsl"
  134. #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
  135. ENDHLSL
  136. }
  137.  
  138. // This pass it not used during regular rendering, only for lightmap baking.
  139. Pass
  140. {
  141. Name "Meta"
  142. Tags{"LightMode" = "Meta"}
  143.  
  144. Cull Off
  145.  
  146. HLSLPROGRAM
  147. // Required to compile gles 2.0 with standard srp library
  148. #pragma prefer_hlslcc gles
  149. #pragma exclude_renderers d3d11_9x
  150. #pragma vertex UniversalVertexMeta
  151. #pragma fragment UniversalFragmentMetaUnlit
  152.  
  153. #include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitInput.hlsl"
  154. #include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitMetaPass.hlsl"
  155.  
  156. ENDHLSL
  157. }
  158. }
  159. FallBack "Hidden/Universal Render Pipeline/FallbackError"
  160. CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.UnlitShader"
  161. }