Lux URP Transmission.shader 23 KB

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