{"id":45,"date":"2024-03-11T17:11:11","date_gmt":"2024-03-11T09:11:11","guid":{"rendered":"http:\/\/chenglixue.top\/?p=45"},"modified":"2024-04-14T13:20:56","modified_gmt":"2024-04-14T05:20:56","slug":"unity-urp-%e9%a3%8e%e6%a0%bc%e5%8c%96%e6%b0%b4","status":"publish","type":"post","link":"http:\/\/chenglixue.top\/?p=45","title":{"rendered":"Unity URP \u98ce\u683c\u5316\u6c34"},"content":{"rendered":"<p><div class=\"has-toc have-toc\"><\/div><\/p>\n<h1>\u524d\u8a00<\/h1>\n<p>\u7b14\u8005\u66fe\u4f7f\u7528UE\u5b9e\u73b0\u8fc7\u4e00\u4e2a\u8f83\u4e3a\u5b8c\u6574\u7684\u5199\u5b9e<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.cnblogs.com\/chenglixue\/p\/17426704.html\" target=\"_blank\"  rel=\"nofollow\" >\u6c34\u6750\u8d28\u7cfb\u7edf<\/a>\uff0c\u4f46\u662f\u56e0\u4e3aUE\u7684\u7ba1\u7ebf\u662f\u5b9a\u6b7b\u7684\uff0c\u5bfc\u81f4\u9ad8\u5149\u65e0\u6cd5\u5b9e\u73b0\uff0c\u4e14\u540e\u6765\u505a\u7b14\u8bd5\u9898\u53d1\u73b0\u5173\u4e8e\u6c34\u7684\u4ea4\u4e92\u8fd8\u672a\u5b9e\u73b0\uff0c\u56e0\u6b64\u672c\u6587\u5c06\u5b9e\u73b0\u4e00\u4e2a\u5b8c\u6574\u7684\u98ce\u683c\u5316\u6c34<\/p>\n<h1>\u7ba1\u7ebf\u8bbe\u7f6e<\/h1>\n<ul>\n<li>\u6c34\u662f\u4e00\u79cd\u534a\u900f\u660e\u6750\u8d28\uff0c\u5b9a\u4e49\u65e0\u9700\u591a\u8bf4<\/p>\n<\/li>\n<li>\n<p>\u5b9e\u73b0<\/p>\n<pre><code class=\"line-numbers\">\"RenderType\"=\"Transparent\" \n\"Queue\" = \"Transparent\"\n\"IgnoreProjector\" = \"True\"\n<\/code><\/pre>\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/65929088c458853aef182de5.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/65929088c458853aef182de5.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<\/ul>\n<h1>\u6df1\u5ea6<\/h1>\n<ul>\n<li>\n<p>\u6211\u770b\u7f51\u4e0a\u5927\u591a\u6570\u6587\u7ae0\u7684\u6c34\u6df1\u90fd\u57fa\u4e8e\u76f8\u673a\u7684depth difference\uff0c\u8fd9\u6837\u5b9e\u73b0\u51fa\u6765\u7684\u4f53\u9a8c\u611f\u5e76\u4e0d\u597d\uff0c\u56e0\u4e3adepth\u4f1a\u968f\u76f8\u673a\u89c6\u89d2\u53d8\u5316\u800c\u53d8\u5316\uff0c\u6240\u4ee5\u8fd9\u91cc\u7b14\u8005\u9009\u62e9\u57fa\u4e8e\u4e16\u754c\u7a7a\u95f4y\u8f74\u7684difference<br \/>\n<img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/658bef1ac458853aef47e80e.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/658bef1ac458853aef47e80e.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<li>\n<p>\u5b9e\u73b0<\/p>\n<pre><code class=\"line-numbers\">\/\/ \u5ffd\u7565\u534a\u900f\u660e\u7269\u4f53\u3002\u7c7b\u4f3cscene depth\nfloat3 GetScenePos(float4 positionSS, float3 viewDirWS, float2 uv)\n{\n  float3 result = 0.f;\n\n  half depth = SampleSceneDepth(uv);\n  half sceneDepth = LinearEyeDepth(depth, _ZBufferParams);\n  result = -viewDirWS \/ positionSS.w * sceneDepth;\n  result += GetCameraPositionWS();\n\n  return result;\n}\n\n\/\/ \u53ef\u4ee5\u7406\u89e3\u4e3apixel y - scene y\nhalf GetDepthFade(float3 positionWS, float4 positionSS, float3 viewDirWS, float2 refractUV)\n{\n  half result = 0.h;\n\n  float3 scenePos = GetScenePos(positionSS, viewDirWS, refractUV);\n  result = (positionWS - scenePos).y;\n  result = saturate(result \/ _DepthFade);\n\n  return result;\n}\n<\/code><\/pre>\n<\/li>\n<li>\u6548\u679c<br \/>\n<img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/65bf9b03871b83018a467ecc.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/65bf9b03871b83018a467ecc.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<\/ul>\n<h1>\u989c\u8272<\/h1>\n<p>\u6709\u4e86\u6df1\u5ea6\u5c31\u53ef\u4ee5\u7528\u6df1\u5ea6\u6765\u5b9e\u73b0\u6c34\u7684\u989c\u8272\u4e86\uff0c\u8fd9\u91cc\u5b9e\u73b0\u4e86\u6d45\u6c34\u3001\u6df1\u6c34\u3001\u6d77\u5cb8\u7ebf\u7684\u989c\u8272<\/p>\n<ul>\n<li>\u601d\u8def\uff1a\u6839\u636e\u6df1\u5ea6\u5bf9\u6d45\u6c34\u989c\u8272\u548c\u6df1\u6c34\u989c\u8272\u8fdb\u884clerp\uff0c\u518d\u5bf9\u6d77\u5cb8\u7ebf\u8fdb\u884cfresnel lerp<\/p>\n<\/li>\n<li>\n<p>\u5b9e\u73b0<\/p>\n<pre><code class=\"line-numbers\">half4 GetSurfaceAlbedo(PSInput psInput, half depthFade)\n{\n  half4 result = half4(0.h, 0.h, 0.h, 0.h);\n\n  float horizonFrensel = Fresnel(psInput.normalWS, SafeNormalize(psInput.viewDirWS), _HorizonFresnelExp);\n\n  result = HSVLerp(_ShallowColor, _DeepColor, depthFade);\n  result = HSVLerp(result, _HorizonColor, horizonFrensel);\n\n  return saturate(result);\n}\n<\/code><\/pre>\n<p>\u4f17\u6240\u5468\u77e5RGB\u989c\u8272\u7a7a\u95f4\u7684\u8272\u5f69\u5e76\u4e0d\u5982HSV\u7a7a\u95f4\u7684\u8272\u5f69\u4e30\u5bcc\uff0c\u82e5\u60f3\u8981\u66f4\u597d\u5eb7\u7684\u989c\u8272\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u8f6c\u6362\u81f3HSV\u7a7a\u95f4\u8fdb\u884clerp<\/p>\n<pre><code class=\"line-numbers\">half3 RGBToHSV(half3 In)\n{\n  half4 K = half4(0.0, -1.0 \/ 3.0, 2.0 \/ 3.0, -1.0);\n  half4 P = lerp(half4(In.bg, K.wz), half4(In.gb, K.xy), step(In.b, In.g));\n  half4 Q = lerp(half4(P.xyw, In.r), half4(In.r, P.yzx), step(P.x, In.r));\n  half D = Q.x - min(Q.w, Q.y);\n  half E = 1e-10;\n  return half3(abs(Q.z + (Q.w - Q.y)\/(6.0 * D + E)), D \/ (Q.x + E), Q.x);\n}\n\nhalf3 HSVToRGB(half3 In)\n{\n  half4 K = half4(1.0, 2.0 \/ 3.0, 1.0 \/ 3.0, 3.0);\n  half3 P = abs(frac(In.xxx + K.xyz) * 6.0 - K.www);\n  return In.z * lerp(K.xxx, saturate(P - K.xxx), In.y);\n}\n\nhalf4 HSVLerp(half4 A, half4 B, half T)\n{\n  A.xyz = RGBToHSV(A.xyz);\n  B.xyz = RGBToHSV(B.xyz);\n\n  half t = T; \/\/ used to lerp alpha, needs to remain unchanged\n\n  half hue;\n  half d = B.x - A.x; \/\/ hue difference\n\n  if(A.x &gt; B.x)\n  {\n      half temp = B.x;\n      B.x = A.x;\n      A.x = temp;\n\n      d = -d;\n      T = 1-T;\n  }\n\n  if(d &gt; 0.5)\n  {\n      A.x = A.x + 1;\n      hue = (A.x + T * (B.x - A.x)) % 1;\n  }\n\n  if(d &lt;= 0.5) hue = A.x + T * d;\n\n  half sat = A.y + T * (B.y - A.y);\n  half val = A.z + T * (B.z - A.z);\n  half alpha = A.w + t * (B.w - A.w);\n\n  half3 rgb = HSVToRGB(half3(hue,sat,val));\n\n  return half4(rgb, alpha);\n}\n<\/code><\/pre>\n<\/li>\n<li>\u6548\u679c\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/65bfa5c9c458853aef32368f.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/65bfa5c9c458853aef32368f.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<\/ul>\n<h1>\u8868\u9762\u6d9f\u6f2a<\/h1>\n<ul>\n<li>\n<p>\u601d\u8def\uff1a\u4f7f\u7528normal map\u6765\u6a21\u62df\u51f9\u51f8\u611f\uff0c\u4e3a\u4e86\u9632\u6b62\u6d9f\u6f2a\u770b\u7740\u592a\u5047\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e24\u5f20normal map\u5e76blend<\/p>\n<\/li>\n<li>\n<p>\u5b9e\u73b0<\/p>\n<pre><code class=\"line-numbers\">float2 Panner(float2 uv, float time, half2 speed = half2(1.h, 1.h))\n{\n  return uv + time * speed;\n}\n\nhalf3 WhiteOutBlendNormal(half3 normal1, half3 normal2)\n{\n  half3 result = half3(0.h, 0.h, 0.h);\n\n  result = half3(normal1.xy + normal2.xy, normal1.z * normal2.z);\n  result = SafeNormalize(result);\n\n  return result;\n}\n\nhalf3 normalTS1 = UnpackNormalScale(SAMPLE_TEXTURE2D(_NormalTex, sampler_NormalTex, Panner(positionWS.xz \/ _Normal1Scale, _Time.y \/ 100, _Normal1Speed)), _NormalIntensity);\nhalf3 normalTS2 = UnpackNormalScale(SAMPLE_TEXTURE2D(_NormalTex, sampler_NormalTex, Panner(positionWS.xz \/ _Normal2Scale, _Time.y \/ 100, _Normal2Speed)), _NormalIntensity);\nsurfaceData.normalTS = WhiteOutBlendNormal(normalTS1, normalTS2);\n<\/code><\/pre>\n<\/li>\n<li>\u6548\u679c\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/65bfa748c458853aef394e4c.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/65bfa748c458853aef394e4c.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<\/ul>\n<h1>\u6298\u5c04<\/h1>\n<ul>\n<li>\n<p>\u601d\u8def\uff1a\u91c7\u6837Gradient Noise\u786e\u5b9a\u6270\u52a8\u7684UV\uff0c\u968f\u540e\u4f7f\u7528\u8fd9\u4e2auv\u5bf9Scene Color\u91c7\u6837<\/p>\n<\/li>\n<li>\n<p>\u5b9e\u73b0<\/p>\n<p>\u56e0\u4e3a\u8fd9\u79cd\u65b9\u6cd5\u548c\u57fa\u4e8enormal\u91c7\u6837Scene Color\u7684\u4e0d\u540c\uff0c\u5b83\u4f1a\u51fa\u73b0\u9519\u8bef\u7684\u60c5\u51b5(\u4e0d\u5728\u6c34\u4e2d\u7684\u90e8\u5206\u4e5f\u4f1a\u8fdb\u884c\u626d\u66f2)\uff0c\u6240\u4ee5\u9700\u8981\u77eb\u6b63\uff0c\u5177\u4f53\u601d\u8def\u5c31\u662f\u5224\u65ady difference\u662f\u5426\u5927\u4e8e\u7b49\u4e8e0<\/p>\n<pre><code class=\"line-numbers\">\/\/ \u751f\u6210Gradient Noise\nfloat2 GradientNoiseDir(float2 uv)\n{\n  uv = uv % 289;\n  float x = (34 * uv.x + 1) * uv.x % 289 + uv.y;\n  x = (34 * x + 1) * x % 289;\n  x = frac(x \/ 41) * 2 - 1;\n  return normalize(float2(x - floor(x + 0.5), abs(x) - 0.5));\n}\nfloat GradientNoise(float2 uv)\n{\n  float2 iuv = floor(uv);\n  float2 fuv = frac(uv);\n  float d00 = dot(GradientNoiseDir(iuv), fuv);\n  float d01 = dot(GradientNoiseDir(iuv + float2(0, 1)), fuv - float2(0, 1));\n  float d10 = dot(GradientNoiseDir(iuv + float2(1, 0)), fuv - float2(1, 0));\n  float d11 = dot(GradientNoiseDir(iuv + float2(1, 1)), fuv - float2(1, 1));\n  fuv = fuv * fuv * fuv * (fuv * (fuv * 6 - 15) + 10);\n  return lerp(lerp(d00, d01, fuv.y), lerp(d10, d11, fuv.y), fuv.x);\n}\nfloat FinalGradientNoise(float2 uv, float scale = 1.f)\n{\n  return GradientNoise(uv * scale) + 0.5f;\n}\n\n\/\/ \u6c42\u5f97\u6298\u5c04\u540e\u7684uv\nfloat2 GetRefractUV(float3 positionWS, float4 positionSS, float2 positionSSNor, float3 viewDirWS, float2 uv)\n{\n  float2 result = float2(0.f, 0.f);\n  _RefractIntensity = max(0.f, _RefractIntensity) \/ 100.h;\n  _RefractTiling = max(0.f, _RefractTiling) \/ 100.h;\n\n  result += Panner(uv * rcpFastNR1(_RefractTiling), _Time.y, float2(_RefractSpeed, _RefractSpeed));\n  result = FinalGradientNoise(result);\n  result = RemapFloat2(result, float2(0, 1), float2(-1, 1));\n  result *= _RefractIntensity;\n  result += positionSSNor;\n\n  \/\/ \u907f\u514d\u4e0d\u8be5\u51fa\u73b0(\u9519\u8bef)\u7684\u6298\u5c04\u6548\u679c\n  float3 scenePos = GetScenePos(positionSS, viewDirWS, result);\n  result = (positionWS - scenePos).y &gt;= 0.f ? result : positionSSNor;\n\n  return result;\n}\n\n\/\/ \u6c42\u5f97\u6298\u5c04\u56fe\u50cf\nhalf3 GetRefract(float2 refractUV)\n{\n  half3 result = half3(0.h, 0.h, 0.h);\n\n  half3 sceneColor = SampleSceneColor(refractUV);\n\n  result = sceneColor;\n\n  return result;\n}\n<\/code><\/pre>\n<p>\u8fd9\u91cc\u4e0d\u80fd\u5c06\u6298\u5c04\u56fe\u50cf\u548c\u4e4b\u524d\u6c42\u5f97\u56fe\u50cf\u7b80\u5355\u7684\u5408\u5e76\uff0c\u7b14\u8005\u91c7\u7528\u7684\u662f\u8fdb\u884clerp<\/p>\n<pre><code class=\"line-numbers\">half3 refractColor = GetRefract(albedo, refractUV);\nsurfaceData.albedo = lerp(albedo.rgb, refractColor, 0.5);\n<\/code><\/pre>\n<\/li>\n<li>\u6548\u679c\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/65bfaa43c458853aef468aa9.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/65bfaa43c458853aef468aa9.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<\/ul>\n<h1>\u53cd\u5c04<\/h1>\n<h2>\u5b9e\u73b0\u53cd\u5c04<\/h2>\n<ul>\n<li>\n<p>\u56e0\u4e3a\u5e73\u9762\u53cd\u5c04\u4f7f\u7528\u4e00\u4e2a\u6444\u50cf\u673a\u4ece\u955c\u50cf\u89d2\u5ea6\u6e32\u67d3\u573a\u666f\u5230RenderTexture\u4e0a\uff0c\u518d\u5c06\u7ed3\u679c\u5408\u5e76\u81f3\u53cd\u5c04\u5e73\u9762\uff0c\u5f00\u9500\u4e0d\u5c0f\uff0c\u9002\u7528\u4e8ePC\u7aef\uff0c\u8fd9\u79cd\u65b9\u5f0f\u5b9e\u73b0\u7684<span class=\"text-highlighted-inline\" style=\"background-color: #fffd38;\">\u53cd\u5c04\u6548\u679c\u5341\u5206\u51c6\u786e<\/span>\uff0c\u4f46\u7f3a\u70b9\u662f<span class=\"text-highlighted-inline\" style=\"background-color: #fffd38;\">\u9700\u8981\u91cd\u65b0\u6e32\u67d3\u4e00\u6b21\u573a\u666f<\/span>\uff0c\u60f3\u60f3\u5982\u679c\u6709\u591a\u4e2a\u955c\u9762\uff0c\u90a3\u5f00\u9500\u7740\u5b9e\u53d7\u4e0d\u4e86\uff0c\u6240\u4ee5\u7b14\u8005\u9009\u62e9\u4f7f\u7528\u5bf9\u79fb\u52a8\u7aef\u53cb\u597d\u7684\u5c4f\u5e55\u7a7a\u95f4\u5e73\u9762\u53cd\u5c04(ssrp)\uff0c\u539f\u7406\u662f<span class=\"text-highlighted-inline\" style=\"background-color: #fffd38;\">\u5728\u5c4f\u5e55\u7a7a\u95f4\u4e2d\u8ba1\u7b97\u955c\u9762\u53cd\u5c04\uff0c\u5f00\u9500\u5f88\u4f4e<\/span>\uff0c\u4f46\u6548\u679c\u4e0d\u662f\u5f88\u51c6\u786e\uff0c<span class=\"text-highlighted-inline\" style=\"background-color: #fffd38;\">\u53ea\u80fd\u53cd\u5c04\u5c4f\u5e55\u4e2d\u7684\u50cf\u7d20\uff0c\u5bb9\u6613\u9732\u9985<\/span>\u3002\u5bf9\u4e8e\u6c34\u9762\u6765\u8bf4\uff0cssrp\u8db3\u4ee5<\/p>\n<\/li>\n<li>\n<p>\u5b9e\u73b0<\/p>\n<ol>\n<li>\u56e0\u4e3assrp\u57fa\u4e8e\u5c4f\u5e55\u7a7a\u95f4\uff0c\u53ef\u4ee5\u5c06\u5176\u770b\u4f5c\u4e00\u79cd\u540e\u5904\u7406\u6280\u672f\uff0cVolume\u4ee3\u7801\u5982\u4e0b\n<pre><code class=\"line-numbers\">using UnityEngine;\nusing UnityEngine.Rendering;\n\nnamespace UnityEditor.Rendering.Universal\n{\n [SerializeField]\n public class SSPRVolume : VolumeComponent\n {\n     [Tooltip(\"\u662f\u5426\u542f\u7528SSPR\")]\n     public BoolParameter m_Enable = new BoolParameter(false);\n\n     [Tooltip(\"\u662f\u5426\u542f\u7528HDR\")] \n     public BoolParameter m_EnableHDR = new BoolParameter(false);\n\n     [Tooltip(\"\u53cd\u5c04\u5e73\u9762\u5206\u8fa8\u7387\")]\n     public ClampedIntParameter m_RTSize = new ClampedIntParameter(512, 128, 1024, false);\n\n     [Tooltip(\"\u53cd\u5c04\u5e73\u9762\u6df1\u5ea6\")]\n     public FloatParameter m_ReflectPlaneHeight = new FloatParameter(0.5f, false);\n\n     [Tooltip(\"\u6839\u636e\u8ddd\u79bb\u5bf9\u5c4f\u5e55\u8fb9\u7f18\u8fdb\u884c\u5e73\u6ed1\")]\n     public ClampedFloatParameter m_FadeOutEdge = new ClampedFloatParameter(0.5f, 0f, 1f, false);\n\n     [Tooltip(\"\u63a7\u5236\u5206\u8fa8\u7387\")] \n     public ClampedIntParameter m_Downsample = new ClampedIntParameter(1, 1, 5);\n\n     [Tooltip(\"\u6a21\u7cca\u7b97\u6cd5\u5faa\u73af\u6b21\u6570\uff0c\u8d8a\u9ad8\u6548\u679c\u8d8a\u597d\")]\n     public ClampedIntParameter m_PassLoop = new ClampedIntParameter(1, 1, 5);\n\n     [Tooltip(\"\u6a21\u7cca\u5f3a\u5ea6\")] \n     public ClampedFloatParameter m_BlurIntensity = new ClampedFloatParameter(1, 0, 10);\n\n     public bool IsActive() =&gt; m_Enable.value;\n     public bool IsTileCompatible() =&gt; false;\n }\n}\n<\/code><\/pre>\n<\/li>\n<li>compute shader<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<p>\u53c2\u6570<\/p>\n<pre><code class=\"line-numbers\">#define THREADCOUNTX 8\n#define THREADCOUNTY 8\n#define THREADCOUNTZ 1\n\nRWTexture2D&lt;half4&gt; _ResultRT;  \/\/ \u53cd\u5c04\u540e\u7684RT\nRWTexture2D&lt;half&gt; _ResultDepthRT;  \/\/ \u53cd\u5c04\u540e\u7684depth\nTexture2D&lt;float4&gt; _ScreenColorTex;    \/\/ scene color\nTexture2D&lt;float4&gt; _ScreenDepthTex;   \/\/ scene depth\n\nfloat2 _RTSize; \/\/ \u53cd\u5c04\u540e\u7684RT\u5206\u8fa8\u7387\nfloat _ReflectPlaneHeight;  \/\/  \u53cd\u5c04\u5e73\u9762\u9ad8\u5ea6(\u57fa\u4e8escreen space uv)\nfloat _FadeOutEdge; \/\/ \u5c4f\u5e55\u8fb9\u7f18\u7684\u8870\u51cf\u7a0b\u5ea6\nfloat _BlurIntensity;   \/\/ DualBlur \u6a21\u7cca\u5f3a\u5ea6\n\nSamplerState PointClampSampler;    \/\/ \u70b9\u91c7\u6837\nSamplerState LinearClampSampler;   \/\/ \u7ebf\u6027\u91c7\u6837\n<\/code><\/pre>\n<\/li>\n<li>\u521d\u59cb\u5316\n<p>\u5c06RT\u548cDepth\u6e050<\/p>\n<pre><code class=\"line-numbers\">[numthreads(THREADCOUNTX, THREADCOUNTY, THREADCOUNTZ)]\nvoid ClearRT(uint3 id : SV_DispatchThreadID)\n{\n   _ResultRT[id.xy] = half4(0.f, 0.f, 0.f, 0.f);\n   _ResultDepthRT[id.xy] = half4(0.f, 0.f, 0.f, 0.f);\n}\n<\/code><\/pre>\n<\/li>\n<li>SSRP\u8ba1\u7b97\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/658be991c458853aef37d01a.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/658be991c458853aef37d01a.jpg\" alt=\"\" \/><\/p><\/noscript>\n<ul>\n<li>\u91cd\u5efa\u4e16\u754c\u5750\u6807\n<pre><code class=\"line-numbers\">[numthreads(THREADCOUNTX, THREADCOUNTY, THREADCOUNTZ)]\nvoid CSMain (uint3 id : SV_DispatchThreadID)\n{\n float2 uvSS = id.xy \/ _RTSize;  \/\/ [0,RTSize-1] -&gt; screen [0,1] uv\n\n float posNDCZ = _ScreenDepthTex.SampleLevel(PointClampSampler, uvSS, 0.f).r;    \/\/ raw depth\n\n float3 absoluteWolrdPos = ComputeWorldSpacePosition(uvSS, posNDCZ, UNITY_MATRIX_I_VP);  \/\/ \u6c42\u5f97\u91cd\u5efa\u540e\u7684\u4e16\u754c\u5750\u6807\n}\n<\/code><\/pre>\n<\/li>\n<li>\u91cd\u5efa\u53cd\u5c04\u540e\u7684\u4e16\u754c\u5750\u6807\n<pre><code class=\"line-numbers\">if(absoluteWolrdPos.y &lt; _ReflectPlaneHeight) return;    \/\/ \u4e22\u5f03\u4f4d\u4e8e\u5e73\u9762\u4e0b\u65b9\u7684\u50cf\u7d20\nfloat3 reflectPosWS = absoluteWolrdPos;\nreflectPosWS.y = -(reflectPosWS.y - _ReflectPlaneHeight) + _ReflectPlaneHeight; \/\/ \u5148\u5c06\u5750\u6807\u51cf\u53bb_ReflectPlaneHeight\uff0c\u4f7f\u5176\u57fa\u4e8ey = 0\u8fdb\u884c\u7ffb\u8f6c(\u53d6\u8d1f)\n<\/code><\/pre>\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/658be9a5c458853aef380c5d.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/658be9a5c458853aef380c5d.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<li>\n<p>\u6784\u5efa\u5e76\u6d4b\u8bd5\u5c4f\u5e55\u7a7a\u95f4uv<\/p>\n<pre><code class=\"line-numbers\">\/\/ \u56e0\u4e3a\u91cd\u5efa\u540e\u7684\u5c4f\u5e55\u7a7a\u95f4uv\u53ef\u4ee5\u8d85\u51fa\u5c4f\u5e55\u8303\u56f4\uff0c\u9700\u8981\u8fdb\u884c\u6d4b\u8bd5\nfloat4 reflectPosCS = mul(UNITY_MATRIX_VP, float4(reflectPosWS, 1.f));   \/\/ posWS -&gt; posCS\nfloat2 reflectPosNDCxy = reflectPosCS.xy \/ reflectPosCS.w;  \/\/ posCS -&gt; posNDC\nif(abs(reflectPosNDCxy.x) &gt; 1.f || abs(reflectPosNDCxy.y) &gt; 1.f) return; \/\/ uv\u8303\u56f4\u5728[0,1]\nfloat2 reflectPosSSxy = reflectPosNDCxy * 0.5 + 0.5;   \/\/ ndc-&gt;ss\n\n\/\/ dx\u5e73\u53f0uv\u5750\u6807\u8d77\u70b9\u5728\u4e0a\u65b9\n#if defined UNITY_UV_STARTS_AT_TOP\n reflectPosSSxy.y = 1 - reflectPosSSxy.y;\n#endif\n\nuint2 reflectSSUVID = reflectPosSSxy * _RTSize;  \/\/ \u6839\u636e\u6b63\u786e\u7684\u5c4f\u5e55uv\u8ba1\u7b97\u5f97\u5230\u65b0\u7684thread id\n<\/code><\/pre>\n<\/li>\n<li>\u8f93\u51fa\n<pre><code class=\"line-numbers\">_ResultRT[reflectSSUVID] = float4(_ScreenColorTex.SampleLevel(LinearClampSampler, uvSS, 0).rgb, 1);\n<\/code><\/pre>\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/658be9bbc458853aef384b40.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/658be9bbc458853aef384b40.jpg\" alt=\"\" \/><\/p><\/noscript>\n<p>\u53ef\u4ee5\u770b\u5230\u8fd9\u5b58\u5728\u4e00\u5b9a\u7684\u906e\u6321\u95ee\u9898\uff08<span class=\"text-highlighted-inline\" style=\"background-color: #fffd38;\">\u7269\u4f53\u7684\u53cd\u5c04\u6e32\u67d3\u987a\u5e8f\u9519\u8bef<\/span>\uff09\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u9020\u6210\u8fd9\u4e00\u73b0\u8c61\u7684\u539f\u56e0\u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u50cf\u7d20\u53cd\u5c04\u540e\u90fd\u4f4d\u4e8e\u540c\u4e00UV<\/p>\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/658be9d1c458853aef388b93.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/658be9d1c458853aef388b93.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<li>\n<p>\u6df1\u5ea6\u987a\u5e8f\u77eb\u6b63<\/p>\n<p>\u5f88\u663e\u7136\uff0c\u8fd9\u91cc\u53ef\u4ee5\u7528\u5230\u6df1\u5ea6\u7f13\u51b2\u533a\uff0c\u5199\u5165\u6df1\u5ea6\u66f4\u5c0f\u7684\u50cf\u7d20(dx\u5e73\u53f0\u56e0\u4e3az\u503c\u7ffb\u8f6c\uff0c\u9700\u8981\u5199\u5165\u6df1\u5ea6\u66f4\u5927\u7684\u50cf\u7d20)\u3002\u8fd9\u6837\u4f1a\u5bfc\u81f4\u65e0\u6cd5\u53cd\u5c04sky box\uff0c\u540e\u7eed\u9700\u8981\u5728PS\u4e2d\u5408\u5e76<\/p>\n<pre><code class=\"line-numbers\">#if defined UNITY_REVERSED_Z\nif(reflectPosCS.z \/ reflectPosCS.w &lt;= _ResultDepthRT[reflectSSUVID]) return;\n#else\nif(rePosCS.z \/ rePosCS.w &gt;= _ResultDepthRT[reSSUVID]) return;\n#endif\n\n_ResultDepthRT[reflectSSUVID] = reflectPosCS.z \/ reflectPosCS.w;\n<\/code><\/pre>\n<\/li>\n<li>\u8fb9\u7f18\u7f3a\u5931\n<p>\u5728\u67d0\u4e9b\u89c6\u89d2\u4e0b\uff0c\u82e5\u53cd\u5c04\u6240\u9700\u8981\u7684\u4fe1\u606f\u5728\u6e32\u67d3\u540e\u7684RT\u5916\uff0c\u4f1a\u751f\u6210\u4e0d\u5c11\u7a7a\u767d\u50cf\u7d20\uff0c\u8fd9\u91cc\u6709\u4e24\u79cd\u89e3\u51b3\u529e\u6cd5\uff1a\u62c9\u4f38uv\u548c2d sdf<\/p>\n<p>\u8003\u8651\u5230\u6027\u80fd\uff0c\u7b14\u8005\u4f7f\u7528SDF\u3002\u5177\u4f53\u539f\u7406\u662f\uff1a<span class=\"text-highlighted-inline\" style=\"background-color: #fffd38;\">sdf \u4f5c\u4e3a\u4e0d\u900f\u660e\u5ea6<\/span><\/p>\n<pre><code class=\"line-numbers\">\/\/ \u8ba1\u7b97pixel\u5230\u5c4f\u5e55\u8fb9\u7f18\u7684\u8ddd\u79bb\nfloat SDF(float2 pos)\n{\n float2 distance = abs(pos) - float2(1, 1);\n return length(max(0.f, distance) - min(max(distance.x, distance.y), 0.f));\n}\n\nfloat mask = SDF(uvSS * 2.f - 1.f);\nmask = smoothstep(0.f, _FadeOutEdge, abs(mask));   \/\/ \u505a\u4e00\u4e2a\u5e73\u6ed1\uff0c\u907f\u514d\u751f\u786c\n_ResultRT[reflectSSUVID] = float4(_ScreenColorTex.SampleLevel(LinearClampSampler, uvSS, 0).rgb, mask);\n<\/code><\/pre>\n<\/li>\n<li>\u586b\u5145\u7a7a\u6d1e\n<p>\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u53cd\u5c04\u540e\u7684\u5e73\u9762\u4f1a\u5b58\u5728\u8bb8\u591a\u9ed1\u70b9\u7a7a\u6d1e\u3002\u8fd9\u662f\u56e0\u4e3a<span class=\"text-highlighted-inline\" style=\"background-color: #fffd38;\">\u8ba1\u7b97\u4e16\u754c\u5750\u6807\u8fdb\u884c\u4e86\u900f\u89c6\u6295\u5f71\u7684\u8ba1\u7b97<\/span>(\u8fd1\u5927\u8fdc\u5c0f)\uff0c\u5bfc\u81f4\u6700\u540e\u7684\u50cf\u7d20\u7d22\u5f15\u8fdb\u884c\u4e86\u504f\u79fb(\u5982\u672c\u8be5\u6e32\u67d3\u5230(1,1)\u7684\uff0c\u5374\u6e32\u67d3\u5230(1,2))<\/p>\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/658be9dfc458853aef38b575.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/658be9dfc458853aef38b575.jpg\" alt=\"\" \/><\/p><\/noscript>\n<p>\u89e3\u51b3\u65b9\u6cd5\u6709\u4e24\u4e2a\uff1a\u8ba1\u7b97\u50cf\u7d20\u660e\u5ea6 \u548c \u6839\u636e\u50cf\u7d20\u7684\u900f\u660e\u5ea6\uff0c\u8fd9\u91cc\u7b14\u8005\u9009\u62e9\u900f\u660e\u5ea6<\/p>\n<pre><code class=\"line-numbers\">[numthreads(THREADCOUNTX, THREADCOUNTY, THREADCOUNTZ)]\nvoid FillHoles (uint3 id : SV_DispatchThreadID)\n{\n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \/\/ \n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n float4 center = _ResultRT[id.xy];\n float4 top = _ResultRT[id.xy + uint2(0, 1)];\n float4 bottom = _ResultRT[id.xy + uint2(0, -1)];\n float4 right = _ResultRT[id.xy + uint2(1, 0)];\n float4 left = _ResultRT[id.xy + uint2(-1, 0)];\n\n \/\/ \u67e5\u627e\u4e0d\u662f\u7a7a\u6d1e\u7684pixel\n float4 best = center;\n best = top.a &gt; best.a + 0.5 ? top : best;\n best = bottom.a &gt; best.a + 0.5 ? bottom : best;\n best = right.a &gt; best.a + 0.5 ? right : best;\n best = left.a &gt; best.a + 0.5 ? left : best;\n\n \/\/ \u586b\u5145\u7a7a\u6d1e\n _ResultRT[id.xy] = best.a &gt; center.a + 0.5 ? best : center;\n _ResultRT[id.xy + uint2(0, 1)] = best.a &gt; top.a + 0.5 ? best : top;\n _ResultRT[id.xy + uint2(0, -1)] = best.a &gt; bottom.a + 0.5 ? best : bottom;\n _ResultRT[id.xy + uint2(1, 0)] = best.a &gt; right.a + 0.5 ? best : right;\n _ResultRT[id.xy + uint2(-1, 0)] = best.a &gt; left.a + 0.5 ? best : left;\n}\n<\/code><\/pre>\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/658be9f4c458853aef38f153.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/658be9f4c458853aef38f153.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<li>\n<p>\u95ea\u70c1<\/p>\n<p>\u6ca1\u6709\u627e\u5230\u597d\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u5bf9\u4e8e\u6c34\u4f53\u53ef\u4ee5\u4f7f\u7528\u6298\u5c04\u6765\u906e\u7f9e<\/p>\n<\/li>\n<li>\n<p>skybox \u622a\u65ad<\/p>\n<p>\u76ee\u524d\u7684\u5b9e\u73b0\u8fd8\u5b58\u5728\u4e00\u4e2a\u95ee\u9898\uff1a\u5f53\u89c2\u5bdf\u89d2\u5ea6\u8fc7\u4e8e\u4f4e\u65f6\u4f1a\u7ed8\u5236\u622a\u65ad\u7684skybox<br \/>\n<img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/658bea0dc458853aef3949a9.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/658bea0dc458853aef3949a9.jpg\" alt=\"\" \/><\/p><\/noscript>\n<ul>\n<li>\u89e3\u51b3\u4e4b\u9053\uff1a\u8df3\u8fc7skybox<\/li>\n<\/ul>\n<pre><code class=\"line-numbers\">void CSMain (uint3 id : SV_DispatchThreadID)\n{\n   float2 uvSS = id.xy \/ _RTSize;  \/\/ [0,RTSize-1] -&gt; screen [0,1] uv\n   float posNDCZ = _ScreenDepthTex.SampleLevel(PointClampSampler, uvSS, 0.f).r;    \/\/ raw depth\n   if(Linear01Depth(posNDCZ, _ZBufferParams) &gt; 0.99) return; \n}\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol start=\"3\">\n<li>Render Feature<\/li>\n<\/ol>\n<p>\u53cd\u5c04\u662f\u6709\u4e00\u5b9a\u7684\u6a21\u7cca\u6548\u679c\u7684\uff0c\u8fd9\u91cc\u4f7f\u7528Dual Blur<\/p>\n<pre><code class=\"line-numbers\">using System;\nusing UnityEngine;\nusing UnityEngine.Rendering;\nusing UnityEngine.Rendering.Universal;\nusing UnityEditor.Rendering.Universal;\n\npublic class SSPRPassFeature : ScriptableRendererFeature\n{\n  [System.Serializable]\n  public class PassSetting\n  {\n      [Tooltip(\"\u663e\u793a\u4e8eframe debugger\")]\n      public readonly string m_ProfilerTag = \"SSRP Pass\";\n\n      [Tooltip(\"Pass\u6267\u884c\u4f4d\u7f6e\")]\n      public RenderPassEvent passEvent = RenderPassEvent.AfterRenderingTransparents;\n\n      [Tooltip(\"compute shader\")]\n      public ComputeShader CS = null;\n\n      [Tooltip(\"Pixel Shader\")]\n      public Material material = null;\n  }\n\n  class SSPRRenderPass : ScriptableRenderPass\n  {\n      \/\/ profiler tag will show up in frame debugger\n      private const string m_ProfilerTag = \"SSPR Pass\";\n\n      \/\/ \u7528\u4e8e\u5b58\u50a8pass setting\n      private PassSetting m_passSetting;\n      private SSPRVolume m_SSPRVolume;\n\n      private ComputeShader m_CS;\n      private Material m_Material;\n\n      \/\/ \u53cd\u5c04RT\u7684\u5206\u8fa8\u7387\n      private int RTSizeWidth;\n      private int RTSizeHeight;\n\n      struct RTID\n      {\n          public static RenderTargetIdentifier m_ResultRT;\n          public static RenderTargetIdentifier m_ResultDepthRT;\n          public static RenderTargetIdentifier m_TempRT;\n      }\n\n      struct ShaderID\n      {\n          public static readonly int RTSizeID = Shader.PropertyToID(\"_RTSize\");\n          public static readonly int ReflectPlaneHeightID = Shader.PropertyToID(\"_ReflectPlaneHeight\");\n          public static readonly int FadeOutEdgeID = Shader.PropertyToID(\"_FadeOutEdge\");\n          public static readonly int ReflectColorRTID = Shader.PropertyToID(\"_ResultRT\");\n          public static readonly int ResultDepthRTID = Shader.PropertyToID(\"_ResultDepthRT\");\n          public static readonly int SceneColorRTID = Shader.PropertyToID(\"_ScreenColorTex\");\n          public static readonly int SceneDepthRTID = Shader.PropertyToID(\"_ScreenDepthTex\");\n\n          public static readonly int BlurIntensityID = Shader.PropertyToID(\"_BlurIntensity\");\n          public static readonly int TempRTID = Shader.PropertyToID(\"_TempRT\");\n      }\n      private struct BlurLevelShaderID\n      {\n          internal int downLevelID;\n          internal int upLevelID;\n      }\n      private BlurLevelShaderID[] blurLevel;\n      private static int m_maxBlurLevel = 16;\n\n      struct Dispatch\n      {\n          \/\/ \u7ebf\u7a0b\u7ec4id\n          public static int ThreadGroupCountX;\n          public static int ThreadGroupCountY;\n          public static int ThreadGroupCountZ;\n          \/\/ \u7ebf\u7a0bid\n          public static int ThreadCountX;\n          public static int ThreadCountY;\n          public static int ThreadCountZ;\n      }\n\n      struct Kernal\n      {\n          public static int ClearRT;\n          public static int CSMain;\n          public static int FillHoles;\n      }\n\n      \/\/ \u7528\u4e8e\u8bbe\u7f6ematerial \u5c5e\u6027\n      public SSPRRenderPass(SSPRPassFeature.PassSetting passSetting) \n      {\n          this.m_passSetting = passSetting;\n\n          renderPassEvent = m_passSetting.passEvent;\n\n          this.m_CS = m_passSetting.CS;\n          this.m_Material = m_passSetting.material;\n\n          Kernal.ClearRT = m_CS.FindKernel(\"ClearRT\");\n          Kernal.CSMain = m_CS.FindKernel(\"CSMain\");\n          Kernal.FillHoles = m_CS.FindKernel(\"FillHoles\");\n      }\n\n      public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)\n      {\n          \/\/ \u83b7\u53d6\u5b9a\u4e49\u7684volume\n          var POSTStack = VolumeManager.instance.stack;\n          m_SSPRVolume = POSTStack.GetComponent&lt;SSPRVolume&gt;();\n\n          float aspect = (float)Screen.height \/ Screen.width;   \/\/ \u5c4f\u5e55\u5206\u8fa8\u7387\n          \/\/ \u7ebf\u7a0b\u5bf9\u5e94compute shader\u4e2d\u7684\u7ebf\u7a0b\u6570\n          Dispatch.ThreadCountX = 8;\n          Dispatch.ThreadCountY = 8;\n          Dispatch.ThreadCountZ = 1;\n          \/\/ \u4f7f\u5f97\u4e00\u4e2a\u7ebf\u7a0b\u5bf9\u5e94\u4e00\u4e2auv\n          Dispatch.ThreadGroupCountY = m_SSPRVolume.m_RTSize.value \/ Dispatch.ThreadCountY;    \/\/ RT\u9ad8\u5ea6\n          Dispatch.ThreadGroupCountX = Mathf.RoundToInt(Dispatch.ThreadGroupCountY \/ aspect); \/\/ RT \u5bbd\u5ea6\n          Dispatch.ThreadGroupCountZ = 1;\n          \/\/ \u53cd\u5c04\u9762\u7684\u5206\u8fa8\u7387\u5927\u5c0f\n          this.RTSizeWidth = Dispatch.ThreadGroupCountX * Dispatch.ThreadCountX;\n          this.RTSizeHeight = Dispatch.ThreadGroupCountY * Dispatch.ThreadCountY;\n\n          \/\/ alpha\u4f5c\u4e3amask\n          RenderTextureDescriptor descriptor = new RenderTextureDescriptor(this.RTSizeWidth, this.RTSizeHeight, RenderTextureFormat.ARGB32);\n          if (m_SSPRVolume.m_EnableHDR.value == true)\n          {\n              \/\/ \u6bcf\u4f4d16\u5b57\u8282\uff0c\u652f\u6301HDR\n              descriptor.colorFormat = RenderTextureFormat.ARGBHalf;\n          }\n          descriptor.enableRandomWrite = true;    \/\/ \u7528\u4e8eD3D\u7684UAV(\u65e0\u5e8f\u89c6\u56fe)\n\n          \/\/ \u7533\u8bf7RT\n          cmd.GetTemporaryRT(ShaderID.ReflectColorRTID, descriptor);\n          RTID.m_ResultRT = new RenderTargetIdentifier(ShaderID.ReflectColorRTID);\n          descriptor.colorFormat = RenderTextureFormat.R16;    \/\/ \u6df1\u5ea6\u56fe\u53ea\u6709r channel\n          cmd.GetTemporaryRT(ShaderID.ResultDepthRTID, descriptor);\n          RTID.m_ResultDepthRT = new RenderTargetIdentifier(ShaderID.ResultDepthRTID);\n\n          blurLevel = new BlurLevelShaderID[m_maxBlurLevel];\n          for (int t = 0; t &lt; m_maxBlurLevel; ++t)\n          {\n              blurLevel[t] = new BlurLevelShaderID\n              {\n                  downLevelID = Shader.PropertyToID(\"_BlurMipDown\" + t),\n                  upLevelID = Shader.PropertyToID(\"_BlurMipU\" + t)\n              };\n          }\n      }\n\n      public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)\n      {\n          if (m_CS == null)\n          {\n              Debug.LogError(\"Custom:SSPR compute shader missing\");\n          }\n\n          if (m_SSPRVolume.m_Enable.value == true)\n          {\n              \/\/ Grab a command buffer. We put the actual execution of the pass inside of a profiling scope\n              CommandBuffer cmd = CommandBufferPool.Get();\n\n              using (new ProfilingScope(cmd, new ProfilingSampler(m_ProfilerTag)))\n              {\n                  cmd.SetComputeTextureParam(this.m_CS, Kernal.ClearRT, ShaderID.ReflectColorRTID, RTID.m_ResultRT);\n                  cmd.SetComputeTextureParam(this.m_CS, Kernal.ClearRT, ShaderID.ResultDepthRTID, RTID.m_ResultDepthRT);\n                  cmd.DispatchCompute(this.m_CS, Kernal.ClearRT, Dispatch.ThreadGroupCountX, Dispatch.ThreadGroupCountY, Dispatch.ThreadGroupCountZ);\n\n                  cmd.SetComputeVectorParam(this.m_CS, ShaderID.RTSizeID, new Vector2(this.RTSizeWidth, this.RTSizeHeight));\n                  cmd.SetComputeFloatParam(this.m_CS, ShaderID.ReflectPlaneHeightID, m_SSPRVolume.m_ReflectPlaneHeight.value);\n                  cmd.SetComputeFloatParam(this.m_CS, ShaderID.FadeOutEdgeID, m_SSPRVolume.m_FadeOutEdge.value);\n                  cmd.SetComputeTextureParam(this.m_CS, Kernal.CSMain, ShaderID.ReflectColorRTID, RTID.m_ResultRT);\n                  cmd.SetComputeTextureParam(this.m_CS, Kernal.CSMain, ShaderID.ResultDepthRTID, RTID.m_ResultDepthRT);\n                  cmd.SetComputeTextureParam(this.m_CS, Kernal.CSMain, ShaderID.SceneColorRTID, new RenderTargetIdentifier(\"_CameraOpaqueTexture\"));\n                  cmd.SetComputeTextureParam(this.m_CS, Kernal.CSMain, ShaderID.SceneDepthRTID, new RenderTargetIdentifier(\"_CameraDepthTexture\"));\n                  cmd.DispatchCompute(this.m_CS, Kernal.CSMain, Dispatch.ThreadGroupCountX, Dispatch.ThreadGroupCountY, Dispatch.ThreadGroupCountZ);\n\n                  cmd.SetComputeTextureParam(this.m_CS, Kernal.FillHoles, ShaderID.ReflectColorRTID, RTID.m_ResultRT);\n                  cmd.DispatchCompute(this.m_CS, Kernal.FillHoles, Dispatch.ThreadGroupCountX, Dispatch.ThreadGroupCountY, Dispatch.ThreadGroupCountZ);\n              }\n\n              if (m_Material == null)\n              {\n                  Debug.LogError(\"Custom:SSPR shader missing\");\n              }\n              else\n              {\n                  m_Material.SetFloat(ShaderID.BlurIntensityID, m_SSPRVolume.m_BlurIntensity.value);\n\n                  RenderTextureDescriptor descriptor = new RenderTextureDescriptor(this.RTSizeWidth, this.RTSizeHeight, RenderTextureFormat.Default);\n                  descriptor.width \/= m_SSPRVolume.m_Downsample.value;\n                  descriptor.height \/= m_SSPRVolume.m_Downsample.value;\n                  \/\/descriptor.depthBufferBits = 0;     \/\/ \u4e0d\u4f1a\u7528\u5230\u6df1\u5ea6\uff0c\u7cbe\u5ea6\u8bbe\u4e3a0\n                  cmd.GetTemporaryRT(ShaderID.TempRTID, descriptor);\n                  RTID.m_TempRT = new RenderTargetIdentifier(ShaderID.TempRTID);\n\n                  Blit(cmd, RTID.m_ResultRT, RTID.m_TempRT);\n\n                  RenderTargetIdentifier lastDown = RTID.m_TempRT;\n                  for (uint i = 0; i &lt; m_SSPRVolume.m_PassLoop.value; ++i)\n                  {\n                      int midDown = blurLevel[i].downLevelID;\n                      int midUp = blurLevel[i].upLevelID;\n                      cmd.GetTemporaryRT(midDown, descriptor, FilterMode.Bilinear);\n                      cmd.GetTemporaryRT(midUp, descriptor, FilterMode.Bilinear);\n                      Blit(cmd, lastDown, midDown, m_Material, 1);\n                      lastDown = midDown;\n\n                      descriptor.width = Mathf.Max(descriptor.width \/ 2, 1);\n                      descriptor.height = Mathf.Max(descriptor.height \/ 2, 1);\n                  }\n\n                  int lastUp = blurLevel[m_SSPRVolume.m_PassLoop.value - 1].downLevelID;\n                  for (int i = m_SSPRVolume.m_PassLoop.value - 2; i &gt;= 0; --i)\n                  {\n                      int midUp = blurLevel[i].upLevelID;\n                      cmd.Blit(lastUp, midUp, m_Material, 2);\n                      lastUp = midUp;\n                  }\n\n                  cmd.Blit(lastUp, RTID.m_ResultRT, m_Material, 2);\n              }\n              context.ExecuteCommandBuffer(cmd);\n              CommandBufferPool.Release(cmd);\n          }\n      }\n\n      public override void OnCameraCleanup(CommandBuffer cmd)\n      {\n          if(cmd == null) throw new ArgumentNullException(\"cmd\");\n\n          cmd.ReleaseTemporaryRT(ShaderID.ReflectColorRTID);\n          cmd.ReleaseTemporaryRT(ShaderID.SceneDepthRTID);\n      }\n  }\n\n  public PassSetting m_Setting = new PassSetting();\n  SSPRRenderPass m_SSPRPass;\n\n  public override void Create()\n  {\n      m_SSPRPass = new SSPRRenderPass(m_Setting);\n  }\n\n  public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)\n  {\n      \/\/ can queue up multiple passes after each other\n      renderer.EnqueuePass(m_SSPRPass);\n  }\n}\n<\/code><\/pre>\n<ol start=\"4\">\n<li>Shader<\/li>\n<\/ol>\n<p>\u6700\u7ec8\u6548\u679c\u8fd8\u662f\u5f97\u7528material(pixel shader)\u5b9e\u73b0(\u4e0d\u8fc7\u4e0d\u7528\u7f6e\u4e8e\u7269\u4f53\u4e0a)<\/p>\n<pre><code class=\"line-numbers\">Shader \"URP\/reflect\"\n{\n  Properties\n  {\n      [HideInInspector] _MainTex(\"\", 2D) = \"white\" {}\n  }\n\n  SubShader\n  {\n      Tags\n      {\n          \"RenderPipeline\"=\"UniversalRenderPipeline\"\n          \"Queue\"=\"Overlay\"\n      }\n      Cull Off\n      ZWrite Off\n      ZTest Always\n\n      HLSLINCLUDE\n      #include \"Packages\/com.unity.render-pipelines.universal\/ShaderLibrary\/Core.hlsl\"\n\n      CBUFFER_START(UnityPerMaterial)\n      float _BlurIntensity;\n      float4 _MainTex_TexelSize;\n      CBUFFER_END\n\n      TEXTURE2D(_MainTex);            SAMPLER(sampler_MainTex);\n      TEXTURE2D(_ResultRT);\n      sampler LinearClampSampler;\n\n       struct VSInput\n       {\n           float4 positionOS : POSITION;\n           float4 normalOS : NORMAL;\n           float2 uv : TEXCOORD;\n       };\n\n       struct PSInput\n       {\n           float4 positionCS : SV_POSITION;\n           float2 uv:TEXCOORD;\n           float4 uv01 : TEXCOORD1;\n           float4 uv23 : TEXCOORD2;\n           float4 uv45 : TEXCOORD3;\n           float4 uv67 : TEXCOORD4;\n           float4 positionSS : TEXCOORD5;\n           float3 positionWS : TEXCOORD6;\n           float3 viewDirWS : TEXCOORD7;\n           float3 normalWS : NORMAL;\n       };\n      ENDHLSL\n\n      pass\n      {\n          NAME \"Copy SSRP\"\n          Tags\n          {\n              \"LightMode\"=\"UniversalForward\"\n              \"RenderType\"=\"Overlay\"\n          }\n\n          HLSLPROGRAM\n          #pragma vertex VS\n          #pragma fragment PS\n\n          PSInput VS(VSInput vsInput)\n          {\n              PSInput vsOutput;\n\n              VertexPositionInputs vertexPos = GetVertexPositionInputs(vsInput.positionOS);\n              vsOutput.positionWS = vertexPos.positionWS;\n              vsOutput.positionCS = vertexPos.positionCS;\n              vsOutput.positionSS = ComputeScreenPos(vsOutput.positionCS);\n\n              VertexNormalInputs vertexNormal = GetVertexNormalInputs(vsInput.normalOS);\n              vsOutput.normalWS = vertexNormal.normalWS;\n\n              return vsOutput;\n          }\n\n          half4 PS(PSInput psInput) : SV_Target\n          {\n              half2 screenUV = psInput.positionSS.xy \/ psInput.positionSS.w;\n              float4 SSPRResult = SAMPLE_TEXTURE2D(_ResultRT, LinearClampSampler, screenUV);\n              SSPRResult.xyz *= SSPRResult.w;\n\n              return SSPRResult;\n          }\n          ENDHLSL\n      }\n\n      Pass\n      {\n          NAME \"Down Samp[le\"\n\n          HLSLPROGRAM\n          #pragma vertex VS\n          #pragma fragment PS\n\n          PSInput VS(VSInput vsInput)\n          {\n              PSInput vsOutput;\n\n              vsOutput.positionCS = TransformObjectToHClip(vsInput.positionOS);\n\n              \/\/ \u5728D3D\u5e73\u53f0\u4e0b\uff0c\u82e5\u5f00\u542f\u6297\u952f\u9f7f\uff0c_TexelSize.y\u4f1a\u53d8\u6210\u8d1f\u503c\uff0c\u9700\u8981\u8fdb\u884coneminus\uff0c\u5426\u5219\u4f1a\u5bfc\u81f4\u56fe\u50cf\u4e0a\u4e0b\u98a0\u5012\n              #ifdef UNITY_UV_STARTS_AT_TOP\n              if(_MainTex_TexelSize.y &lt; 0)\n                  vsInput.uv.y = 1 - vsInput.uv.y;\n              #endif\n\n              vsOutput.uv = vsInput.uv;\n              vsOutput.uv01.xy = vsInput.uv + float2(1.f, 1.f) * _MainTex_TexelSize.xy * _BlurIntensity;\n              vsOutput.uv01.zw = vsInput.uv + float2(-1.f, -1.f) * _MainTex_TexelSize.xy * _BlurIntensity;\n              vsOutput.uv23.xy = vsInput.uv + float2(1.f, -1.f) * _MainTex_TexelSize.xy * _BlurIntensity;\n              vsOutput.uv23.zw = vsInput.uv + float2(-1.f, 1.f) * _MainTex_TexelSize.xy * _BlurIntensity;\n\n              return vsOutput;\n          }\n\n          float4 PS(PSInput psInput) : SV_TARGET\n          {\n              float4 outputColor = 0.f;\n\n              outputColor += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, psInput.uv.xy) * 0.5;\n\n              outputColor += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, psInput.uv01.xy) * 0.125;\n              outputColor += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, psInput.uv01.zw) * 0.125;\n              outputColor += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, psInput.uv23.xy) * 0.125;\n              outputColor += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, psInput.uv23.zw) * 0.125;\n\n              return outputColor;\n          }\n          ENDHLSL\n      }\n\n      Pass\n      {\n          NAME \"Up Sample\"\n\n          HLSLPROGRAM\n          #pragma vertex VS\n          #pragma fragment PS\n\n          PSInput VS(VSInput vsInput)\n          {\n              PSInput vsOutput;\n\n              vsOutput.positionCS = TransformObjectToHClip(vsInput.positionOS);\n\n              #ifdef UNITY_UV_STARTS_AT_TOP\n              if(_MainTex_TexelSize.y &lt; 0.f)\n                  vsInput.uv.y = 1 - vsInput.uv.y;\n              #endif\n\n              vsOutput.uv = vsInput.uv;\n              \/\/ 1\/12\n              vsOutput.uv01.xy = vsInput.uv + float2(0, 1) * _MainTex_TexelSize.xy * _BlurIntensity;\n              vsOutput.uv01.zw = vsInput.uv + float2(0, -1) * _MainTex_TexelSize.xy * _BlurIntensity;\n              vsOutput.uv23.xy = vsInput.uv + float2(1, 0) * _MainTex_TexelSize.xy * _BlurIntensity;\n              vsOutput.uv23.zw = vsInput.uv + float2(-1, 0) * _MainTex_TexelSize.xy * _BlurIntensity;\n              \/\/ 1\/6\n              vsOutput.uv45.xy = vsInput.uv + float2(1, 1) * 0.5 * _MainTex_TexelSize.xy * _BlurIntensity;\n              vsOutput.uv45.zw = vsInput.uv + float2(-1, -1) * 0.5 * _MainTex_TexelSize.xy * _BlurIntensity;\n              vsOutput.uv67.xy = vsInput.uv + float2(1, -1) * 0.5 * _MainTex_TexelSize.xy * _BlurIntensity;\n              vsOutput.uv67.zw = vsInput.uv + float2(-1, 1) * 0.5 * _MainTex_TexelSize.xy * _BlurIntensity;\n\n              return vsOutput;\n          }\n\n          float4 PS(PSInput psInput) : SV_TARGET\n          {\n              float4 outputColor = 0.f;\n\n              outputColor += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, psInput.uv01.xy) * 1\/12;\n              outputColor += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, psInput.uv01.zw) * 1\/12;\n              outputColor += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, psInput.uv23.xy) * 1\/12;\n              outputColor += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, psInput.uv23.zw) * 1\/12;\n\n              outputColor += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, psInput.uv45.xy) * 1\/6;\n              outputColor += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, psInput.uv45.zw) * 1\/6;\n              outputColor += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, psInput.uv67.xy) * 1\/6;\n              outputColor += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, psInput.uv67.zw) * 1\/6;\n\n              return outputColor;\n          }\n          ENDHLSL\n      }\n  }\n} \n<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2>\u52a0\u5165\u6c34\u4e2d<\/h2>\n<ul>\n<li>\u601d\u8def\uff1a\u5c4f\u5e55\u7a7a\u95f4\u5e73\u9762\u53cd\u5c04\u56fe\u50cf + \u5929\u7a7a\u76d2\u53cd\u5c04\uff0c\u5e76\u626d\u66f2\u6a21\u7cca<\/p>\n<\/li>\n<li>\n<p>\u5b9e\u73b0<\/p>\n<pre><code class=\"line-numbers\">half3 GetReflect(float4 positionSS, half3 normalWS, half3 viewDirWS)\n{\n  half3 result = half3(0.h, 0.h, 0.h);\n\n  float2 positionSSNor = positionSS.xy \/ positionSS.w;\n  \/\/ \u5bf9\u53cd\u5c04\u56fe\u50cf\u8fdb\u884c\u626d\u66f2\u6270\u52a8\n  float2 uv = positionSSNor + normalWS.xy * max(0.f, _ReflectDistortIntensity) * (_ScreenParams.zw - 1.h);\n\n  half3 SSRPColor = SAMPLE_TEXTURE2D(_ResultRT, sampler_ResultRT, uv).rgb * max(0.0001f, _SSRPColorScale);\n  \/\/ \u89c6\u60c5\u51b5\u8c03\u6574\u6a21\u7cca\u7a0b\u5ea6\n  half3 skyBoxColor = GetEnvironmentColor(viewDirWS, normalWS, _EnvironmentMipMapLevel) * max(0.0001f, _EnvironmentColorScale);\n  result += SSRPColor + skyBoxColor;\n\n  return result;\n}\n<\/code><\/pre>\n<\/li>\n<li>\u6548\u679c\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/65bfab76c458853aef4be827.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/65bfab76c458853aef4be827.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<\/ul>\n<h1>\u7126\u6563<\/h1>\n<ul>\n<li>\n<p>\u601d\u8def\uff1a\u5728UE\u4e2d\u4f7f\u7528\u540e\u5904\u7406\u5b9e\u73b0\u8fc7\uff0c\u8fd9\u91cc\u5c1d\u8bd5\u4e00\u79cd\u65b0\u65b9\u6cd5\uff0c\u91cd\u6784\u4e16\u754c\u5750\u6807\u5e76\u91c7\u6837\u7126\u6563\u8d34\u56fe\uff0c\u6700\u540e\u63a7\u5236\u7126\u6563\u51fa\u73b0\u533a\u57df<\/p>\n<\/li>\n<li>\n<p>\u7eb9\u7406<\/p>\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/658bea3ec458853aef39fb5f.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/658bea3ec458853aef39fb5f.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<li>\n<p>\u5b9e\u73b0<\/p>\n<p>panner\u53cd\u5411uv\u6a21\u62df\u7126\u6563\u7684\u8fd0\u52a8<\/p>\n<pre><code class=\"line-numbers\">half3 GetCaustic(half depthFade, float2 positionSSNor)\n{\n  half3 result = half3(0.h, 0.h, 0.h);\n  _CausticTiling = max(0.0001h, _CausticTiling);\n  _CausticRange = max(0.1h, _CausticRange);\n  _ShoreCausticTransparent = max(0.h, _ShoreCausticTransparent);\n  _CausticTint = max(0.h, _CausticTint);\n\n  half rawDepth = SampleSceneDepth(positionSSNor);\n  \/\/ \u91cd\u6784\u4e16\u754c\u5750\u6807\n  float3 positionWS = ComputeWorldSpacePosition(positionSSNor, rawDepth, UNITY_MATRIX_I_VP);\n\n  half causticArea = saturate(exp(-depthFade \/ _CausticRange));\n\n  float2 uv = positionWS.xz \/ _CausticTiling;\n  float2 uv1 = Panner(uv, _Time.y \/ 10, half2(_CausticSpeed.x, _CausticSpeed.x));\n  float2 uv2 = Panner(-uv, _Time.y \/ 10, half2(_CausticSpeed.y, _CausticSpeed.y));\n  half3 causticTex1 = SAMPLE_TEXTURE2D(_CausticTex, sampler_CausticTex, uv1).rgb;\n  half3 causticTex2 = SAMPLE_TEXTURE2D(_CausticTex, sampler_CausticTex, uv2).rgb;\n  result = min(causticTex1, causticTex2) * _CausticTint;\n  result *= causticArea;\n\n  return result;\n}\n\nhalf3 causticColor = GetCaustic(defaultDepthFade, positionSSNor);\nsurfaceData.albedo += causticColor;\n<\/code><\/pre>\n<\/li>\n<li>\u6548\u679c<br \/>\n<img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/65c074569f345e8d035956ef.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/65c074569f345e8d035956ef.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<\/ul>\n<h1>\u6d6a\u82b1<\/h1>\n<ul>\n<li>\n<p>\u53c2\u8003\u4e86\u5f88\u591a\u6e38\u620f\u4e2d\u7684\u98ce\u683c\u5316\u6c34\u4f53\u6548\u679c\uff0c\u53d1\u73b0\u5f88\u5c11\u5b9e\u73b0\u6ce2\u5cf0\u6d6a\u82b1\u7684\uff0c\u4ec5\u4ec5\u5b9e\u73b0\u4e86\u8fd1\u5cb8\u6d6a\u82b1\uff0c\u8fd9\u91cc\u5077\u4e2a\u61d2\u4e5f\u53ea\u5b9e\u73b0\u8fd1\u5cb8\u6d6a\u82b1\u53ed<\/p>\n<\/li>\n<li>\n<p>\u5b9e\u73b0<br \/>\nFoamMask\u57fa\u4e8e\u6df1\u5ea6\u5b9e\u73b0\uff0c\u4f7f\u7528Foam Cutoff\u6765\u63a7\u5236Foam\u533a\u57df<\/p>\n<pre><code class=\"line-numbers\">half3 GetFoam(half depthFade, float2 uv)\n{\n  half3 result = half3(0.h, 0.h, 0.h);\n\n  _FoamDepthFade = max(0.0001h, _FoamDepthFade) \/ 10.h;\n  _FoamTiling = max(0.0001h, _FoamTiling) \/ 10.h;\n\n\/\/ \u63a7\u5236\u6d6a\u82b1\u51fa\u73b0\u533a\u57df\n  half foamMask = depthFade \/ _FoamDepthFade + 0.1h;\n  foamMask = smoothstep(foamMask, 1.h - _FoamFade, 1.h);\n  foamMask = 1.h - foamMask;\n\n\/\/ \u91c7\u6837\u6d6a\u82b1\u8d34\u56fe\n  float2 foamUV = Panner(uv * _FoamTiling, _Time.y \/ 10.h, half2(_FoamSpeed, _FoamSpeed));\n  half foamTex = SAMPLE_TEXTURE2D(_FoamTex, sampler_FoamTex, foamUV).r;\n  half cutOff = foamMask * _FoamCutoff;\n  foamTex = step(cutOff, foamTex);\n\n  half4 temp = _FoamTint * foamTex;\n  result = temp.rgb * temp.a * foamMask;\n\n  return result;\n}\n\nhalf3 foamColor = GetFoam(defaultDepthFade, positionWS.xz);\nsurfaceData.albedo += foamColor;\n<\/code><\/pre>\n<\/li>\n<li>\u6548\u679c<br \/>\n<img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/65c074ea9f345e8d035aeaf4.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/65c074ea9f345e8d035aeaf4.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<\/ul>\n<h1>Wave<\/h1>\n<ul>\n<li>\n<p>\u8001\u670b\u53cb\u4e86GerstnerWave\uff0c\u8003\u8651\u5230\u79fb\u52a8\u7aef\u7684\u6027\u80fd\uff0c\u6700\u591a\u53e0\u52a04\u4e2a\u6ce2<\/p>\n<\/li>\n<li>\n<p>\u5b9e\u73b0<\/p>\n<pre><code class=\"line-numbers\">void GerstnerWave(inout float3 positionOS, inout float3 tangentWS, inout float3 binormalWS, half direction)\n{\n  direction = direction * 2 - 1;\n  float2 d = normalize(float2(cos(3.14 * direction), sin(3.14 * direction)));   \n  float k = 2 * 3.14 \/ _WaveLength; \/\/ \u9891\u7387\u5468\u671f\n  float f = k * (dot(d, positionOS.xz) - _G * _Time.y); \/\/ sin\/cos\u53c2\u6570\n  float a = _Steepness \/ k; \/\/ \u632f\u5e45(\u9632\u6b62\u6253\u7ed3)\n\n  tangentWS += float3(\n  -d.x * d.x * (_Steepness * sin(f)),\n  d.x * (_Steepness * cos(f)),\n  -d.x * d.y * (_Steepness * sin(f))\n  );\n\n  binormalWS += float3(\n  -d.x * d.y * (_Steepness * sin(f)),\n  d.y * (_Steepness * cos(f)),\n  -d.y * d.y * (_Steepness * sin(f))\n  );\n\n  positionOS += float3(\n  d.x * (a * cos(f)),\n  a * sin(f),\n  d.y * (a * cos(f))\n  );\n}\n\nvoid GerstnerWave4(inout float3 positionOS, float3 normalWS)\n{\n  _Steepness = max(0.h, _Steepness);\n  _WaveLength = max(0.0001h, _WaveLength);\n  _G = max(0.h, _G);\n\n  float3 tangent = float3(1, 0, 0);\n  float3 binormal = float3(0, 0, 1);\n\n  GerstnerWave(positionOS, tangent, binormal, _WindDirection.x);\n  GerstnerWave(positionOS, tangent, binormal, _WindDirection.y);\n  GerstnerWave(positionOS, tangent, binormal, _WindDirection.z);\n  GerstnerWave(positionOS, tangent, binormal, _WindDirection.w);\n\n  normalWS += cross(tangent, binormal);\n}\n\n\/\/ VS\u4e2d\nGerstnerWave4(i.positionOS, i.normalOS);\n<\/code><\/pre>\n<\/li>\n<li>\u6548\u679c<br \/>\n<img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/65c074d49f345e8d035aaf7b.jpg\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/65c074d49f345e8d035aaf7b.jpg\" alt=\"\" \/><\/p><\/noscript>\n<\/li>\n<\/ul>\n<h1>\u6700\u7ec8\u6548\u679c<\/h1>\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic.imgdb.cn\/item\/65c076719f345e8d035f71fa.gif\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><\/p >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/65c076719f345e8d035f71fa.gif\" alt=\"\" \/><\/p><\/noscript>\n<h1>\u9879\u76ee\u94fe\u63a5<\/h1>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/github.com\/chenglixue\/URPStylizedWater\" target=\"_blank\"  rel=\"nofollow\" >URPStylizedWater<\/a><\/p>\n<h1>reference<\/h1>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/ameye.dev\/notes\/stylized-water-shader\/\" target=\"_blank\"  rel=\"nofollow\" >Stylized Water Shader<\/a><\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.alanzucconi.com\/2016\/01\/06\/colour-interpolation\/\" target=\"_blank\"  rel=\"nofollow\" >The Secrets of Colour Interpolation<\/a><\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/docs.unrealengine.com\/4.27\/en-US\/BuildingWorlds\/Water\/WaterWaveAsset\/\" target=\"_blank\"  rel=\"nofollow\" >Simulating Waves Using The Water Waves Asset<\/a><\/p>\n<p>https:\/\/zhuanlan.zhihu.com\/p\/357714920<\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/github.com\/ColinLeung-NiloCat\/UnityURP-MobileScreenSpacePlanarReflection\" target=\"_blank\"  rel=\"nofollow\" >UnityURP-MobileScreenSpacePlanarReflection<\/a><\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/zhuanlan.zhihu.com\/p\/651134124\" target=\"_blank\"  rel=\"nofollow\" >Unity URP\u5b9e\u73b0\u5c4f\u5e55\u7a7a\u95f4\u5e73\u9762\u53cd\u5c04\uff08SSPR\uff09<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u7b14\u8005\u66fe\u4f7f\u7528UE\u5b9e\u73b0\u8fc7\u4e00\u4e2a\u8f83\u4e3a\u5b8c\u6574\u7684\u5199\u5b9e\u6c34\u6750\u8d28\u7cfb\u7edf\uff0c\u4f46\u662f\u56e0\u4e3aUE\u7684\u7ba1\u7ebf\u662f\u5b9a\u6b7b\u7684\uff0c\u5bfc\u81f4\u9ad8\u5149\u65e0\u6cd5\u5b9e\u73b0\uff0c\u4e14\u540e\u6765\u505a\u7b14\u8bd5\u9898\u53d1\u73b0\u5173\u4e8e\u6c34\u7684\u4ea4 &#8230;<\/p>","protected":false},"author":1,"featured_media":46,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/chenglixue.top\/index.php?rest_route=\/wp\/v2\/posts\/45"}],"collection":[{"href":"http:\/\/chenglixue.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/chenglixue.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/chenglixue.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/chenglixue.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=45"}],"version-history":[{"count":7,"href":"http:\/\/chenglixue.top\/index.php?rest_route=\/wp\/v2\/posts\/45\/revisions"}],"predecessor-version":[{"id":119,"href":"http:\/\/chenglixue.top\/index.php?rest_route=\/wp\/v2\/posts\/45\/revisions\/119"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/chenglixue.top\/index.php?rest_route=\/wp\/v2\/media\/46"}],"wp:attachment":[{"href":"http:\/\/chenglixue.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=45"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/chenglixue.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=45"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/chenglixue.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=45"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}