Lux URP Glass.shader 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. // Shader uses custom editor to set double sided GI
  2. // Needs _Culling to be set properly
  3. Shader "Lux URP/Glass"
  4. {
  5. Properties
  6. {
  7. [HeaderHelpLuxURP_URL(3fte1chjgh54)]
  8. [Header(Surface Options)]
  9. [Space(8)]
  10. [Enum(Off,0,On,1)]_ZWrite ("ZWrite", Float) = 1.0
  11. [Enum(UnityEngine.Rendering.CullMode)]
  12. _Cull ("Culling", Float) = 2
  13. [Enum(None,0,Transparent,1,Additive,2)]
  14. _Blend ("Blending", Float) = 0.0
  15. _FinalAlpha (" Final Alpha", Range(0.0, 1.0)) = 0.5
  16. [ToggleOff(_RECEIVE_SHADOWS_OFF)]
  17. _ReceiveShadows ("Receive Shadows", Float) = 1.0
  18. [Header(Surface Inputs)]
  19. [Space(8)]
  20. [MainColor]
  21. _BaseColor ("Color (RGB) Alpha (A)", Color) = (1,1,1,0)
  22. [Toggle(_BASEMAP)]
  23. _EnableBaseMap ("Enable Base Map", Float) = 0.0
  24. [MainTexture]
  25. _BaseMap (" Albedo (RGB) Alpha (A)", 2D) = "white" {}
  26. [Space(5)]
  27. _Smoothness ("Smoothness", Range(0.0, 1.0)) = 0.5
  28. _SmoothnessBase (" Smoothness Opaque", Range(0.0, 1.0)) = 0.5
  29. _SpecColor ("Specular", Color) = (0.2, 0.2, 0.2)
  30. _SpecColorBase (" Specular Opaque", Color) = (0.2, 0.2, 0.2)
  31. [Space(5)]
  32. [Toggle(_MASKMAP)]
  33. _EnableMaskMap ("Enable Mask Map", Float) = 0.0
  34. [NoScaleOffset] _MaskMap (" Thickness Mask (R) Smoothness (A)", 2D) = "white" {}
  35. [Space(5)]
  36. [Toggle(_NORMALMAP)]
  37. _ApplyNormal ("Enable Normal Map", Float) = 0.0
  38. [NoScaleOffset] _BumpMap (" Normal Map", 2D) = "bump" {}
  39. _BumpScale (" Normal Scale", Float) = 1.0
  40. [Header(Refrection)]
  41. [Space(8)]
  42. [Toggle(_GEOREFRACTIONS)]
  43. _EnableGeoRefr ("Enable geometric Refractions", Float) = 1.0
  44. _IOR (" Index of Refraction", Float) = 1.33
  45. _IsThinShell (" Thin Shell", Range(0.0, 0.98)) = 0
  46. [Space(5)]
  47. [Toggle(_SCREENEDGEFADE)]
  48. _EnableScreenEdgeFade ("Enable Screen Edge Fade", Float) = 0.0
  49. _ScreenEdgeFade (" Fade Width", Range(8.0, 32.0)) = 8
  50. [Space(5)]
  51. _BumpRefraction ("Bump Distortion", Range(0.0, 1.0)) = 0.1
  52. [Space(5)]
  53. [Toggle(_EXCLUDEFOREGROUND)]
  54. _ExcludeForeground ("Exclude Foreground", Float) = 0.0
  55. [Header(Rim Lighting)]
  56. [Space(8)]
  57. [Toggle(_RIMLIGHTING)]
  58. _Rim ("Enable Rim Lighting", Float) = 0
  59. [HDR] _RimColor ("Rim Color", Color) = (0.5,0.5,0.5,1)
  60. _RimPower ("Rim Power", Float) = 2
  61. _RimFrequency ("Rim Frequency", Float) = 0
  62. _RimMinPower (" Rim Min Power", Float) = 1
  63. _RimPerPositionFrequency (" Rim Per Position Frequency", Range(0.0, 1.0)) = 1
  64. [Header(Stencil)]
  65. [Space(8)]
  66. [IntRange] _Stencil ("Stencil Reference", Range (0, 255)) = 0
  67. [IntRange] _ReadMask (" Read Mask", Range (0, 255)) = 255
  68. [IntRange] _WriteMask (" Write Mask", Range (0, 255)) = 255
  69. [Enum(UnityEngine.Rendering.CompareFunction)]
  70. _StencilComp ("Stencil Comparison", Int) = 8 // always
  71. [Enum(UnityEngine.Rendering.StencilOp)]
  72. _StencilOp ("Stencil Operation", Int) = 0 // 0 = keep, 2 = replace
  73. [Enum(UnityEngine.Rendering.StencilOp)]
  74. _StencilFail ("Stencil Fail Op", Int) = 0 // 0 = keep
  75. [Enum(UnityEngine.Rendering.StencilOp)]
  76. _StencilZFail ("Stencil ZFail Op", Int) = 0 // 0 = keep
  77. [Header(Advanced)]
  78. [Space(8)]
  79. [ToggleOff]
  80. _SpecularHighlights ("Enable Specular Highlights", Float) = 1.0
  81. [ToggleOff]
  82. _EnvironmentReflections ("Environment Reflections", Float) = 1.0
  83. [Space(5)]
  84. [HideInInspector] _SrcBlend ("SrcBlend", Float) = 1.0
  85. [HideInInspector] _DstBlend ("_DstBlend", Float) = 0.0
  86. // Lightmapper and outline selection shader need _MainTex, _Color and _Cutoff
  87. [HideInInspector] _MainTex ("Albedo", 2D) = "white" {}
  88. [HideInInspector] _Color ("Color", Color) = (1,1,1,1)
  89. }
  90. SubShader
  91. {
  92. Tags
  93. {
  94. "RenderPipeline" = "UniversalPipeline"
  95. "RenderType" = "Transparent"
  96. "Queue" = "Transparent"
  97. }
  98. LOD 100
  99. Pass
  100. {
  101. Name "ForwardLit"
  102. Tags{"LightMode" = "UniversalForward"}
  103. Stencil {
  104. Ref [_Stencil]
  105. ReadMask [_ReadMask]
  106. WriteMask [_WriteMask]
  107. Comp [_StencilComp]
  108. Pass [_StencilOp]
  109. Fail [_StencilFail]
  110. ZFail [_StencilZFail]
  111. }
  112. ZWrite [_ZWrite]
  113. Cull [_Cull]
  114. Blend [_SrcBlend] [_DstBlend]
  115. HLSLPROGRAM
  116. // Required to compile gles 2.0 with standard SRP library
  117. #pragma prefer_hlslcc gles
  118. #pragma exclude_renderers d3d11_9x
  119. #pragma target 2.0
  120. // -------------------------------------
  121. // Material Keywords
  122. #define _SPECULAR_SETUP 1
  123. // #pragma shader_feature _ALPHATEST_ON
  124. #define _ALPHAPREMULTIPLY_ON
  125. #pragma shader_feature_local _NORMALMAP
  126. #pragma shader_feature_local_fragment _GEOREFRACTIONS
  127. #pragma shader_feature_local_fragment _SCREENEDGEFADE
  128. #pragma shader_feature_local_fragment _FINALALPHA
  129. #pragma shader_feature_local_fragment _ADDITIVE
  130. #pragma shader_feature_local_fragment _BASEMAP
  131. #pragma shader_feature_local_fragment _MASKMAP
  132. #pragma shader_feature_local_fragment _EXCLUDEFOREGROUND
  133. #pragma shader_feature_local_fragment _RIMLIGHTING
  134. #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
  135. #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
  136. #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
  137. // -------------------------------------
  138. // Lightweight Pipeline keywords
  139. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS
  140. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
  141. #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  142. #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
  143. #pragma multi_compile_fragment _ _SHADOWS_SOFT
  144. #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
  145. // -------------------------------------
  146. // Unity defined keywords
  147. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  148. #pragma multi_compile _ LIGHTMAP_ON
  149. #pragma multi_compile_fog
  150. //--------------------------------------
  151. // GPU Instancing
  152. #pragma multi_compile_instancing
  153. // #pragma multi_compile _ DOTS_INSTANCING_ON // needs shader target 4.5
  154. // Include base inputs and all other needed "base" includes
  155. #include "Includes/Lux URP Glass Inputs.hlsl"
  156. #pragma vertex LitPassVertex
  157. #pragma fragment LitPassFragment
  158. //--------------------------------------
  159. // Vertex shader
  160. VertexOutput LitPassVertex(VertexInput input)
  161. {
  162. VertexOutput output = (VertexOutput)0;
  163. UNITY_SETUP_INSTANCE_ID(input);
  164. UNITY_TRANSFER_INSTANCE_ID(input, output);
  165. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  166. VertexPositionInputs vertexInput; //
  167. vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
  168. VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS);
  169. float3 viewDirWS = GetCameraPositionWS() - vertexInput.positionWS;
  170. half3 vertexLight = VertexLighting(vertexInput.positionWS, normalInput.normalWS);
  171. half fogFactor = ComputeFogFactor(vertexInput.positionCS.z);
  172. output.uv.xy = TRANSFORM_TEX(input.texcoord, _BaseMap);
  173. output.normalWS = normalInput.normalWS; //NormalizeNormalPerVertex(normalInput.normalWS);
  174. output.viewDirWS = viewDirWS;
  175. #ifdef _NORMALMAP
  176. float sign = input.tangentOS.w * GetOddNegativeScale();
  177. output.tangentWS = float4(normalInput.tangentWS.xyz, 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. //#ifdef _ADDITIONAL_LIGHTS
  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. output.projectionCoord = vertexInput.positionNDC;
  190. // Store Eye Depth
  191. output.projectionCoord.z = LinearEyeDepth(output.projectionCoord.z / output.projectionCoord.w, _ZBufferParams);
  192. float3 scale;
  193. float4x4 MV = mul(UNITY_MATRIX_V, UNITY_MATRIX_M);
  194. scale.x = length(float3(MV[0].x, MV[1].x, MV[2].x));
  195. scale.y = length(float3(MV[0].y, MV[1].y, MV[2].y));
  196. scale.z = length(float3(MV[0].z, MV[1].z, MV[2].z));
  197. output.scale = max(scale.x, max(scale.y, scale.z));
  198. return output;
  199. }
  200. //--------------------------------------
  201. // Fragment shader and functions
  202. inline void InitializeSurfaceData(
  203. float2 uv,
  204. float4 projectionCoord,
  205. half3 normalWS,
  206. half3 viewDirWS,
  207. float3 positionWS,
  208. float scale,
  209. half facing,
  210. out SurfaceDescription outSurfaceData)
  211. {
  212. #if defined(_BASEMAP)
  213. half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
  214. outSurfaceData.alpha = Alpha(albedoAlpha.a, _BaseColor, 0.0h);
  215. outSurfaceData.albedo = albedoAlpha.rgb * _BaseColor.rgb;
  216. #else
  217. outSurfaceData.alpha = _BaseColor.a;
  218. outSurfaceData.albedo = _BaseColor.rgb;
  219. #endif
  220. // Normal Map
  221. #if defined (_NORMALMAP)
  222. outSurfaceData.normalTS = SampleNormal(uv.xy, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale);
  223. #else
  224. outSurfaceData.normalTS = half3(0,0,1);
  225. #endif
  226. // Mask Map (Glass)
  227. #if defined(_MASKMAP)
  228. half4 maskSample = SAMPLE_TEXTURE2D(_MaskMap, sampler_MaskMap, uv.xy);
  229. #else
  230. half4 maskSample = half4(0,1,1,1);
  231. #endif
  232. // ///////////////////////////////////////
  233. // Refraction
  234. // Handle VFACE separatly for refractions
  235. normalWS *= facing;
  236. float NdotV = saturate(dot(normalWS, viewDirWS));
  237. #if defined(_GEOREFRACTIONS)
  238. half isThinShell = _IsThinShell
  239. #if defined(_MASKMAP)
  240. * maskSample.r
  241. #endif
  242. ;
  243. // Tweak ior to handle solid and thin shell refractions
  244. half myior = lerp(_IOR * 2.0h /* as we skip the 2nd, outgoing refraction*/, 1.0h, isThinShell);
  245. half3 refractWS = refract(-viewDirWS, normalWS, rcp(myior) );
  246. half rayLength = -dot(normalWS, refractWS);
  247. float3 rayOriginWS = positionWS + (refractWS * rayLength);
  248. float3 refractedPointWS = rayOriginWS + (refractWS * scale);
  249. // Calculate the sample UVs
  250. // Transform world space coordinates to clip space
  251. float4 screenUV = TransformWorldToHClip(refractedPointWS); // Clip space
  252. // Transform from clip space to NDC
  253. #if UNITY_UV_STARTS_AT_TOP
  254. screenUV.y = -screenUV.y;
  255. #endif
  256. screenUV *= rcp(screenUV.w); // Perspective
  257. // Final sample UVs
  258. screenUV.xy = screenUV.xy * 0.5f + 0.5f; // NDC
  259. #else
  260. float2 screenUV = projectionCoord.xy * rcp(projectionCoord.w);
  261. #endif
  262. #if defined(_NORMALMAP)
  263. screenUV.xy += (outSurfaceData.normalTS.xy * _BumpRefraction) * rcp(projectionCoord.w);
  264. #endif
  265. // Clamp at screen edges
  266. #if defined(_SCREENEDGEFADE)
  267. float2 coordCS = screenUV.xy * 2 - 1;
  268. float fadeRcpLength = _ScreenEdgeFade;
  269. float2 t = Remap10(abs(coordCS), fadeRcpLength, fadeRcpLength);
  270. float weight = Smoothstep01(t.x) * Smoothstep01(t.y);
  271. screenUV.xy = lerp(projectionCoord.xy/projectionCoord.w, screenUV.xy, weight);
  272. #endif
  273. // Fix screenUV for Single Pass Stereo Rendering
  274. #if defined(UNITY_SINGLE_PASS_STEREO)
  275. //screenUV.x = screenUV.x * 0.5f + (float)unity_StereoEyeIndex * 0.5f;
  276. screenUV.xy = UnityStereoTransformScreenSpaceTex(screenUV.xy);
  277. #endif
  278. // Check depth
  279. #if defined(_EXCLUDEFOREGROUND)
  280. #if defined(SHADER_API_GLES)
  281. float refractedSceneDepth = SAMPLE_DEPTH_TEXTURE_LOD(_CameraDepthTexture, sampler_CameraDepthTexture, screenUV.xy, 0);
  282. #else
  283. //float refractedSceneDepth = LOAD_TEXTURE2D_X_LOD(_CameraDepthTexture, _CameraDepthTexture_TexelSize.zw * screenUV.xy, 0).x;
  284. float refractedSceneDepth = LOAD_TEXTURE2D_X(_CameraDepthTexture, _CameraDepthTexture_TexelSize.zw * saturate(screenUV.xy)).x;
  285. #endif
  286. // TODO: add ortho support
  287. refractedSceneDepth = LinearEyeDepth(refractedSceneDepth, _ZBufferParams);
  288. float refractionOffsetMultiplier = saturate(refractedSceneDepth - projectionCoord.z);
  289. screenUV.xy = lerp(
  290. #if defined(UNITY_SINGLE_PASS_STEREO)
  291. UnityStereoTransformScreenSpaceTex(projectionCoord.xy/projectionCoord.w),
  292. #else
  293. projectionCoord.xy/projectionCoord.w,
  294. #endif
  295. screenUV.xy, refractionOffsetMultiplier);
  296. #endif
  297. // Just like separate texture + sampler syntax, inline sampler states are not supported on some platforms.
  298. // Currently they are implemented on Direct3D 11/12, PS4, XboxOne and Metal.
  299. #if defined(_EXCLUDEFOREGROUND)
  300. //half3 RefractionSample = SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, screenUV ).rgb;
  301. half3 RefractionSample = SAMPLE_TEXTURE2D_X(_CameraOpaqueTexture, sampler_LinearClamp, screenUV.xy).rgb;
  302. #else
  303. #if defined(SHADER_API_D3D11) || defined(SHADER_API_PS4) || defined(SHADER_API_XBOXONE) || defined(SHADER_API_METAL)
  304. //half3 RefractionSample = SAMPLE_TEXTURE2D(_CameraOpaqueTexture, my_linear_clamp_sampler, screenUV).rgb;
  305. half3 RefractionSample = SAMPLE_TEXTURE2D_X(_CameraOpaqueTexture, sampler_LinearClamp, screenUV.xy).rgb;
  306. #else
  307. //half3 RefractionSample = SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, screenUV ).rgb;
  308. half3 RefractionSample = SAMPLE_TEXTURE2D_X(_CameraOpaqueTexture, sampler_LinearClamp, screenUV.xy).rgb;
  309. #endif
  310. #endif
  311. // Tint glass
  312. half3 glassTint = outSurfaceData.albedo;
  313. outSurfaceData.emission = RefractionSample * glassTint * max(0.5h, 1.0h - F_Schlick(_SpecColor.rgb, NdotV)) * (1.0h - outSurfaceData.alpha);
  314. //outSurfaceData.emission = weight;
  315. // ///////////////////////////////////////
  316. #if defined(_MASKMAP)
  317. outSurfaceData.smoothness = _Smoothness * maskSample.a;
  318. #else
  319. outSurfaceData.smoothness = _Smoothness;
  320. #endif
  321. // Lerp between glass and opaque properties
  322. outSurfaceData.smoothness = lerp(outSurfaceData.smoothness, _SmoothnessBase, outSurfaceData.alpha);
  323. outSurfaceData.specular = lerp(_SpecColor.rgb, _SpecColorBase.rgb, outSurfaceData.alpha.xxx);
  324. outSurfaceData.metallic = 0;
  325. outSurfaceData.occlusion = 1;
  326. }
  327. void InitializeInputData(VertexOutput input, half3 normalTS, half3 viewDirWS, half facing, out InputData inputData)
  328. {
  329. // NOTE: inputData.normalWS and viewDirWS are already normalized
  330. inputData = (InputData)0;
  331. inputData.positionWS = input.positionWS;
  332. #if defined(_NORMALMAP)
  333. //half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
  334. normalTS.z *= facing;
  335. float sgn = input.tangentWS.w; // should be either +1 or -1
  336. float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz);
  337. inputData.normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, bitangent, input.normalWS.xyz));
  338. #else
  339. //half3 viewDirWS = input.viewDirWS;
  340. inputData.normalWS = input.normalWS * facing;
  341. #endif
  342. inputData.viewDirectionWS = viewDirWS;
  343. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  344. inputData.shadowCoord = input.shadowCoord;
  345. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  346. inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
  347. #else
  348. inputData.shadowCoord = float4(0, 0, 0, 0);
  349. #endif
  350. inputData.fogCoord = input.fogFactorAndVertexLight.x;
  351. inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
  352. inputData.bakedGI = SAMPLE_GI(input.lightmapUV, input.vertexSH, inputData.normalWS);
  353. }
  354. half4 LitPassFragment(VertexOutput input, half facing : VFACE) : SV_Target
  355. {
  356. UNITY_SETUP_INSTANCE_ID(input);
  357. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
  358. // We need viewDirWS and normalWS already in the surface function, so we get them up front
  359. half3 viewDirWS = SafeNormalize(input.viewDirWS);
  360. input.normalWS.xyz = NormalizeNormalPerPixel(input.normalWS.xyz);
  361. // Get the surface description
  362. SurfaceDescription surfaceData;
  363. InitializeSurfaceData(input.uv, input.projectionCoord, input.normalWS.xyz, viewDirWS, input.positionWS, input.scale, facing, surfaceData);
  364. // Prepare surface data (like bring normal into world space and get missing inputs like gi)
  365. // NOTE: viewDirWS and normalWS are already (almost) set up
  366. InputData inputData;
  367. InitializeInputData(input, surfaceData.normalTS, viewDirWS, facing, inputData);
  368. #if defined(_RIMLIGHTING)
  369. half rim = saturate(1.0h - saturate( dot(inputData.normalWS, inputData.viewDirectionWS) ) );
  370. half power = _RimPower;
  371. UNITY_BRANCH if(_RimFrequency > 0 ) {
  372. half perPosition = lerp(0.0h, 1.0h, dot(1.0h, frac(UNITY_MATRIX_M._m03_m13_m23) * 2.0h - 1.0h ) * _RimPerPositionFrequency ) * 3.1416h;
  373. power = lerp(power, _RimMinPower, (1.0h + sin(_Time.y * _RimFrequency + perPosition) ) * 0.5h );
  374. }
  375. surfaceData.emission += pow(rim, power) * _RimColor.rgb * _RimColor.a;
  376. #endif
  377. // Apply lighting
  378. half4 color = LuxLWRPTransparentFragmentPBR (
  379. inputData,
  380. surfaceData.albedo,
  381. surfaceData.metallic,
  382. surfaceData.specular,
  383. surfaceData.smoothness,
  384. surfaceData.occlusion,
  385. surfaceData.emission,
  386. surfaceData.alpha
  387. );
  388. #if defined(_FINALALPHA)
  389. color.a = max(_FinalAlpha, surfaceData.alpha);
  390. #endif
  391. #if defined (_ADDITIVE)
  392. // Add fog
  393. color.rgb = MixFogColor(color.rgb, half3(0,0,0), inputData.fogCoord);
  394. #else
  395. // Add fog
  396. color.rgb = MixFog(color.rgb, inputData.fogCoord);
  397. #endif
  398. return color;
  399. }
  400. ENDHLSL
  401. }
  402. // Meta -----------------------------------------------------
  403. Pass
  404. {
  405. Tags{"LightMode" = "Meta"}
  406. Cull Off
  407. HLSLPROGRAM
  408. // Required to compile gles 2.0 with standard srp library
  409. #pragma prefer_hlslcc gles
  410. #pragma vertex UniversalVertexMeta
  411. #pragma fragment UniversalFragmentMeta
  412. #define _SPECULAR_SETUP
  413. // First include all our custom stuff
  414. #include "Includes/Lux URP Glass Inputs.hlsl"
  415. //--------------------------------------
  416. // Fragment shader and functions
  417. inline void InitializeStandardLitSurfaceData(float2 uv, out SurfaceData outSurfaceData)
  418. {
  419. //half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
  420. outSurfaceData.alpha = 1;
  421. outSurfaceData.albedo = _BaseColor.rgb;
  422. outSurfaceData.metallic = 0;
  423. outSurfaceData.specular = _SpecColor.rgb;
  424. outSurfaceData.smoothness = _Smoothness;
  425. outSurfaceData.normalTS = half3(0,0,1);
  426. outSurfaceData.occlusion = 1;
  427. outSurfaceData.emission = 0;
  428. outSurfaceData.clearCoatMask = 0;
  429. outSurfaceData.clearCoatSmoothness = 0;
  430. }
  431. // Finally include the meta pass related stuff
  432. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"
  433. ENDHLSL
  434. }
  435. // End Passes -----------------------------------------------------
  436. }
  437. FallBack "Hidden/InternalErrorShader"
  438. CustomEditor "LuxURPCustomGlassShaderGUI"
  439. }