Lux URP Clear Coat.shader 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. // Shader uses custom editor to set double sided GI
  2. // Needs _Culling to be set properly
  3. Shader "Lux URP/Clear Coat"
  4. {
  5. Properties
  6. {
  7. [HeaderHelpLuxURP_URL(vw98j94c4183)]
  8. [Header(Surface Options)]
  9. [Space(8)]
  10. [ToggleOff(_RECEIVE_SHADOWS_OFF)]
  11. _ReceiveShadows ("Receive Shadows", Float) = 1.0
  12. [Header(Clear Coat Inputs)]
  13. [Space(8)]
  14. _ClearCoatThickness ("Clear Coat", Range(0.0, 1.0)) = 0.5
  15. _ClearCoatSmoothness ("Clear Coat Smoothness", Range(0.0, 1.0)) = 0.5
  16. _ClearCoatSpecular ("Clear Coat Specular", Color) = (0.2, 0.2, 0.2)
  17. [Toggle(_MASKMAP)]
  18. _EnableCoatMask ("Enable Coat Mask Map", Float) = 0.0
  19. _CoatMask (" Mask (G) Smoothness (A)", 2D) = "white" {}
  20. [Toggle(_STANDARDLIGHTING)]
  21. _EnableStandardLighting (" Enable Standard Lighting", Float) = 0.0
  22. [Header(Base Layer Inputs)]
  23. [Space(8)]
  24. [MainColor]
  25. _BaseColor ("Color", Color) = (1,1,1,1)
  26. [Toggle(_BASECOLORMAP)]
  27. _EnableBaseMap ("Enable Base Layer Albedo Map", Float) = 0.0
  28. [MainTexture]
  29. _BaseMap ("Base Layer Albedo (RGB)", 2D) = "white" {}
  30. [Toggle(_SECONDARYCOLOR)]
  31. _EnableSecColor ("Enable Secondary Color", Float) = 0.0
  32. _SecondaryColor (" Secondary Color", Color) = (1,1,1,1)
  33. [Space(5)]
  34. _Smoothness ("Smoothness", Range(0.0, 1.0)) = 0.5
  35. _Metallic ("Metallic", Range(0.0, 1.0)) = 0.145
  36. //[Toggle(_ADJUSTSPEC)]
  37. //_AdjustSpec ("Adjust Specular", Float) = 0.0
  38. [Space(5)]
  39. [Toggle(_NORMALMAP)]
  40. _ApplyNormal ("Enable Normal Map", Float) = 0.0
  41. _BumpMap (" Normal Map", 2D) = "bump" {}
  42. _BumpScale (" Normal Scale", Float) = 1.0
  43. [Toggle(_MASKMAPSECONDARY)]
  44. _EnableSecondaryMask ("Enable Base Layer Mask Map", Float) = 0.0
  45. _SecondaryMask (" Metallic (R) Occlusion (G) Smoothness (A)", 2D) = "white" {}
  46. _Occlusion (" Occlusion", Range(0.0, 1.0)) = 1.0
  47. [Toggle(_SECONDARYLOBE)]
  48. _EnableSecondaryLobe ("Enable secondary Reflection Sample", Float) = 0.0
  49. [Header(Rim Lighting)]
  50. [Space(8)]
  51. [Toggle(_RIMLIGHTING)]
  52. _Rim ("Enable Rim Lighting", Float) = 0
  53. [HDR] _RimColor ("Rim Color", Color) = (0.5,0.5,0.5,1)
  54. _RimPower ("Rim Power", Float) = 2
  55. _RimFrequency ("Rim Frequency", Float) = 0
  56. _RimMinPower (" Rim Min Power", Float) = 1
  57. _RimPerPositionFrequency (" Rim Per Position Frequency", Range(0.0, 1.0)) = 1
  58. [Header(Stencil)]
  59. [Space(8)]
  60. [IntRange] _Stencil ("Stencil Reference", Range (0, 255)) = 0
  61. [IntRange] _ReadMask (" Read Mask", Range (0, 255)) = 255
  62. [IntRange] _WriteMask (" Write Mask", Range (0, 255)) = 255
  63. [Enum(UnityEngine.Rendering.CompareFunction)]
  64. _StencilComp ("Stencil Comparison", Int) = 8 // always – terrain should be the first thing being rendered anyway
  65. [Enum(UnityEngine.Rendering.StencilOp)]
  66. _StencilOp ("Stencil Operation", Int) = 0 // 0 = keep, 2 = replace
  67. [Enum(UnityEngine.Rendering.StencilOp)]
  68. _StencilFail ("Stencil Fail Op", Int) = 0 // 0 = keep
  69. [Enum(UnityEngine.Rendering.StencilOp)]
  70. _StencilZFail ("Stencil ZFail Op", Int) = 0 // 0 = keep
  71. [Header(Advanced)]
  72. [Space(8)]
  73. //[ToggleOff]
  74. //_SpecularHighlights ("Enable Specular Highlights", Float) = 1.0
  75. [ToggleOff]
  76. _EnvironmentReflections ("Environment Reflections", Float) = 1.0
  77. // Needed by the inspector
  78. [HideInInspector] _Culling ("Culling", Float) = 0.0
  79. // Lightmapper and outline selection shader need _MainTex, _Color and _Cutoff
  80. [HideInInspector] _MainTex ("Albedo", 2D) = "white" {}
  81. [HideInInspector] _Color ("Color", Color) = (1,1,1,1)
  82. // URP 10.1. needs this for the depthnormal pass
  83. [HideInInspector] _Cutoff (" Threshold", Range(0.0, 1.0)) = 0.5
  84. [HideInInspector] _Surface("__surface", Float) = 0.0
  85. }
  86. SubShader
  87. {
  88. Tags
  89. {
  90. "RenderPipeline" = "UniversalPipeline"
  91. "RenderType" = "Opaque"
  92. "Queue" = "Geometry"
  93. }
  94. LOD 100
  95. Pass
  96. {
  97. Name "ForwardLit"
  98. Tags{"LightMode" = "UniversalForward"}
  99. Stencil {
  100. Ref [_Stencil]
  101. ReadMask [_ReadMask]
  102. WriteMask [_WriteMask]
  103. Comp [_StencilComp]
  104. Pass [_StencilOp]
  105. Fail [_StencilFail]
  106. ZFail [_StencilZFail]
  107. }
  108. ZWrite On
  109. Cull Back
  110. HLSLPROGRAM
  111. // Required to compile gles 2.0 with standard SRP library
  112. #pragma prefer_hlslcc gles
  113. #pragma exclude_renderers d3d11_9x
  114. // Shader target needs to be 3.0 due to tex2Dlod in the vertex shader and VFACE
  115. #pragma target 2.0
  116. // -------------------------------------
  117. // Material Keywords
  118. #pragma shader_feature_local _BASECOLORMAP
  119. #pragma shader_feature_local _SECONDARYCOLOR
  120. //#pragma shader_feature_local _ADJUSTSPEC
  121. #pragma shader_feature_local _MASKMAP
  122. #pragma shader_feature_local _STANDARDLIGHTING
  123. #pragma shader_feature_local _MASKMAPSECONDARY
  124. #pragma shader_feature_local _SECONDARYLOBE
  125. #pragma shader_feature_local _NORMALMAP
  126. #pragma shader_feature_local _RIMLIGHTING
  127. //#pragma shader_feature _SPECULARHIGHLIGHTS_OFF
  128. #pragma shader_feature _ENVIRONMENTREFLECTIONS_OFF
  129. #pragma shader_feature _RECEIVE_SHADOWS_OFF
  130. // -------------------------------------
  131. // Universal Pipeline keywords
  132. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS
  133. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
  134. #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  135. #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
  136. #pragma multi_compile_fragment _ _SHADOWS_SOFT
  137. #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
  138. #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
  139. #pragma multi_compile _ SHADOWS_SHADOWMASK
  140. // -------------------------------------
  141. // Unity defined keywords
  142. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  143. #pragma multi_compile _ LIGHTMAP_ON
  144. #pragma multi_compile_fog
  145. //--------------------------------------
  146. // GPU Instancing
  147. #pragma multi_compile_instancing
  148. // #pragma multi_compile _ DOTS_INSTANCING_ON // needs shader target 4.5
  149. // Include base inputs and all other needed "base" includes
  150. #include "Includes/Lux URP Clear Coat Inputs.hlsl"
  151. #pragma vertex LitPassVertex
  152. #pragma fragment LitPassFragment
  153. //--------------------------------------
  154. // Vertex shader
  155. VertexOutput LitPassVertex(VertexInput input)
  156. {
  157. VertexOutput output = (VertexOutput)0;
  158. UNITY_SETUP_INSTANCE_ID(input);
  159. UNITY_TRANSFER_INSTANCE_ID(input, output);
  160. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  161. VertexPositionInputs vertexInput; //
  162. vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
  163. VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS);
  164. float3 viewDirWS = GetCameraPositionWS() - vertexInput.positionWS;
  165. half3 vertexLight = VertexLighting(vertexInput.positionWS, normalInput.normalWS);
  166. half fogFactor = ComputeFogFactor(vertexInput.positionCS.z);
  167. //output.uv.xy = TRANSFORM_TEX(input.texcoord, _BumpMap);
  168. output.uv.xy = input.texcoord;
  169. // already normalized from normal transform to WS.
  170. output.normalWS = normalInput.normalWS;
  171. output.viewDirWS = viewDirWS;
  172. #if defined(_MASKMAP)
  173. output.uv.zw = TRANSFORM_TEX(input.texcoord, _CoatMask);
  174. #endif
  175. #if defined(_NORMALMAP)
  176. float sign = input.tangentOS.w * GetOddNegativeScale();
  177. output.tangentWS = float4(normalInput.tangentWS, sign);
  178. #endif
  179. OUTPUT_LIGHTMAP_UV(input.lightmapUV, unity_LightmapST, output.lightmapUV);
  180. OUTPUT_SH(output.normalWS.xyz, output.vertexSH);
  181. output.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
  182. #if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR)
  183. output.positionWS = vertexInput.positionWS;
  184. #endif
  185. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  186. output.shadowCoord = GetShadowCoord(vertexInput);
  187. #endif
  188. output.positionCS = vertexInput.positionCS;
  189. return output;
  190. }
  191. //--------------------------------------
  192. // Fragment shader and functions
  193. inline void InitializeSurfaceData(
  194. #if defined(_MASKMAP)
  195. float4 uv,
  196. #else
  197. float2 uv,
  198. #endif
  199. out SurfaceDescription outSurfaceData)
  200. {
  201. outSurfaceData.occlusion = 1;
  202. outSurfaceData.alpha = 1;
  203. outSurfaceData.albedo = 1;
  204. outSurfaceData.metallic = _Metallic;
  205. outSurfaceData.specular = half3(0.0h, 0.0h, 0.0h);
  206. outSurfaceData.smoothness = _Smoothness;
  207. #if defined (_BASECOLORMAP)
  208. float2 albedoUV = TRANSFORM_TEX(uv, _BaseMap);
  209. outSurfaceData.albedo = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, albedoUV).rgb;
  210. #endif
  211. // Normal Map
  212. #if defined (_NORMALMAP)
  213. // half4 sampleNormal = SAMPLE_TEXTURE2D(_MaskMap, sampler_MaskMap, uv);
  214. // half3 tangentNormal;
  215. // tangentNormal.xy = sampleNormal.ag * 2 - 1;
  216. // tangentNormal.xy *= _BumpScale;
  217. // tangentNormal.z = sqrt(1.0 - dot(tangentNormal.xy, tangentNormal.xy));
  218. // outSurfaceData.normalTS = tangentNormal;
  219. // outSurfaceData.smoothness = sampleNormal.b * _Smoothness;
  220. float2 normalUV = TRANSFORM_TEX(uv, _BumpMap);
  221. outSurfaceData.normalTS = SampleNormal(normalUV, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale);
  222. #else
  223. outSurfaceData.normalTS = half3(0,0,1);
  224. #endif
  225. // Secondary Mask
  226. #if defined(_MASKMAPSECONDARY)
  227. float2 secondaryMaskUV = TRANSFORM_TEX(uv, _SecondaryMask);
  228. half4 secondaryMaskSample = SAMPLE_TEXTURE2D(_SecondaryMask, sampler_SecondaryMask, secondaryMaskUV);
  229. outSurfaceData.metallic *= secondaryMaskSample.r;
  230. outSurfaceData.occlusion = lerp(1, secondaryMaskSample.g, _Occlusion);
  231. outSurfaceData.smoothness *= secondaryMaskSample.a;
  232. #endif
  233. // Coat
  234. outSurfaceData.clearCoatSmoothness = _ClearCoatSmoothness;
  235. outSurfaceData.clearCoatThickness = _ClearCoatThickness;
  236. #if defined(_MASKMAP)
  237. half4 maskSample = SAMPLE_TEXTURE2D(_CoatMask, sampler_CoatMask, uv.zw);
  238. outSurfaceData.clearCoatSmoothness *= maskSample.a;
  239. outSurfaceData.clearCoatThickness *= maskSample.g;
  240. #endif
  241. outSurfaceData.emission = 0;
  242. }
  243. void InitializeInputData(VertexOutput input, half3 normalTS, out InputData inputData)
  244. {
  245. inputData = (InputData)0;
  246. #if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR)
  247. inputData.positionWS = input.positionWS;
  248. #endif
  249. half3 viewDirWS = SafeNormalize(input.viewDirWS);
  250. #ifdef _NORMALMAP
  251. float sgn = input.tangentWS.w; // should be either +1 or -1
  252. float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz);
  253. inputData.normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWS.xyz));
  254. #else
  255. inputData.normalWS = input.normalWS; // * facing;
  256. #endif
  257. inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
  258. inputData.viewDirectionWS = viewDirWS;
  259. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  260. inputData.shadowCoord = input.shadowCoord;
  261. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  262. inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
  263. #else
  264. inputData.shadowCoord = float4(0, 0, 0, 0);
  265. #endif
  266. inputData.fogCoord = input.fogFactorAndVertexLight.x;
  267. inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
  268. inputData.bakedGI = SAMPLE_GI(input.lightmapUV, input.vertexSH, inputData.normalWS);
  269. //inputData.normalizedScreenSpaceUV = input.positionCS.xy;
  270. inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
  271. inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV);
  272. }
  273. half4 LitPassFragment(VertexOutput input) : SV_Target
  274. {
  275. UNITY_SETUP_INSTANCE_ID(input);
  276. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
  277. // Get the surface description
  278. SurfaceDescription surfaceData;
  279. InitializeSurfaceData(input.uv, surfaceData);
  280. // Prepare surface data (like bring normal into world space and get missing inputs like gi)
  281. InputData inputData;
  282. InitializeInputData(input, surfaceData.normalTS, inputData);
  283. #if defined(_RIMLIGHTING)
  284. half rim = saturate(1.0h - saturate( dot(inputData.normalWS, inputData.viewDirectionWS) ) );
  285. half power = _RimPower;
  286. UNITY_BRANCH if(_RimFrequency > 0 ) {
  287. half perPosition = lerp(0.0h, 1.0h, dot(1.0h, frac(UNITY_MATRIX_M._m03_m13_m23) * 2.0h - 1.0h ) * _RimPerPositionFrequency ) * 3.1416h;
  288. power = lerp(power, _RimMinPower, (1.0h + sin(_Time.y * _RimFrequency + perPosition) ) * 0.5h );
  289. }
  290. surfaceData.emission += pow(rim, power) * _RimColor.rgb * _RimColor.a;
  291. #endif
  292. // Apply lighting
  293. half4 color = LuxClearCoatFragmentPBR(
  294. inputData,
  295. surfaceData.albedo,
  296. surfaceData.metallic,
  297. surfaceData.specular,
  298. surfaceData.smoothness,
  299. surfaceData.occlusion,
  300. surfaceData.emission,
  301. surfaceData.alpha,
  302. surfaceData.clearCoatSmoothness,
  303. surfaceData.clearCoatThickness,
  304. _ClearCoatSpecular.rgb,
  305. NormalizeNormalPerPixel(input.normalWS.xyz),
  306. #if defined (_BASECOLORMAP)
  307. _BaseColor.rgb * surfaceData.albedo,
  308. #else
  309. _BaseColor.rgb,
  310. #endif
  311. _SecondaryColor.rgb
  312. );
  313. // Add fog
  314. color.rgb = MixFog(color.rgb, inputData.fogCoord);
  315. return color;
  316. }
  317. ENDHLSL
  318. }
  319. // Shadows -----------------------------------------------------
  320. Pass
  321. {
  322. Name "ShadowCaster"
  323. Tags{"LightMode" = "ShadowCaster"}
  324. ZWrite On
  325. ZTest LEqual
  326. Cull Off
  327. HLSLPROGRAM
  328. // Required to compile gles 2.0 with standard srp library
  329. #pragma prefer_hlslcc gles
  330. #pragma exclude_renderers d3d11_9x
  331. #pragma target 2.0
  332. // -------------------------------------
  333. // Material Keywords
  334. //--------------------------------------
  335. // GPU Instancing
  336. #pragma multi_compile_instancing
  337. // #pragma multi_compile _ DOTS_INSTANCING_ON // needs shader target 4.5
  338. #pragma vertex ShadowPassVertex
  339. #pragma fragment ShadowPassFragment
  340. // Include base inputs and all other needed "base" includes
  341. #include "Includes/Lux URP Clear Coat Inputs.hlsl"
  342. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
  343. // Shadow caster specific input
  344. float3 _LightDirection;
  345. VertexOutput ShadowPassVertex(VertexInput input)
  346. {
  347. VertexOutput output = (VertexOutput)0;
  348. UNITY_SETUP_INSTANCE_ID(input);
  349. UNITY_TRANSFER_INSTANCE_ID(input, output);
  350. float3 positionWS = TransformObjectToWorld(input.positionOS.xyz);
  351. float3 normalWS = TransformObjectToWorldDir(input.normalOS);
  352. output.positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, _LightDirection));
  353. #if UNITY_REVERSED_Z
  354. output.positionCS.z = min(output.positionCS.z, output.positionCS.w * UNITY_NEAR_CLIP_VALUE);
  355. #else
  356. output.positionCS.z = max(output.positionCS.z, output.positionCS.w * UNITY_NEAR_CLIP_VALUE);
  357. #endif
  358. return output;
  359. }
  360. half4 ShadowPassFragment(VertexOutput input) : SV_TARGET
  361. {
  362. UNITY_SETUP_INSTANCE_ID(input);
  363. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
  364. return 0;
  365. }
  366. ENDHLSL
  367. }
  368. // Depth -----------------------------------------------------
  369. Pass
  370. {
  371. Tags{"LightMode" = "DepthOnly"}
  372. ZWrite On
  373. ColorMask 0
  374. Cull Off
  375. HLSLPROGRAM
  376. // Required to compile gles 2.0 with standard srp library
  377. #pragma prefer_hlslcc gles
  378. #pragma exclude_renderers d3d11_9x
  379. #pragma target 2.0
  380. #pragma vertex DepthOnlyVertex
  381. #pragma fragment DepthOnlyFragment
  382. // -------------------------------------
  383. // Material Keywords
  384. //--------------------------------------
  385. // GPU Instancing
  386. #pragma multi_compile_instancing
  387. // #pragma multi_compile _ DOTS_INSTANCING_ON // needs shader target 4.5
  388. #define DEPTHONLYPASS
  389. #include "Includes/Lux URP Clear Coat Inputs.hlsl"
  390. VertexOutput DepthOnlyVertex(VertexInput input)
  391. {
  392. VertexOutput output = (VertexOutput)0;
  393. UNITY_SETUP_INSTANCE_ID(input);
  394. UNITY_TRANSFER_INSTANCE_ID(input, output);
  395. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  396. output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
  397. return output;
  398. }
  399. half4 DepthOnlyFragment(VertexOutput input) : SV_TARGET
  400. {
  401. UNITY_SETUP_INSTANCE_ID(input);
  402. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
  403. return 0;
  404. }
  405. ENDHLSL
  406. }
  407. // Depth Normal ---------------------------------------------
  408. // This pass is used when drawing to a _CameraNormalsTexture texture
  409. Pass
  410. {
  411. Name "DepthNormals"
  412. Tags{"LightMode" = "DepthNormals"}
  413. ZWrite On
  414. Cull[_Cull]
  415. HLSLPROGRAM
  416. #pragma exclude_renderers d3d11_9x gles
  417. #pragma target 4.5
  418. #pragma vertex DepthNormalsVertex
  419. #pragma fragment DepthNormalsFragment
  420. // -------------------------------------
  421. // Material Keywords
  422. #pragma shader_feature_local _NORMALMAP
  423. //#pragma shader_feature_local_fragment _ALPHATEST_ON
  424. //#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  425. //--------------------------------------
  426. // GPU Instancing
  427. #pragma multi_compile_instancing
  428. // #pragma multi_compile _ DOTS_INSTANCING_ON // needs shader target 4.5
  429. //#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  430. #include "Includes/Lux URP Clear Coat Inputs.hlsl"
  431. #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl"
  432. ENDHLSL
  433. }
  434. // Meta -----------------------------------------------------
  435. Pass
  436. {
  437. Tags{"LightMode" = "Meta"}
  438. Cull Off
  439. HLSLPROGRAM
  440. // Required to compile gles 2.0 with standard srp library
  441. #pragma prefer_hlslcc gles
  442. #pragma vertex UniversalVertexMeta
  443. #pragma fragment UniversalFragmentMeta
  444. // #define _SPECULAR_SETUP
  445. // First include all our custom stuff
  446. #include "Includes/Lux URP Clear Coat Inputs.hlsl"
  447. //--------------------------------------
  448. // Fragment shader and functions
  449. inline void InitializeStandardLitSurfaceData(float2 uv, out SurfaceData outSurfaceData)
  450. {
  451. //half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
  452. outSurfaceData.alpha = 1;
  453. outSurfaceData.albedo = _BaseColor.rgb;
  454. outSurfaceData.metallic = _Metallic; // 0
  455. outSurfaceData.specular = 0; //_SpecColor;
  456. outSurfaceData.smoothness = _Smoothness;
  457. outSurfaceData.normalTS = half3(0,0,1);
  458. outSurfaceData.occlusion = 1;
  459. outSurfaceData.emission = 0;
  460. outSurfaceData.clearCoatMask = 0;
  461. outSurfaceData.clearCoatSmoothness = 0;
  462. }
  463. // Finally include the meta pass related stuff
  464. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"
  465. ENDHLSL
  466. }
  467. // End Passes -----------------------------------------------------
  468. }
  469. FallBack "Hidden/InternalErrorShader"
  470. CustomEditor "LuxURPUniversalCustomShaderGUI"
  471. }