{"id":493,"date":"2026-07-13T00:53:02","date_gmt":"2026-07-12T16:53:02","guid":{"rendered":"http:\/\/chenglixue.top\/?p=493"},"modified":"2026-07-13T00:54:36","modified_gmt":"2026-07-12T16:54:36","slug":"ue5-basepass%e6%8b%86%e8%a7%a3","status":"publish","type":"post","link":"http:\/\/chenglixue.top\/?p=493","title":{"rendered":"UE5 BasePass\u62c6\u89e3"},"content":{"rendered":"<p><div class=\"has-toc have-toc\"><\/div><\/p>\n<h1>\u4ec0\u4e48\u662fBasePass<\/h1>\n<p>BasePass\u662f\u4f4d\u4e8e\u5ef6\u8fdf\u7ba1\u7ebf\u7684PrePass\u4e4b\u540e\u7684\u4e00\u4e2aPass\uff0cDeferred \u4e0b\u4e0d\u900f\u660e BasePass \u4ee5\u5199 GBuffer + \u96fe\u6548 + \u90e8\u5206\u95f4\u63a5\/\u81ea\u53d1\u5149\u4e3a\u4e3b\uff1b\u534a\u900f\u660e\u7b49\u53e6\u6709\u8def\u5f84<\/p>\n<h1>\u4e3a\u4ec0\u4e48\u9700\u8981BasePass<\/h1>\n<p>\u8fd9\u662f\u4e00\u4e2a\u8001\u751f\u5e38\u8c08\u7684\u95ee\u9898\uff0c\u8fd9\u91cc\u7b80\u5355\u63d0\u4e00\u4e0b\uff0c\u4e3b\u8981\u4f5c\u7528\u5c31\u662f\u4f18\u5316\u5149\u7167\u590d\u6742\u5ea6\uff0c\u907f\u514d\u65e0\u7528\u7684\u5149\u7167\u8ba1\u7b97<\/p>\n<h1>UE5 BasePass<\/h1>\n<h2>CPU\u7aef<\/h2>\n<h3>\u8bbe\u5b9aGBuffer\u53caFormat<\/h3>\n<ul>\n<li>\u4f4d\u7f6e\uff1aGBufferInfo.cpp->FetchLegacyGBufferInfo()<\/p>\n<\/li>\n<li>\n<p>\u5b9e\u73b0<\/p>\n<pre><code class=\"language-glsl line-numbers\">Info.Targets[0].Init(GBT_Unorm_11_11_10,  TEXT(\"Lighting\"), false,  true,  true,  true);\nInfo.Targets[1].Init(NormalGBufferFormatTarget,TEXT(\"GBufferA\"), false,  true,  true,  true);\nInfo.Targets[2].Init(DiffuseAndSpecularGBufferFormat,   TEXT(\"GBufferB\"), false,  true,  true,  true);\n\nconst bool bLegacyAlbedoSrgb = true;\nInfo.Targets[3].Init(DiffuseAndSpecularGBufferFormat,  TEXT(\"GBufferC\"), bLegacyAlbedoSrgb &amp;&amp; !bHighPrecisionGBuffers,  true,  true,  true);\n\n\/\/ This code should match TBasePassPS\nif (Params.bHasVelocity == 0 &amp;&amp; Params.bHasTangent == 0)\n{\n  TargetGBufferD = 4;\n  Info.Targets[4].Init(GBT_Unorm_8_8_8_8,  TEXT(\"GBufferD\"), false,  true,  true,  true);\n\n  if (Params.bHasPrecShadowFactor)\n  {\n      TargetGBufferE = 5;\n      Info.Targets[5].Init(GBT_Unorm_8_8_8_8, TEXT(\"GBufferE\"), false, true, true, true);\n  }\n}\nelse if (Params.bHasVelocity)\n{\n  TargetVelocity = 4;\n  TargetGBufferD = 5;\n\n  \/\/ note the false for use extra flags for velocity, not quite sure of all the ramifications, but this keeps it consistent with previous usage\n  Info.Targets[4].Init(Params.bUsesVelocityDepth ? GBT_Unorm_16_16_16_16 : (IsAndroidOpenGLESPlatform(Params.ShaderPlatform) ? GBT_Float_16_16 : GBT_Unorm_16_16), TEXT(\"Velocity\"), false, true, true, false);\n  Info.Targets[5].Init(GBT_Unorm_8_8_8_8, TEXT(\"GBufferD\"), false, true, true, true);\n\n  if (Params.bHasPrecShadowFactor)\n  {\n      TargetGBufferE = 6;\n      Info.Targets[6].Init(GBT_Unorm_8_8_8_8, TEXT(\"GBufferE\"), false, true, true, false);\n  }\n}\nelse if (Params.bHasTangent)\n{\n  TargetGBufferF = 4;\n  TargetGBufferD = 5;\n  Info.Targets[4].Init(GBT_Unorm_8_8_8_8,  TEXT(\"GBufferF\"), false,  true,  true,  true);\n  Info.Targets[5].Init(GBT_Unorm_8_8_8_8, TEXT(\"GBufferD\"), false, true, true, true);\n  if (Params.bHasPrecShadowFactor)\n  {\n      TargetGBufferE = 6;\n      Info.Targets[6].Init(GBT_Unorm_8_8_8_8, TEXT(\"GBufferE\"), false, true, true, true);\n  }\n}\nelse\n{\n  \/\/ should never hit this path\n  check(0);\n}\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>\u6e05\u7a7aGBuffer<\/h3>\n<pre><code class=\"language-glsl line-numbers\">static const auto ClearMethodCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT(\"r.ClearSceneMethod\"));\n\nbool bRequiresRHIClear = true;\nbool bRequiresFarZQuadClear = false;\n\nif (ClearMethodCVar)\n{\n    int32 ClearMethod = ClearMethodCVar-&gt;GetValueOnRenderThread();\n\n    if (ClearMethod == 0 &amp;&amp; !ViewFamily.EngineShowFlags.Game)\n    {\n        \/\/ Do not clear the scene only if the view family is in game mode.\n        ClearMethod = 1;\n    }\n\n    switch (ClearMethod)\n    {\n    case 0: \/\/ No clear\n        bRequiresRHIClear = false;\n        bRequiresFarZQuadClear = false;\n        break;\n\n    case 1: \/\/ RHICmdList.Clear\n        bRequiresRHIClear = true;\n        bRequiresFarZQuadClear = false;\n        break;\n\n    case 2: \/\/ Clear using far-z quad\n        bRequiresFarZQuadClear = true;\n        bRequiresRHIClear = false;\n        break;\n    }\n}\n<\/code><\/pre>\n<p>\u6e05\u7a7aGBuffer\u7684\u65b9\u5f0f\u7531\u63a7\u5236\u53f0\u6307\u4ee4\u663e\u793a\u6307\u5b9a\uff0c\u6e05\u7a7a\u65b9\u5f0f\u6709\u4e09\u79cd\uff0c<strong>\u9ed8\u8ba4RHIClear<\/strong>\uff1a<\/p>\n<ol>\n<li>NoClear\n<ul>\n<li>\u76ee\u7684\uff1a\u4e0d\u6e05\u9664Clear<\/li>\n<li>\u4f18\u70b9\uff1a\u7701\u5e26\u5bbd<\/li>\n<li>\u7f3a\u70b9\uff1a\u53ef\u80fd\u6b8b\u7559\u5783\u573e\u6570\u636e<\/li>\n<\/ul>\n<\/li>\n<li>RHIClear\n<ul>\n<li>\u76ee\u7684\uff1a\u6574\u5c4f\u786c\u4ef6 Clear<\/li>\n<li>\u4f18\u70b9\uff1a\u5b9e\u73b0\u7b80\u5355\u3001\u884c\u4e3a\u7a33\u5b9a<\/li>\n<li>\u7f3a\u70b9\uff1a\u6574\u5c4f\u5e26\u5bbd<\/li>\n<\/ul>\n<\/li>\n<li>QuadAtMaxZ\n<ul>\n<li>\u76ee\u7684\uff1a\u5728Clear\u7684\u60c5\u51b5\u4e0b\uff0c\u8282\u7701\u5e26\u5bbd<\/li>\n<li>\u4f18\u70b9\uff1a\u4f7f\u7528Prepass\u6df1\u5ea6\u505a\u6df1\u5ea6\u6d4b\u8bd5\n<ul>\n<li>\u753b\u4e00\u4e2a\u5168\u5c4f Quad\uff0c\u6df1\u5ea6\u8bbe\u5728 MaxZ<\/li>\n<li>\u2022 \u6df1\u5ea6\u6d4b\u8bd5 CF_GreaterEqual\uff08Reversed-Z\uff09<\/li>\n<li>\u2022 \u53ea\u6709\u4ecd\u4e3a MaxZ \u7684\u50cf\u7d20\u901a\u8fc7\u6d4b\u8bd5\u5e76\u88ab\u5199\u4e0a\u80cc\u666f\u8272<\/li>\n<li>\u2022 \u5df2\u6709\u51e0\u4f55\u7684\u50cf\u7d20\u6df1\u5ea6\u66f4\u8fd1 \u2192 \u4e0d\u4f1a\u88ab\u8986\u76d6<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<pre><code class=\"language-glsl line-numbers\">if (ViewFamily.EngineShowFlags.Wireframe || ViewFamily.EngineShowFlags.ShaderComplexity || ViewFamily.EngineShowFlags.StationaryLightOverlap)\n{\n    bRequiresRHIClear = true;\n    bRequiresFarZQuadClear = false;\n}\n<\/code><\/pre>\n<p>\u8fd9\u91cc\u4f9d\u7136\u5728\u5224\u65ad\u5982\u4f55Clear RT\uff0c\u5224\u65adView\u89c6\u53e3\u76ee\u524d\u662f\u4e0d\u662f\u7ebf\u6846\u6a21\u5f0f\u3001shader\u590d\u6742\u5ea6\u6a21\u5f0f\u3001\u9759\u6b62\u5149\u4ea4\u9519\u6d4b\u8bd5\u6a21\u5f0f\uff0c\u662f\u5219\u542f\u7528RHIClear\uff0c\u7981\u7528QuadAtMaxZ\uff0c\u4e5f\u5c31\u662f\u8bf4\u8fd9\u4e09\u79cd\u6a21\u5f0f\u4e0d\u80fd\u8d70prepass\u6df1\u5ea6\u6d4b\u8bd5\u4f18\u5316<\/p>\n<h3>\u83b7\u53d6GBuffer RenderTargets<\/h3>\n<pre><code class=\"language-glsl line-numbers\">TStaticArray&lt;FTextureRenderTargetBinding, MaxSimultaneousRenderTargets&gt; BasePassTextures;\nuint32 BasePassTextureCount = SceneTextures.GetGBufferRenderTargets(BasePassTextures);\n<\/code><\/pre>\n<p>\u5148\u83b7\u53d6Base Pass\u7528\u5230\u7684RenderTargets<\/p>\n<pre><code class=\"language-glsl line-numbers\">TArrayView&lt;FTextureRenderTargetBinding&gt; BasePassTexturesView = MakeArrayView(BasePassTextures.GetData(), BasePassTextureCount);\n<\/code><\/pre>\n<p>\u7531\u4e8eBasePassTextures\u521d\u59cb\u5316\u4e00\u6b21\u6027\u5206\u914d\u56fa\u5b9a\u5927\u5c0f\u7684\u6570\u7ec4\uff0cRenderTargets\u53ef\u80fd\u4e0d\u4f1a\u5b8c\u5168\u5360\u6ee1\uff0c\u8fd9\u610f\u5473\u7740\u4f1a\u5269\u4e0b\u7a7a\u4f4d\uff0c\u4e0d\u80fd\u628a\u5e26\u6709\u7a7a\u4f4d\u7684BasePassTextures\u4f20\u7ed9\u5176\u4ed6\u5bf9\u8c61\uff0c\u56e0\u6b64MakeArrayView\u6267\u884c\u4e86\u53bb\u7a7a<\/p>\n<pre><code class=\"line-numbers\">FRDGTextureRef BasePassDepthTexture = SceneTextures.Depth.Target;\nFLinearColor SceneColorClearValue = FLinearColor::Black;\n<\/code><\/pre>\n<p>\u83b7\u53d6Depth Texture\uff0c\u4ee5\u53caClear Color<\/p>\n<h3>Clear GBuffer Render Targets<\/h3>\n<ul>\n<li>\u51b3\u5b9aClear Color\n<pre><code class=\"language-glsl line-numbers\">if (ViewFamily.EngineShowFlags.ShaderComplexity || ViewFamily.EngineShowFlags.StationaryLightOverlap)\n{\n  SceneColorClearValue = FLinearColor(0, 0, 0, kSceneColorClearAlpha);\n}\nelse\n{\n  SceneColorClearValue = FLinearColor(InViews[0].BackgroundColor.R, InViews[0].BackgroundColor.G, InViews[0].BackgroundColor.B, kSceneColorClearAlpha);\n}\n<\/code><\/pre>\n<p>Debug\u6a21\u5f0fClear Color\u4e3a\u9ed1\uff0c\u6b63\u5e38\u60c5\u51b5Clear Color\u4e3a\u80cc\u666f\u8272<\/p>\n<\/li>\n<li>\n<p>\u51b3\u5b9aclear\u65b9\u5f0f<\/p>\n<pre><code class=\"language-glsl line-numbers\">ERenderTargetLoadAction ColorLoadAction = ERenderTargetLoadAction::ELoad;\n\nif (SceneTextures.Color.Target-&gt;Desc.ClearValue.GetClearColor() == SceneColorClearValue)\n{\n  ColorLoadAction = ERenderTargetLoadAction::EClear;\n}\nelse\n{\n  ColorLoadAction = ERenderTargetLoadAction::ENoAction;\n}\n<\/code><\/pre>\n<ul>\n<li>EClear\uff1aGPU\u786c\u4ef6 Clear\uff0cclear\u6210ClearColor<\/li>\n<li>ENoAction\uff1a\u4e0d Load\u3001\u4e5f\u4e0d Clear<\/li>\n<li>ELoad\uff1a\u4fdd\u7559\u5df2\u6709\u5185\u5bb9<\/li>\n<\/ul>\n<\/li>\n<li>Pass Parameter\u7ed1\u5b9aRenderTargets\n<pre><code class=\"language-glsl line-numbers\">auto* PassParameters = GraphBuilder.AllocParameters&lt;FRenderTargetParameters&gt;();\nPassParameters-&gt;RenderTargets = GetRenderTargetBindings(ColorLoadAction, BasePassTexturesView);\n<\/code><\/pre>\n<\/li>\n<li>\u5904\u7406GBufferD\n<pre><code class=\"language-glsl line-numbers\">const FGBufferBindings&amp; GBufferBindings = SceneTextures.Config.GBufferBindings[GBL_Default];\nif (!CVarClearGBufferDBeforeBasePass.GetValueOnRenderThread() &amp;&amp; GBufferBindings.GBufferD.Index &gt; 0 &amp;&amp; GBufferBindings.GBufferD.Index &lt; (int32)BasePassTextureCount)\n{\n  PassParameters-&gt;RenderTargets[GBufferBindings.GBufferD.Index].SetLoadAction(ERenderTargetLoadAction::ENoAction);\n}\n<\/code><\/pre>\n<p>\u82e5\u660e\u786e\u6307\u51faBase Pass\u6267\u884c\u524d\uff0c\u4e0dclear GBufferD\uff0cGBufferD\u8bbe\u7f6e\u4e0dclear \u4e0dload<\/p>\n<p>GBufferD \u5e38\u5b58 PerObject Data \/ Custom Data\uff0c\u6709\u65f6 Base Pass \u4f1a\u5b8c\u6574\u8986\u76d6\uff0c\u63d0\u524d\u6e05\u662f\u6d6a\u8d39<\/p>\n<\/li>\n<li>\n<p>\u5f53\u4e0dClear\uff0c\u4e5f\u4e0dLoad<\/p>\n<pre><code class=\"language-glsl line-numbers\">GraphBuilder.AddPass(RDG_EVENT_NAME(\"GBufferClear\"), PassParameters, ERDGPassFlags::Raster,\n[PassParameters, ColorLoadAction, SceneColorClearValue](FRDGAsyncTask, FRHICommandList&amp; RHICmdList)\n{\nconst FRenderTargetBindingSlots&amp; RenderTargets = PassParameters-&gt;RenderTargets;\n  FLinearColor ClearColors[MaxSimultaneousRenderTargets];\n  FRHITexture* Textures[MaxSimultaneousRenderTargets];\n  int32 TextureIndex = 0;\n\n  RenderTargets.Enumerate([&amp;](const FRenderTargetBinding&amp; RenderTarget)\n      {\n          FRHITexture* TextureRHI = RenderTarget.GetTexture()-&gt;GetRHI();\n          ClearColors[TextureIndex] = TextureIndex == 0 ? SceneColorClearValue : TextureRHI-&gt;GetClearColor();\n          Textures[TextureIndex] = TextureRHI;\n          ++TextureIndex;\n      });\n\n  \/\/ Clear color only; depth-stencil is fast cleared.\n  DrawClearQuadMRT(RHICmdList, true, TextureIndex, ClearColors, false, 0, false, 0);\n});\n<\/code><\/pre>\n<p>\u5f53\u786c\u4ef6\u4e0d\u505a\u4efb\u4f55\u5904\u7406\u65f6\uff0c\u624d\u6267\u884cShader Clear<\/p>\n<p>Scene Color Clear \u4e3aSceneColorClearValue\uff0c\u5176\u4ed6\u7684Clear\u4e3a\u5404\u81ea\u7eb9\u7406\u6ce8\u518c\u7684 GetClearColor()<\/p>\n<\/li>\n<\/ul>\n<h3>RenderBasePass<\/h3>\n<h4>Load GBuffer<\/h4>\n<pre><code class=\"language-glsl line-numbers\">FRenderTargetBindingSlots BasePassRenderTargets = GetRenderTargetBindings(ERenderTargetLoadAction::ELoad, BasePassTexturesView);\nBasePassRenderTargets.DepthStencil = FDepthStencilBinding(BasePassDepthTexture, ERenderTargetLoadAction::ELoad, ERenderTargetLoadAction::ELoad, ExclusiveDepthStencil);\n\nBasePassRenderTargets.DepthStencil = FDepthStencilBinding(BasePassDepthTexture, ERenderTargetLoadAction::ELoad, ERenderTargetLoadAction::ELoad, ExclusiveDepthStencil);\n\nconst bool bAllowReadOnlyDepthBasePass = bIsEarlyDepthComplete\n    &amp;&amp; !ViewFamily.EngineShowFlags.ShaderComplexity\n    &amp;&amp; !ViewFamily.UseDebugViewPS()\n    &amp;&amp; !ViewFamily.EngineShowFlags.Wireframe\n    &amp;&amp; !ViewFamily.EngineShowFlags.LightMapDensity;\n\nconst FExclusiveDepthStencil::Type BasePassDepthStencilAccess =\n    bAllowReadOnlyDepthBasePass\n    ? FExclusiveDepthStencil::DepthRead_StencilWrite\n    : FExclusiveDepthStencil::DepthWrite_StencilWrite;\n<\/code><\/pre>\n<p>\u53ea\u6709\u662f\u975eDebug\u6a21\u5f0f\u4e14prepass\u6267\u884c\u4e86\uff0c\u624d\u8d70DepthRead_StencilWrite\uff0c\u5426\u5219DepthWrite_StencilWrite<\/p>\n<h4>RenderNaniteBasePass<\/h4>\n<pre><code class=\"language-glsl line-numbers\">auto RenderNaniteBasePass = [&amp;](FViewInfo&amp; View, int32 ViewIndex)\n{\n    Nanite::FRasterResults&amp; RasterResults = NaniteRasterResults[ViewIndex];\n\n    Nanite::DispatchBasePass(\n        GraphBuilder,\n        NaniteBasePassShadingCommands,\n        Renderer,\n        SceneTextures,\n        BasePassRenderTargets,\n        DBufferTextures,\n        *Scene,\n        View,\n        uint32(ViewIndex),\n        RasterResults\n    );\n}\n<\/code><\/pre>\n<p>\u7531\u4e8eNanite\u8fd8\u672a\u63a5\u89e6\uff0c\u8fd9\u91cc\u5c31\u4e0d\u73ed\u95e8\u5f04\u65a7\u4e86\uff0c\u53ea\u9700\u77e5\u9053RenderNaniteBasePass\u6e32\u67d3\u7684\u662fNanite\u7269\u4f53\u7684GBuffer<\/p>\n<h4>Render Base Pass<\/h4>\n<p>\u4f9d\u7136\u904d\u5386View\u6e32\u67d3Base Pass<\/p>\n<ul>\n<li>\u5224\u65adLumen\u662f\u5426\u542f\u7528\n<pre><code class=\"language-glsl line-numbers\">const bool bLumenGIEnabled = Renderer.GetViewPipelineState(View).DiffuseIndirectMethod == EDiffuseIndirectMethod::Lumen;\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<h5>\u8ba1\u7b97\u6e32\u67d3\u72b6\u6001<\/h5>\n<pre><code class=\"language-glsl line-numbers\">FMeshPassProcessorRenderState DrawRenderState;\n\nSetupBasePassState(BasePassDepthStencilAccess, ViewFamily.EngineShowFlags.ShaderComplexity, DrawRenderState);\n<\/code><\/pre>\n<pre><code class=\"language-glsl line-numbers\">void SetupBasePassState(FExclusiveDepthStencil::Type BasePassDepthStencilAccess, const bool bShaderComplexity, FMeshPassProcessorRenderState&amp; DrawRenderState)\n{\n    DrawRenderState.SetDepthStencilAccess(BasePassDepthStencilAccess);\n\n    if (bShaderComplexity)\n    {\n        \/\/ Additive blending when shader complexity viewmode is enabled.\n        DrawRenderState.SetBlendState(TStaticBlendState&lt;CW_RGBA, BO_Add, BF_One, BF_One, BO_Add, BF_Zero, BF_One&gt;::GetRHI());\n        \/\/ Disable depth writes as we have a full depth prepass.\n        DrawRenderState.SetDepthStencilState(TStaticDepthStencilState&lt;false, CF_DepthNearOrEqual&gt;::GetRHI());\n    }\n    else\n    {\n        \/\/ Opaque blending for all G buffer targets, depth tests and writes.\n        static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT(\"r.BasePassOutputsVelocityDebug\"));\n        if (CVar &amp;&amp; CVar-&gt;GetValueOnRenderThread() == 2)\n        {\n            DrawRenderState.SetBlendState(TStaticBlendStateWriteMask&lt;CW_RGBA, CW_RGBA, CW_RGBA, CW_RGBA, CW_RGBA, CW_RGBA, CW_NONE&gt;::GetRHI());\n        }\n        else\n        {\n            DrawRenderState.SetBlendState(TStaticBlendStateWriteMask&lt;CW_RGBA, CW_RGBA, CW_RGBA, CW_RGBA&gt;::GetRHI());\n        }\n\n        if (DrawRenderState.GetDepthStencilAccess() &amp; FExclusiveDepthStencil::DepthWrite)\n        {\n            DrawRenderState.SetDepthStencilState(TStaticDepthStencilState&lt;true, CF_DepthNearOrEqual&gt;::GetRHI());\n        }\n        else\n        {\n            DrawRenderState.SetDepthStencilState(TStaticDepthStencilState&lt;false, CF_DepthNearOrEqual&gt;::GetRHI());\n        }\n    }\n}\n<\/code><\/pre>\n<ul>\n<li>DrawRenderState\u8bbe\u7f6e\u6df1\u5ea6\u6a21\u677f\u6d4b\u8bd5<\/li>\n<li>\u5224\u65ad\u662f\u5426\u662fShaderComplexity Debug\u6a21\u5f0f\n<ul>\n<li>\u662f\uff1a\u8bbe\u7f6e\u9002\u5408ShaderComplexity\u7684\u6df1\u5ea6\u6a21\u677f\u6d4b\u8bd5(\u4e0d\u5199\u6df1\u5ea6)\u3001Blend\u6d4b\u8bd5(Additive)<\/li>\n<li>\u5426\uff1a\u8bbe\u7f6eopaque blend<\/li>\n<li>\u5224\u65ad\u662f\u5426Debug Velocity\n<ul>\n<li>\u662f\uff1aGBuffer \u524d6\u4e2aRT\u7684Color \u56db\u901a\u9053\u90fd\u5199\uff0c\u7b2c\u4e03\u4e2aRT\u4e0d\u5199Color\uff0c\u7b2c\u516b\u4e2a\u9ed8\u8ba4Color \u56db\u901a\u9053\u90fd\u5199<\/li>\n<li>\u5426\uff1aGBuffer 8\u4e2aRT\u7684Color \u56db\u901a\u9053\u90fd\u5199<\/li>\n<\/ul>\n<\/li>\n<li>\u5224\u65ad\u662f\u5426Depth Write\n<ul>\n<li>\u662f\uff1a\u542f\u7528\u6df1\u5ea6\u5199\u5165\uff0c\u6df1\u5ea6\u6d4b\u8bd5\u4e3a\u6df1\u5ea6\u503c\u5c0f\u4e8e\u7b49\u4e8e<\/li>\n<li>\u5426\uff1a\u7981\u7528\u6df1\u5ea6\u5199\u5165\uff0c\u6df1\u5ea6\u6d4b\u8bd5\u4e3a\u6df1\u5ea6\u503c\u5c0f\u4e8e\u7b49\u4e8e<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5>\u7ed1\u5b9aPass Parameter<\/h5>\n<pre><code class=\"language-glsl line-numbers\">BEGIN_SHADER_PARAMETER_STRUCT(FOpaqueBasePassParameters, )\n    SHADER_PARAMETER_STRUCT_INCLUDE(FViewShaderParameters, View)\n    SHADER_PARAMETER_STRUCT_REF(FReflectionCaptureShaderData, ReflectionCapture)\n    SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FOpaqueBasePassUniformParameters, BasePass)\n    SHADER_PARAMETER_STRUCT_INCLUDE(FInstanceCullingDrawParams, InstanceCullingDrawParams)\n    RENDER_TARGET_BINDING_SLOTS()\nEND_SHADER_PARAMETER_STRUCT()\n\nBEGIN_SHADER_PARAMETER_STRUCT(FViewShaderParameters, )\n    SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, View)\n    SHADER_PARAMETER_STRUCT_REF(FInstancedViewUniformShaderParameters, InstancedView)\nEND_SHADER_PARAMETER_STRUCT()\n\nBEGIN_GLOBAL_SHADER_PARAMETER_STRUCT(FReflectionCaptureShaderData,)\n    SHADER_PARAMETER_ARRAY(FVector4f,PositionHighAndRadius,[GMaxNumReflectionCaptures])\n    \/\/ W is unused\n    SHADER_PARAMETER_ARRAY(FVector4f,PositionLow,[GMaxNumReflectionCaptures])\n    \/\/ R is brightness, G is array index, B is shape\n    SHADER_PARAMETER_ARRAY(FVector4f,CaptureProperties,[GMaxNumReflectionCaptures])\n    SHADER_PARAMETER_ARRAY(FVector4f,CaptureOffsetAndAverageBrightness,[GMaxNumReflectionCaptures])\n    \/\/ Stores the box transform for a box shape, other data is packed for other shapes\n    SHADER_PARAMETER_ARRAY(FMatrix44f,BoxTransform,[GMaxNumReflectionCaptures])\n    SHADER_PARAMETER_ARRAY(FVector4f,BoxScales,[GMaxNumReflectionCaptures])\nEND_GLOBAL_SHADER_PARAMETER_STRUCT()\n\nBEGIN_GLOBAL_SHADER_PARAMETER_STRUCT(FOpaqueBasePassUniformParameters,)\n    SHADER_PARAMETER_STRUCT(FSharedBasePassUniformParameters, Shared)\n    SHADER_PARAMETER_STRUCT(FSubstrateBasePassUniformParameters, Substrate)\n    \/\/ Forward shading \n    SHADER_PARAMETER(int32, UseForwardScreenSpaceShadowMask)\n    SHADER_PARAMETER_RDG_TEXTURE(Texture2D, ForwardScreenSpaceShadowMaskTexture)\n    SHADER_PARAMETER_RDG_TEXTURE(Texture2D, IndirectOcclusionTexture)\n    SHADER_PARAMETER_RDG_TEXTURE(Texture2D, ResolvedSceneDepthTexture)\n    \/\/ DBuffer decals\n    SHADER_PARAMETER_STRUCT_INCLUDE(FDBufferParameters, DBuffer)\n    \/\/ Misc\n    SHADER_PARAMETER_TEXTURE(Texture2D, PreIntegratedGFTexture)\n    SHADER_PARAMETER_SAMPLER(SamplerState, PreIntegratedGFSampler)\n    SHADER_PARAMETER(int32, Is24BitUnormDepthStencil)\n    SHADER_PARAMETER_RDG_BUFFER_SRV(StructuredBuffer&lt;float4&gt;, EyeAdaptationBuffer)\nEND_GLOBAL_SHADER_PARAMETER_STRUCT()\n\nBEGIN_SHADER_PARAMETER_STRUCT(FInstanceCullingDrawParams, )\n    RDG_BUFFER_ACCESS(DrawIndirectArgsBuffer, ERHIAccess::IndirectArgs)\n    RDG_BUFFER_ACCESS(InstanceIdOffsetBuffer, ERHIAccess::VertexOrIndexBuffer)\n    SHADER_PARAMETER(uint32, InstanceDataByteOffset) \/\/ offset into per-instance buffer\n    SHADER_PARAMETER(uint32, IndirectArgsByteOffset) \/\/ offset into indirect args buffer\n    SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FInstanceCullingGlobalUniforms, InstanceCulling)    \n    SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FSceneUniformParameters, Scene)\n    SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FBatchedPrimitiveParameters, BatchedPrimitive)\nEND_SHADER_PARAMETER_STRUCT()\n<\/code><\/pre>\n<p>Pass Parameter\u5305\u542bView\u3001ReflectionCaptureData\u3001InstanceCulling\u3001OpaqueBasePassUniform<\/p>\n<pre><code class=\"language-glsl line-numbers\">FOpaqueBasePassParameters* PassParameters = GraphBuilder.AllocParameters&lt;FOpaqueBasePassParameters&gt;();\nPassParameters-&gt;View = View.GetShaderParameters();\nPassParameters-&gt;ReflectionCapture = View.ReflectionCaptureUniformBuffer;\nPassParameters-&gt;BasePass = CreateOpaqueBasePassUniformBuffer(GraphBuilder, View, ViewIndex, ForwardBasePassTextures, DBufferTextures, bLumenGIEnabled);\nPassParameters-&gt;RenderTargets = BasePassRenderTargets;\nPassParameters-&gt;RenderTargets.ShadingRateTexture = GVRSImageManager.GetVariableRateShadingImage(GraphBuilder, View, FVariableRateShadingImageManager::EVRSPassType::BasePass);\n\n<\/code><\/pre>\n<h5>Dispatch Base &amp; Sky Pass<\/h5>\n<ul>\n<li>\u5148\u5224\u65adView\u662f\u5426\u53ef\u4ee5\u6267\u884cBase Pass\n<pre><code class=\"language-glsl line-numbers\">const bool bShouldRenderView = View.ShouldRenderView();\n\nbool ShouldRenderView() const \n{\n  if (bHasNoVisiblePrimitive)\n  {\n      return false;\n  }\n  else if (!bIsSinglePassStereo)\n  {\n      return true;\n  }\n  else if (bIsSinglePassStereo &amp;&amp; !IStereoRendering::IsASecondaryPass(StereoPass))\n  {\n      return true;\n  }\n  else\n  {\n      return false;\n  }\n}\n<\/code><\/pre>\n<p>\u82e5\u6ca1\u6709\u53ef\u89c1\u56fe\u5143\u4e0d\u753b<\/p>\n<\/li>\n<li>\n<p>\u82e5View\u53ef\u4ee5\u6267\u884cBase Pass\uff0c\u4e14MeshDrawCommandPasses[EMeshPass::BasePass]\u4e0d\u4e3anull\uff0cDispatch Base Pass<\/p>\n<pre><code class=\"language-glsl line-numbers\">if (auto* Pass = View.ParallelMeshDrawCommandPasses[EMeshPass::BasePass]; Pass &amp;&amp; bShouldRenderView)\n{\n  Pass-&gt;BuildRenderingCommands(GraphBuilder, Scene-&gt;GPUScene, PassParameters-&gt;InstanceCullingDrawParams);\n\n  GraphBuilder.AddDispatchPass(\n      RDG_EVENT_NAME(\"BasePassParallel\"),\n      PassParameters,\n      ERDGPassFlags::Raster,\n      [Pass, PassParameters](FRDGDispatchPassBuilder&amp; DispatchPassBuilder)\n  {\n      Pass-&gt;Dispatch(DispatchPassBuilder, &amp;PassParameters-&gt;InstanceCullingDrawParams);\n  });\n}\n<\/code><\/pre>\n<\/li>\n<li>Dispatch Nanite Base Pass\n<pre><code class=\"language-glsl line-numbers\">const bool bShouldRenderViewForNanite = bNaniteEnabled\n  &amp;&amp; !View.bHasNoVisiblePrimitive\n  &amp;&amp; (!bDrawSceneViewsInOneNanitePass || ViewIndex == 0); \nif (bShouldRenderViewForNanite)\n{\n  check(Renderer.ShouldRenderPrePass());\n\n  RenderNaniteBasePass(View, ViewIndex);\n}\n<\/code><\/pre>\n<\/li>\n<li>Dispatch Sky Atmosphere\n<pre><code class=\"language-glsl line-numbers\">if (auto* Pass = View.ParallelMeshDrawCommandPasses[EMeshPass::SkyPass]; Pass &amp;&amp; bShouldRenderView &amp;&amp; View.Family-&gt;EngineShowFlags.Atmosphere)\n{\n  FOpaqueBasePassParameters* SkyPassPassParameters = GraphBuilder.AllocParameters&lt;FOpaqueBasePassParameters&gt;();\n  SkyPassPassParameters-&gt;BasePass = PassParameters-&gt;BasePass;\n  SkyPassPassParameters-&gt;RenderTargets = BasePassRenderTargets;\n  SkyPassPassParameters-&gt;View = View.GetShaderParameters();\n  SkyPassPassParameters-&gt;ReflectionCapture = View.ReflectionCaptureUniformBuffer;\n\n  \/\/ Remove all but the SceneColor\n  for (uint32 i = 1; i &lt; MaxSimultaneousRenderTargets; ++i)\n  {\n      SkyPassPassParameters-&gt;RenderTargets[i] = FRenderTargetBinding();\n  }\n\n  Pass-&gt;BuildRenderingCommands(GraphBuilder, Scene-&gt;GPUScene, SkyPassPassParameters-&gt;InstanceCullingDrawParams);\n\n  GraphBuilder.AddDispatchPass(\n      RDG_EVENT_NAME(\"SkyPassParallel\"),\n      SkyPassPassParameters,\n      ERDGPassFlags::Raster,\n      [Pass, SkyPassPassParameters](FRDGDispatchPassBuilder&amp; DispatchPassBuilder)\n  {\n      Pass-&gt;Dispatch(DispatchPassBuilder, &amp;SkyPassPassParameters-&gt;InstanceCullingDrawParams);\n  });\n}\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<h4>\u7ed1\u5b9a\u6e32\u67d3\u72b6\u6001<\/h4>\n<p>\u4f9d\u7136Process\u83b7\u53d6\u7ed1\u5b9aShader\u3001\u8bbe\u7f6eDepthStencilc\u6d4b\u8bd5\u3001\u6392\u5e8f\uff0c\u6d41\u7a0b\u4e0e\u4e00\u822c\u7684Pass\u7c7b\u4f3c\uff0c\u4e0d\u518d\u8d58\u8ff0\uff0c\u8fd9\u91cc\u53ea\u63d0\u4e24\u4e2a\u989d\u5916\u7684\u64cd\u4f5c<\/p>\n<ul>\n<li>\u8bbe\u7f6eDecal Stencil Ref\n<pre><code class=\"language-glsl line-numbers\">if (bEnableReceiveDecalOutput)\n{\nuint8 StencilValue = 0;\nStencilValue = \n    GET_STENCIL_BIT_MASK(RECEIVE_DECAL, PrimitiveSceneProxy ? !!PrimitiveSceneProxy-&gt;ReceivesDecals() : 0x00)\n  | GET_STENCIL_BIT_MASK(RAY_TRACING_REPRESENTATION, bHasRayTracingRepresentation)\n  | STENCIL_LIGHTING_CHANNELS_MASK(PrimitiveSceneProxy ? PrimitiveSceneProxy-&gt;GetLightingChannelStencilValue() : 0x00);\n  DrawRenderState.SetStencilRef(StencilValue);\n}\n<\/code><\/pre>\n<p>\u7528\u4e8e\u6807\u8bb0Decal \u6e32\u67d3\u533a\u57df<\/p>\n<\/li>\n<li>\n<p>\u82e5\u6750\u8d28\u7c7b\u578b\u662fTranslucent\uff0c\u800c\u975eopaque\uff0c\u5219\u8bbe\u7f6e\u9002\u5408Translucent\u7684\u6e32\u67d3\u72b6\u6001<\/p>\n<pre><code class=\"language-glsl line-numbers\">if (bTranslucentBasePass)\n{\n  SetTranslucentRenderState(DrawRenderState, MaterialResource, GShaderPlatformForFeatureLevel[FeatureLevel], TranslucencyPassType);\n}\n<\/code><\/pre>\n<\/li>\n<li>\u7ed1\u5b9a\u7684Shader\n<ul>\n<li>VS Shader<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">#define IMPLEMENT_BASEPASS_VERTEXSHADER_TYPE(LightMapPolicyType,LightMapPolicyName) \\\n    typedef TBasePassVS&lt; LightMapPolicyType &gt; TBasePassVS##LightMapPolicyName ; \\\n    IMPLEMENT_MATERIAL_SHADER_TYPE(template&lt;&gt;,TBasePassVS##LightMapPolicyName,TEXT(\"\/Engine\/Private\/BasePassVertexShader.usf\"),TEXT(\"Main\"),SF_Vertex);\n\n<\/code><\/pre>\n<ul>\n<li>PS Shader<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">#define IMPLEMENT_BASEPASS_PIXELSHADER_TYPE(LightMapPolicyType,LightMapPolicyName,bEnableSkyLight,SkyLightName,GBufferLayout,LayoutName) \\\n    typedef TBasePassPS&lt;LightMapPolicyType, bEnableSkyLight, GBufferLayout&gt; TBasePassPS##LightMapPolicyName##SkyLightName##LayoutName; \\\n    IMPLEMENT_MATERIAL_SHADER_TYPE(template&lt;&gt;,TBasePassPS##LightMapPolicyName##SkyLightName##LayoutName,TEXT(\"\/Engine\/Private\/BasePassPixelShader.usf\"),TEXT(\"MainPS\"),SF_Pixel);\n\n#define IMPLEMENT_BASEPASS_COMPUTESHADER_TYPE(LightMapPolicyType,LightMapPolicyName,bEnableSkyLight,SkyLightName,bVoxel,VoxelName) \\\n    typedef TBasePassCS&lt;LightMapPolicyType, bEnableSkyLight, bVoxel, SF_Compute&gt; TBasePassCS##LightMapPolicyName##SkyLightName##VoxelName; \\\n    IMPLEMENT_MATERIAL_SHADER_TYPE(template&lt;&gt;,TBasePassCS##LightMapPolicyName##SkyLightName##VoxelName,TEXT(\"\/Engine\/Private\/BasePassPixelShader.usf\"),TEXT(\"MainCS\"),SF_Compute);\n\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2>GPU\u7aef<\/h2>\n<p><img decoding=\"async\"   class=\"lazyload\" data-src=\"https:\/\/pic1.imgdb.cn\/item\/6a53c5324893f89183bb0bfe.png\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\" \/><br \/ >\n<noscript><img decoding=\"async\" src=\"https:\/\/pic1.imgdb.cn\/item\/6a53c5324893f89183bb0bfe.png\" alt=\"\" \/><br \/><\/noscript>\nGPU\u7aef\u6d41\u7a0b\u5927\u81f4\u5982\u4e0a\u56fe\u6240\u793a<\/p>\n<h3>BasePassVertexShader<\/h3>\n<ul>\n<li>\u4f9d\u7136\u662f\u8ba1\u7b97World Position\u3001Clip Position\n<pre><code class=\"language-glsl line-numbers\">FVertexFactoryIntermediates VFIntermediates = GetVertexFactoryIntermediates(Input);\nfloat4 WorldPositionExcludingWPO = VertexFactoryGetWorldPosition(Input, VFIntermediates);\nfloat4 WorldPosition = WorldPositionExcludingWPO;\nfloat4 ClipSpacePosition;\n\nfloat3x3 TangentToLocal = VertexFactoryGetTangentToLocal(Input, VFIntermediates); \nFMaterialVertexParameters VertexParameters = GetMaterialVertexParameters(Input, VFIntermediates, WorldPosition.xyz, TangentToLocal);\n\nWorldPosition.xyz += GetMaterialWorldPositionOffset(VertexParameters);\nApplyMaterialFirstPersonTransform(VertexParameters, WorldPosition.xyz);\n\nfloat4 RasterizedWorldPosition = VertexFactoryGetRasterizedWorldPosition(Input, VFIntermediates, WorldPosition);\nClipSpacePosition = mul(RasterizedWorldPosition, ResolvedView.TranslatedWorldToClip)\n\nOutput.Position = INVARIANT(ClipSpacePosition);\n<\/code><\/pre>\n<\/li>\n<li>\u534a\u900f\u660e\u96fe\u6548\n<ul>\n<li>\u534a\u900f\u660e\u4e14\u6ca1\u6709\u542f\u7528per-pixel fog\uff0c\u6216 Forward Shading \u4e0d\u900f\u660e\u7269\u4f53\u4e14\u542f\u7528 opaque vertex fogging<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">#define NEEDS_BASEPASS_VERTEX_FOGGING     (TRANSLUCENCY_NEEDS_BASEPASS_FOGGING &amp;&amp; !MATERIAL_COMPUTE_FOG_PER_PIXEL || OPAQUE_NEEDS_BASEPASS_FOGGING &amp;&amp; PROJECT_VERTEX_FOGGING_FOR_OPAQUE)\n\n<\/code><\/pre>\n<ul>\n<li>\u8ba1\u7b97\u9ad8\u5ea6\u96fe<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">Output.BasePassInterpolants.VertexFog = CalculateHeightFog(WorldPosition.xyz - ResolvedView.TranslatedWorldCameraOrigin, EyeIndex, ResolvedView); \/\/ WorldPosition is in fact TranslatedWorldPosition \n<\/code><\/pre>\n<ul>\n<li>\u8ba1\u7b97\u5927\u6c14\u900f\u89c6<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">const float OneOverPreExposure = ResolvedView.OneOverPreExposure;\n\n#if PROJECT_SUPPORT_SKY_ATMOSPHERE &amp;&amp; BASEPASS_SKYATMOSPHERE_AERIALPERSPECTIVE &amp;&amp; MATERIAL_IS_SKY==0 \/\/ Do not apply aerial perpsective on sky materials\nif (ResolvedView.SkyAtmosphereApplyCameraAerialPerspectiveVolume &gt; 0.0f)\n{\n    Output.BasePassInterpolants.VertexFog = GetAerialPerspectiveLuminanceTransmittanceWithFogOver(\n        ResolvedView.RealTimeReflectionCapture, ResolvedView.SkyAtmosphereCameraAerialPerspectiveVolumeSizeAndInvSize,\n        Output.Position, (WorldPosition.xyz - ResolvedView.TranslatedWorldCameraOrigin) * CM_TO_SKY_UNIT,\n        View.CameraAerialPerspectiveVolume, View.CameraAerialPerspectiveVolumeSampler,\n        ResolvedView.SkyAtmosphereCameraAerialPerspectiveVolumeDepthResolutionInv,\n        ResolvedView.SkyAtmosphereCameraAerialPerspectiveVolumeDepthResolution,\n        ResolvedView.SkyAtmosphereAerialPerspectiveStartDepthKm,\n        ResolvedView.SkyAtmosphereCameraAerialPerspectiveVolumeDepthSliceLengthKm,\n        ResolvedView.SkyAtmosphereCameraAerialPerspectiveVolumeDepthSliceLengthKmInv,\n        OneOverPreExposure, Output.BasePassInterpolants.VertexFog);\n}\n#endif\n<\/code><\/pre>\n<ul>\n<li>\u7ed9\u534a\u900f\u660e\u6dfb\u52a0\u5c40\u90e8\u4f53\u79ef\u96fe<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">#if LOCAL_FOG_VOLUME_ON_TRANSLUCENT\n    float4 VertexClipSpacePosition          = mul(float4(WorldPosition.xyz, 1), ResolvedView.TranslatedWorldToClip);\n    float2 SvPosition                       = (VertexClipSpacePosition.xy \/ VertexClipSpacePosition.w * float2(.5f, -.5f) + .5f) * ResolvedView.ViewSizeAndInvSize.xy;\n    uint2 TilePos                           = clamp(uint2(SvPosition.xy \/ float(LFVTilePixelSize)), uint2(0, 0), LFVTileDataResolution - 1);\n    float4 LFVContribution                  = GetLFVContribution(ResolvedView, TilePos, WorldPosition.xyz);\n    Output.BasePassInterpolants.VertexFog   = float4(LFVContribution.rgb + Output.BasePassInterpolants.VertexFog.rgb * LFVContribution.a, LFVContribution.a * Output.BasePassInterpolants.VertexFog.a);\n#endif\n\n#if MATERIAL_ENABLE_TRANSLUCENCY_CLOUD_FOGGING\n    if (TranslucentBasePass.ApplyVolumetricCloudOnTransparent &gt; 0.0f)\n    {\n        Output.BasePassInterpolants.VertexFog = GetCloudLuminanceTransmittanceOverFog(\n            Output.Position, WorldPosition.xyz, ResolvedView.TranslatedWorldCameraOrigin,\n            TranslucentBasePass.VolumetricCloudColor, TranslucentBasePass.VolumetricCloudColorSampler,\n            TranslucentBasePass.VolumetricCloudDepth, TranslucentBasePass.VolumetricCloudDepthSampler,\n            OneOverPreExposure, Output.BasePassInterpolants.VertexFog, TranslucentBasePass.SoftBlendingDistanceKm, \n            TranslucentBasePass.VolumetricCloudColorUVScale, TranslucentBasePass.VolumetricCloudColorUVMax);\n    }\n#endif\n\n<\/code><\/pre>\n<ul>\n<li>\u8ba1\u7b97\u9876\u70b9\u7740\u8272<\/p>\n<\/li>\n<li>\n<p>\u9884\u8ba1\u7b97\u95f4\u63a5\u5149 per-vertex \u91c7\u6837<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">#if PRECOMPUTED_IRRADIANCE_VOLUME_LIGHTING &amp;&amp; TRANSLUCENCY_ANY_PERVERTEX_LIGHTING\n    float3 BrickTextureUVs = ComputeVolumetricLightmapBrickTextureUVs(WorldPositionForVertexLighting);\n\n    #if TRANSLUCENCY_LIGHTING_VOLUMETRIC_PERVERTEX_NONDIRECTIONAL\n        FOneBandSHVectorRGB IrradianceSH = GetVolumetricLightmapSH1(BrickTextureUVs);\n        Output.BasePassInterpolants.VertexIndirectAmbient = float3(IrradianceSH.R.V, IrradianceSH.G.V, IrradianceSH.B.V);\n    #elif TRANSLUCENCY_LIGHTING_VOLUMETRIC_PERVERTEX_DIRECTIONAL\n        \/\/ Need to interpolate directional lighting so we can incorporate a normal in the pixel shader\n        FTwoBandSHVectorRGB IrradianceSH = GetVolumetricLightmapSH2(BrickTextureUVs);\n        Output.BasePassInterpolants.VertexIndirectSH[0] = IrradianceSH.R.V;\n        Output.BasePassInterpolants.VertexIndirectSH[1] = IrradianceSH.G.V;\n        Output.BasePassInterpolants.VertexIndirectSH[2] = IrradianceSH.B.V;\n    #endif\n#endif\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>\u8fd9\u91cc\u63d0\u5230\u7684\u96fe\u6548\u4ee5\u540e\u4f1a\u5728\u96fe\u6548\u4e13\u680f\u5206\u6790<\/p>\n<h3>BasePassPixelShader<\/h3>\n<p>Pixel Shader\u7684\u4e3b\u8981\u903b\u8f91\u7531FPixelShaderInOut_MainPS()\u9a71\u52a8<\/p>\n<h4>\u521d\u59cb\u5316<\/h4>\n<pre><code class=\"language-glsl line-numbers\">FMaterialPixelParameters MaterialParameters = GetMaterialPixelParameters(Interpolants, In.SvPosition);\nFPixelMaterialInputs PixelMaterialInputs;\n<\/code><\/pre>\n<ul>\n<li>\u8ba1\u7b97Lightmap VT Page Table\n<pre><code class=\"language-glsl line-numbers\">VTPageTableResult LightmapVTPageTableResult = (VTPageTableResult)0.0f;\n#if LIGHTMAP_VT_ENABLED\n{\n    LightmapUVType LightmapUV0, LightmapUV1;\n    uint LightmapDataIndex;\n    GetLightMapCoordinates(Interpolants, LightmapUV0, LightmapUV1, LightmapDataIndex);\n    LightmapVTPageTableResult = LightmapGetVTSampleInfo(LightmapUV0, LightmapDataIndex, In.SvPosition.xy);\n}\n#endif\n<\/code><\/pre>\n<\/li>\n<li>\u4eceLightmap\u91c7\u6837AO\n<pre><code class=\"language-glsl line-numbers\">#if HQ_TEXTURE_LIGHTMAP &amp;&amp; USES_AO_MATERIAL_MASK &amp;&amp; !MATERIAL_SHADINGMODEL_UNLIT\n{\n    LightmapUVType LightmapUV0, LightmapUV1;\n    uint LightmapDataIndex;\n    GetLightMapCoordinates(Interpolants, LightmapUV0, LightmapUV1, LightmapDataIndex);\n    \/\/ Must be computed before BaseColor, Normal, etc are evaluated\n    MaterialParameters.AOMaterialMask = GetAOMaterialMask(LightmapVTPageTableResult, ScaleLightmapUV(LightmapUV0, float2(1, 2)), LightmapDataIndex, In.SvPosition.xy);\n}\n#endif\n<\/code><\/pre>\n<\/li>\n<li>\u8ba1\u7b97World Position\uff0c\u4e14\u4f7f\u7528World Position\u8ba1\u7b97\u6cd5\u7ebf\u3001UV\u3001ScreenPos\u7b49\n<pre><code class=\"language-glsl line-numbers\">float4 ScreenPosition = SvPositionToResolvedScreenPosition(In.SvPosition);\nfloat3 TranslatedWorldPosition = SvPositionToResolvedTranslatedWorld(In.SvPosition);\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<h4>\u6df1\u5ea6\u504f\u79fb\u4e0e\u88c1\u526a<\/h4>\n<ul>\n<li>\u6df1\u5ea6\u504f\u79fb\n<pre><code class=\"line-numbers\">#if OUTPUT_PIXEL_DEPTH_OFFSET\nApplyPixelDepthOffsetForBasePass(MaterialParameters, PixelMaterialInputs, BasePassInterpolants, Out.Depth);\n\n#if APPLE_DEPTH_BIAS_HACK\nOut.Depth -= APPLE_DEPTH_BIAS_VALUE;\n#endif\n#endif\n<\/code><\/pre>\n<\/li>\n<li>\u5f53Mask\u6ca1\u6709\u5728 PrePass \u6267\u884c\u8fc7 Clip\uff0c\u8fd9\u91cc\u6267\u884cClip\n<pre><code class=\"language-glsl line-numbers\">#if !EARLY_Z_PASS_ONLY_MATERIAL_MASKING\nif (!bEditorWeightedZBuffering)\n{\n#if MATERIALBLENDING_MASKED_USING_COVERAGE\n    Out.Coverage = DiscardMaterialWithPixelCoverage(MaterialParameters, PixelMaterialInputs);\n#else\n    GetMaterialCoverageAndClipping(MaterialParameters, PixelMaterialInputs);\n#endif\n}\n#endif\n<\/code><\/pre>\n<p>\u5206\u6210\u4e24\u6761\u8def\uff1a<\/p>\n<ul>\n<li>\u666e\u901aMask\uff1aClip<\/li>\n<li>Alpha-to-Coverage\uff1a\u5199 Coverage<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>\u83b7\u53d6\u6750\u8d28\u5c5e\u6027\uff0c\u5199\u5165GBuffer<\/h4>\n<pre><code class=\"language-glsl line-numbers\">half3 BaseColor = GetMaterialBaseColor(PixelMaterialInputs);\nhalf  Metallic = GetMaterialMetallic(PixelMaterialInputs);\nhalf  Specular = GetMaterialSpecular(PixelMaterialInputs);\n\nfloat Roughness = GetMaterialRoughness(PixelMaterialInputs);\nfloat Anisotropy = GetMaterialAnisotropy(PixelMaterialInputs);\nuint ShadingModel = GetMaterialShadingModel(PixelMaterialInputs);\nhalf Opacity = GetMaterialOpacity(PixelMaterialInputs);\nfloat MaterialAO = GetMaterialAmbientOcclusion(PixelMaterialInputs);\n\nfloat4 SubsurfaceData = GetMaterialSubsurfaceData(PixelMaterialInputs);\n\nconst float BaseMaterialCoverageOverWater = Opacity;\nconst float WaterVisibility = 1.0 - BaseMaterialCoverageOverWater;\n\nfloat3 VolumetricLightmapBrickTextureUVs;\n#if PRECOMPUTED_IRRADIANCE_VOLUME_LIGHTING\n    VolumetricLightmapBrickTextureUVs = ComputeVolumetricLightmapBrickTextureUVs(WSHackToFloat(GetWorldPosition(MaterialParameters)));\n#endif\n<\/code><\/pre>\n<p>\u83b7\u53d6\u6750\u8d28\u5c5e\u6027<\/p>\n<pre><code class=\"language-glsl line-numbers\">FGBufferData GBuffer = (FGBufferData)0;\n\nGBuffer.GBufferAO = MaterialAO;\nGBuffer.PerObjectGBufferData = GetPrimitive_PerObjectGBufferData(MaterialParameters.PrimitiveId);\nGBuffer.Depth = MaterialParameters.ScreenPosition.w;\nGBuffer.PrecomputedShadowFactors = GetPrecomputedShadowMasks(LightmapVTPageTableResult, Interpolants, MaterialParameters, VolumetricLightmapBrickTextureUVs);\n\nSetGBufferForShadingModel(\n        GBuffer,\n        MaterialParameters,\n        PixelMaterialInputs,\n        Opacity,\n        BaseColor,\n        Metallic,\n        Specular,\n        Roughness,\n        Anisotropy,\n        SubsurfaceColor,\n        SubsurfaceProfile,\n        Dither,\n        ShadingModel\n        );\n<\/code><\/pre>\n<p>\u5c06\u6750\u8d28\u5c5e\u6027\u586b\u8fdb\u5bf9\u5e94GBuffer<\/p>\n<h4>DBuffer<\/h4>\n<pre><code class=\"language-glsl line-numbers\">if ((GetPrimitiveData(MaterialParameters).Flags &amp; PRIMITIVE_SCENE_DATA_FLAG_DECAL_RECEIVER) != 0 &amp;&amp; View.ShowDecalsMask &gt; 0)\n{\n    uint ValidDBufferTargetMask = GetDBufferTargetMask(uint2(In.SvPosition.xy)) &amp; MATERIALDECALRESPONSEMASK;\n\n    if (ValidDBufferTargetMask)\n    {\n        float2 BufferUV = SvPositionToBufferUV(In.SvPosition);\n        FDBufferData DBufferData = GetDBufferData(BufferUV, ValidDBufferTargetMask);\n        ApplyDBufferData(DBufferData, MaterialParameters.WorldNormal, SubsurfaceColor, Roughness, BaseColor, Metallic, Specular);\n    }\n}\n<\/code><\/pre>\n<p>\u83b7\u53d6DBuffer\u4fe1\u606f\uff0c\u5199\u5165\u6750\u8d28\u5c5e\u6027<\/p>\n<h4>\u5149\u7167\u524d\u51c6\u5907\u5de5\u4f5c<\/h4>\n<ul>\n<li>\u83b7\u53d6\u9884\u8ba1\u7b97\u9634\u5f71\n<pre><code class=\"language-glsl line-numbers\">GBuffer.PrecomputedShadowFactors = GetPrecomputedShadowMasks(LightmapVTPageTableResult, Interpolants, MaterialParameters, VolumetricLightmapBrickTextureUVs);\n<\/code><\/pre>\n<\/li>\n<li>\u9700\u8981\u65f6\u5199\u5165GBuffer &amp; \u83b7\u53d6Velocity\n<pre><code class=\"language-glsl line-numbers\">#if WRITES_VELOCITY_TO_GBUFFER\nBRANCH\nif ((GetPrimitiveData(MaterialParameters).Flags &amp; PRIMITIVE_SCENE_DATA_FLAG_OUTPUT_VELOCITY) != 0)\n{\n    \/\/ 2d velocity, includes camera an object motion\n#if IS_NANITE_PASS\n    float3 Velocity = Calculate3DVelocity(MaterialParameters.ScreenPosition, MaterialParameters.PrevScreenPosition);\n#else\n    float3 Velocity = Calculate3DVelocity(MaterialParameters.ScreenPosition, BasePassInterpolants.VelocityPrevScreenPosition);\n#endif\n    float TemporalResponsiveness = GetMaterialTemporalResponsiveness(MaterialParameters);   \n    float4 EncodedVelocity = EncodeVelocityToTexture(Velocity, (GetPrimitiveData(MaterialParameters).Flags &amp; PRIMITIVE_SCENE_DATA_FLAG_HAS_PIXEL_ANIMATION) != 0, TemporalResponsiveness);\n\n#if USES_GBUFFER\n    GBuffer.Velocity = EncodedVelocity;\n#else\n    OutVelocity = EncodedVelocity;\n#endif\n}\n#endif\n<\/code><\/pre>\n<\/li>\n<li>\u83b7\u53d6F0\u3001DiffuseColor\n<pre><code class=\"language-glsl line-numbers\">GBuffer.SpecularColor = ComputeF0(Specular, BaseColor, Metallic);\n\nGBuffer.DiffuseColor = BaseColor - BaseColor * Metallic;\n<\/code><\/pre>\n<\/li>\n<li>\u83b7\u53d6SubsurfaceProfile\n<pre><code class=\"language-glsl line-numbers\">if (UseSubsurfaceProfile(GBuffer.ShadingModelID))\n{\n  AdjustBaseColorAndSpecularColorForSubsurfaceProfileLighting(BaseColor, GBuffer.SpecularColor, Specular, bChecker);\n}\n<\/code><\/pre>\n<p>checkerboard \u4e0b\u62c6\u5206 diffuse\/specular<\/p>\n<\/li>\n<li>\n<p>\u83b7\u53d6BentNormal<\/p>\n<pre><code class=\"language-glsl line-numbers\">float3 InputBentNormal = MaterialParameters.WorldNormal;\n\nBRANCH if( GBuffer.ShadingModelID == SHADINGMODELID_CLEAR_COAT &amp;&amp; CLEAR_COAT_BOTTOM_NORMAL)\n{\n  const float2 oct1 = ((float2(GBuffer.CustomData.a, GBuffer.CustomData.z) * 4) - (512.0\/255.0)) + UnitVectorToOctahedron(GBuffer.WorldNormal);\n  InputBentNormal = OctahedronToUnitVector(oct1);\n}\n<\/code><\/pre>\n<p>\u82e5\u4e0d\u5904\u4e8eclear coat\uff0cBentNormal\u4e3aWorldNormal\uff0c\u5426\u5219\u9700\u8981\u989d\u5916\u8ba1\u7b97<\/p>\n<pre><code class=\"language-glsl line-numbers\">const FShadingOcclusion ShadingOcclusion = ApplyBentNormal(MaterialParameters.CameraVector, InputBentNormal, GetWorldBentNormalZero(MaterialParameters), GBuffer.Roughness, MaterialAO);\n<\/code><\/pre>\n<\/li>\n<li>AOMultiBounce\n<pre><code class=\"line-numbers\">GBuffer.GBufferAO = AOMultiBounce( Luminance( GBuffer.SpecularColor ), ShadingOcclusion.SpecOcclusion ).g;\n<\/code><\/pre>\n<p>\u5bf9\u5df2\u7ecf\u6709\u7684AO\u505a\u4e00\u6b21\u6709\u989c\u8272\u7684\u8fd1\u4f3c\u4fee\u6b63\uff0c\u7528 albedo + \u5355\u6b21 AO \u62df\u5408\u201c\u7f1d\u9699\u91cc\u591a\u6b21\u53cd\u5f39\u201d\u7684\u7ed3\u679c<\/p>\n<\/li>\n<li>\n<p>\u8ba1\u7b97\u6f2b\u53cd\u5c04\u95f4\u63a5\u91c7\u6837\u65b9\u5411\u662f\u5426\u88ab\u906e\u6321\u7684AO<\/p>\n<pre><code class=\"language-glsl line-numbers\">#if !SUBSTRATE_INLINE_SINGLELAYERWATER\nGBuffer.DiffuseIndirectSampleOcclusion = GetDiffuseIndirectSampleOcclusion(GBuffer, MaterialParameters.CameraVector, MaterialParameters.WorldNormal, GetWorldBentNormalZero(MaterialParameters), In.SvPosition.xy, MaterialAO);\n#endif    \n<\/code><\/pre>\n<p>\u6839\u636ebent normal\u3001material AO\u8ba1\u7b97\u5e26\u65b9\u5411\u7684 AO<\/p>\n<p>GBuffer.DiffuseIndirectSampleOcclusion  \/\/ uint\uff0c\u6bcf\u4f4d\u5bf9\u5e94\u4e00\u6761\u91c7\u6837\u65b9\u5411<br \/>\n\u7ed9\u540e\u7eed\u95f4\u63a5\u6f2b\u53cd\u5c04\u7528\u7684 per-direction occlusion mask<\/p>\n<\/li>\n<\/ul>\n<h4>\u5149\u7167\u8ba1\u7b97<\/h4>\n<ul>\n<li>\n<p>\u8ba1\u7b97\u9884\u8ba1\u7b97\u7b80\u63a5\u5149\u7167\u4e0e\u5929\u5149<\/p>\n<ul>\n<li>\u8ba1\u7b97\u95f4\u63a5\u6f2b\u53cd\u5c04\u4f7f\u7528\u7684Dir\u4e0eAlebdo<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">float3 DiffuseDir = ShadingOcclusion.BentNormal;\nfloat3 DiffuseColorForIndirect = GBuffer.DiffuseColor;\n<\/code><\/pre>\n<p>\u5f53\u7136\u4e0d\u540cshading model\u7684Dir\u3001Alebdo\u90fd\u4e0d\u540c<\/p>\n<ul>\n<li>\u8ba1\u7b97\u9884\u8ba1\u7b97\u95f4\u63a5\u5149\u662f\u5426\u9700\u8981\u8ba1\u7b97\u80cc\u9762<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">const bool bEvaluateBackface = GetShadingModelRequiresBackfaceLighting(GBuffer.ShadingModelID);\n<\/code><\/pre>\n<p>\u53ea\u6709\u6811\u53f6\u9700\u8981<\/p>\n<ul>\n<li>\u8ba1\u7b97\u9884\u8ba1\u7b97\u7b80\u4ecb\u5149\u7167\u4e0e\u5929\u5149<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">GetPrecomputedIndirectLightingAndSkyLight(MaterialParameters, Interpolants, BasePassInterpolants, LightmapVTPageTableResult, bEvaluateBackface, DiffuseDir, VolumetricLightmapBrickTextureUVs, DiffuseIndirectLighting, SubsurfaceIndirectLighting, IndirectIrradiance);\n<\/code><\/pre>\n<\/li>\n<li>\u8ba1\u7b97\u5f97\u5230\u7684\u95f4\u63a5\u5149\u5199\u5165DiffuseColor\n<pre><code class=\"language-glsl line-numbers\">DiffuseColor += (DiffuseIndirectLighting * DiffuseColorForIndirect + SubsurfaceIndirectLighting * SubsurfaceColor) * AOMultiBounce( GBuffer.BaseColor, ShadingOcclusion.DiffOcclusion );\n<\/code><\/pre>\n<\/li>\n<li>\u6df7\u5408\u96fe\u3001\u5927\u6c14\u3001\u4e91\u3001\u4f53\u79ef\u9634\u5f71\n<ul>\n<li>Fog\u7ec4\u6210<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">float4 Fogging; \n<\/code><\/pre>\n<p>.rgb = \u96fe\u672c\u8eab\u53d1\u51fa\/\u6563\u5c04\u7684\u5149\uff08in-scatter\uff09<\/p>\n<p>.a   = \u5230\u8868\u9762\u7684\u900f\u8fc7\u7387 transmittance\uff081=\u5168\u900f\uff0c0=\u5168\u6321\uff09<\/p>\n<ul>\n<li>\u4f7f\u7528\u9876\u70b9\u96fe\u8fd8\u662f\u50cf\u7d20\u96fe<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">#if NEEDS_BASEPASS_VERTEX_FOGGING\n    float4 HeightFogging = BasePassInterpolants.VertexFog;\n#elif NEEDS_BASEPASS_PIXEL_FOGGING\n    float4 HeightFogging = CalculateHeightFog(MaterialParameters.WorldPosition_CamRelative, EyeIndex, ResolvedView);\n    #if LOCAL_FOG_VOLUME_ON_TRANSLUCENT\n    const float4 LocalFogVolumeContrib = BasePassInterpolants.VertexFog;\n    HeightFogging = float4(LocalFogVolumeContrib.rgb + HeightFogging.rgb * LocalFogVolumeContrib.a, LocalFogVolumeContrib.a * HeightFogging.a);\n    #endif \/\/ LOCAL_FOG_VOLUME_ON_TRANSLUCENT\n#else\n    float4 HeightFogging = float4(0,0,0,1);\n#endif\n<\/code><\/pre>\n<p>\u82e5\u4f7f\u7528\u9876\u70b9\u96fe\uff0c\u76f4\u63a5\u4f7f\u7528Vertex Shader\u7684\u8ba1\u7b97\u7ed3\u679c\u5373\u53ef<\/p>\n<p>\u82e5\u4f7f\u7528\u50cf\u7d20\u96fe\uff0c\u5219\u9700\u8ba1\u7b97\u9ad8\u5ea6\u96fe<\/p>\n<p>\u82e5\u534a\u900f\u660e\u4e14\u5c40\u90e8\u96fe\uff0cVertex Shader\u8ba1\u7b97\u7684 Local Fog Volume \u518d over \u5230\u9ad8\u5ea6\u96fe\u4e0a<\/p>\n<ul>\n<li>\u5e94\u7528\u5728\u534a\u900f\u660e\u7684\u50cf\u7d20\u7ea7\u522b\u5c40\u90e8\u96fe<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">float3 TranslatedWorldPosition = SvPositionToResolvedTranslatedWorld(In.SvPosition);\nuint2 TilePos = clamp(uint2(In.SvPosition.xy \/ float(LFVTilePixelSize)), uint2(0, 0), LFVTileDataResolution - 1);\nfloat4 LocalFogVolumeContrib = GetLFVContribution(ResolvedView, TilePos, TranslatedWorldPosition);\nFogging = float4(LocalFogVolumeContrib.rgb + Fogging.rgb * LocalFogVolumeContrib.a, LocalFogVolumeContrib.a * Fogging.a);\n<\/code><\/pre>\n<p>\u4e0a\u4e00\u6b65\u53e0\u52a0\u7684\u662f\u9876\u70b9\u7ea7\u522b\u7684\u5c40\u90e8\u96fe\uff0c\u8fd9\u91cc\u53e0\u52a0\u7684\u662f\u50cf\u7d20\u7ea7\u522b<\/p>\n<ul>\n<li>\u6b65\u9aa4\n<ul>\n<li>\u6309\u50cf\u7d20\u4f4d\u7f6e\u67e5 LFV tile \u2192 GetLFVContribution<\/li>\n<li>over \u8fdb Fog<\/li>\n<\/ul>\n<\/li>\n<li>Volumetric Fog<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">float3 VolumeUV = ComputeVolumeUV(MaterialParameters.AbsoluteWorldPosition, ResolvedView.WorldToClip, ResolvedView);\nFogging = CombineVolumetricFog(Fogging, VolumeUV, EyeIndex, GBuffer.Depth, ResolvedView);\n<\/code><\/pre>\n<p>\u91c7\u6837 3D \u4f53\u79ef\u96fe\uff0c\u5408\u5e76\u8fdb Fogging<\/p>\n<ul>\n<li>\u8ba1\u7b97\u96fe\u6548\u7684\u9634\u5f71<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">float2 NDC = MaterialParameters.ScreenPosition.xy \/ MaterialParameters.ScreenPosition.w;\nfloat2 ScreenUV = NDC * ResolvedView.ScreenPositionScaleBias.xy + ResolvedView.ScreenPositionScaleBias.wz;\nfloat3 TranslatedWorldPosition = SvPositionToResolvedTranslatedWorld(In.SvPosition);\nfloat4 HeterogeneousVolumeResult = saturate(AVSM_SampleCameraRadianceAndTransmittance4(ScreenUV, TranslatedWorldPosition, ResolvedView.TranslatedWorldCameraOrigin));\nFogging.rgb = HeterogeneousVolumeResult.rgb + Fogging.rgb * HeterogeneousVolumeResult.a;\nFogging.a *= HeterogeneousVolumeResult.a;\n<\/code><\/pre>\n<p>\u8fd9\u662f\u81ea\u9002\u5e94Volumetric Shadow Map\uff0c\u540e\u7eed\u4e13\u95e8\u5f00\u7bc7\u8bb2\u89e3<\/p>\n<ul>\n<li>\u5e94\u7528\u5927\u6c14\u6563\u5c04<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">if (ResolvedView.SkyAtmosphereApplyCameraAerialPerspectiveVolume &gt; 0.0f)\n{\n    \/\/ Sample the aerial perspective (AP).\n    Fogging = GetAerialPerspectiveLuminanceTransmittanceWithFogOver(\n        ResolvedView.RealTimeReflectionCapture, ResolvedView.SkyAtmosphereCameraAerialPerspectiveVolumeSizeAndInvSize,\n        NDCPosition, MaterialParameters.WorldPosition_CamRelative * CM_TO_SKY_UNIT,\n        View.CameraAerialPerspectiveVolume, SkyAtmAerialPerspecSharedSampler,\n        ResolvedView.SkyAtmosphereCameraAerialPerspectiveVolumeDepthResolutionInv,\n        ResolvedView.SkyAtmosphereCameraAerialPerspectiveVolumeDepthResolution,\n        ResolvedView.SkyAtmosphereAerialPerspectiveStartDepthKm,\n        ResolvedView.SkyAtmosphereCameraAerialPerspectiveVolumeDepthSliceLengthKm,\n        ResolvedView.SkyAtmosphereCameraAerialPerspectiveVolumeDepthSliceLengthKmInv,\n        OneOverPreExposure, Fogging);\n}\n<\/code><\/pre>\n<ul>\n<li>\u82e5\u534a\u900f\u660e\uff0c\u5e94\u7528\u4f53\u79ef\u4e91<\/li>\n<\/ul>\n<pre><code class=\"language-glsl line-numbers\">if (TranslucentBasePass.ApplyVolumetricCloudOnTransparent &gt; 0.0f)\n{\n    Fogging = GetCloudLuminanceTransmittanceOverFog(\n        NDCPosition, GetTranslatedWorldPosition(MaterialParameters), ResolvedView.TranslatedWorldCameraOrigin,\n        TranslucentBasePass.VolumetricCloudColor, TranslucentBasePass.VolumetricCloudColorSampler,\n        TranslucentBasePass.VolumetricCloudDepth, TranslucentBasePass.VolumetricCloudDepthSampler,\n        OneOverPreExposure, Fogging, TranslucentBasePass.SoftBlendingDistanceKm, \n        TranslucentBasePass.VolumetricCloudColorUVScale, TranslucentBasePass.VolumetricCloudColorUVMax);\n}\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<h4>Emissive\u4e0e\u7279\u6b8a\u6a21\u578b<\/h4>\n<ul>\n<li>\u8ba1\u7b97\u534a\u900f\u660e\u5149\u7167\u4f53\u79ef\n<pre><code class=\"language-glsl line-numbers\">if (GBuffer.ShadingModelID == SHADINGMODELID_DEFAULT_LIT || GBuffer.ShadingModelID == SHADINGMODELID_SUBSURFACE)\n{\n  float3 TLVDiffuseLighting;\n  float3 TLVSpecularLighting;\n  GetTranslucencyVolumeLighting(MaterialParameters, PixelMaterialInputs, BasePassInterpolants, GBuffer, IndirectIrradiance, TLVDiffuseLighting, TLVSpecularLighting);\n  Color += TLVDiffuseLighting;\n  Color += TLVSpecularLighting;\n}\n<\/code><\/pre>\n<\/li>\n<li>\u5f97\u5230\u6750\u8d28\u84dd\u56fe\u4f20\u9012\u7684Emissive\uff0c\u5408\u5e76DiffuseColor\u3001Emissive\n<pre><code class=\"language-glsl line-numbers\">Emissive = GetMaterialEmissive(PixelMaterialInputs);\n\nColor += DiffuseColor;\nColor += Emissive;\n<\/code><\/pre>\n<\/li>\n<li>\u8ba1\u7b97Single Layer Water\u7684\u4f53\u79ef\u5149\u7167\n<pre><code class=\"language-glsl line-numbers\">#if MATERIAL_SHADINGMODEL_SINGLELAYERWATER || SUBSTRATE_INLINE_SINGLELAYERWATER\n{\n    const bool CameraIsUnderWater = false;  \/\/ Fade out the material contribution over to water contribution according to material opacity.\n    float3 SunIlluminance = ResolvedView.DirectionalLightColor.rgb * PI;    \/\/ times PI because it is divided by PI on CPU (=luminance) and we want illuminance here. \n    float3 WaterDiffuseIndirectIlluminance = DiffuseIndirectLighting * PI;\/\/ DiffuseIndirectLighting is luminance. So we need to multiply by PI to get illuminance.\n#if USE_DEVELOPMENT_SHADERS\n    SunIlluminance = lerp(SunIlluminance, 0.0f, View.UnlitViewmodeMask);\n    WaterDiffuseIndirectIlluminance = lerp(WaterDiffuseIndirectIlluminance, PI, View.UnlitViewmodeMask);\n#endif\n    const bool bSeparateWaterMainDirLightLuminance = (SINGLE_LAYER_WATER_SEPARATED_MAIN_LIGHT &gt; 0) &amp;&amp; SingleLayerWater.bSeparateMainDirLightLuminance;\n\n    \/\/ Evaluate Fresnel effect\n    const float3 N = MaterialParameters.WorldNormal;\n    const float3 V = MaterialParameters.CameraVector;\n    const float3 EnvBrdf = EnvBRDF(GBuffer.SpecularColor, GBuffer.Roughness, max(0.0, dot(N, V)));\n\n#if SINGLE_LAYER_WATER_SHADING_QUALITY == SINGLE_LAYER_WATER_SHADING_QUALITY_MOBILE_WITH_DEPTH_TEXTURE\n    const float4 NullDistortionParams = 1.0f;\n    WaterVolumeLightingOutput WaterLighting = EvaluateWaterVolumeLighting(\n        MaterialParameters, PixelMaterialInputs, ResolvedView,\n        DirectionalLightShadow * DirectionalLightCloudShadow,\n        SingleLayerWater.SceneDepthWithoutSingleLayerWaterTexture, SingleLayerWaterSceneDepthSampler, \/\/ Scene depth texture\n        SingleLayerWater.SceneWithoutSingleLayerWaterTextureSize,\n        SingleLayerWater.SceneWithoutSingleLayerWaterInvTextureSize,\n        Specular, NullDistortionParams,\n        SunIlluminance, WaterDiffuseIndirectIlluminance, EnvBrdf,\n        CameraIsUnderWater, WaterVisibility, EyeIndex,\n        bSeparateWaterMainDirLightLuminance, SeparatedWaterMainDirLightLuminance);\n\n    \/\/ Add water luminance contribution\n    Color += WaterLighting.Luminance;\n    \/\/ Combine top layer opacity with water transmittance (grey scale)\n    Opacity = 1.0 - ((1.0 - Opacity) * dot(WaterLighting.WaterToSceneToLightTransmittance, float3(1.0 \/ 3.0, 1.0 \/ 3.0, 1.0 \/ 3.0)));\n#else\n    Color += EvaluateWaterVolumeLighting(\n        MaterialParameters, PixelMaterialInputs, ResolvedView,\n        DirectionalLightShadow * DirectionalLightCloudShadow,\n        SingleLayerWater.SceneDepthWithoutSingleLayerWaterTexture, SingleLayerWaterSceneDepthSampler,\n        SingleLayerWater.SceneWithoutSingleLayerWaterTextureSize,\n        SingleLayerWater.SceneWithoutSingleLayerWaterInvTextureSize,\n        SingleLayerWater.SceneColorWithoutSingleLayerWaterTexture, SingleLayerWaterSceneColorSampler,\n        SingleLayerWater.SceneWithoutSingleLayerWaterMinMaxUV.xy,\n        SingleLayerWater.SceneWithoutSingleLayerWaterMinMaxUV.zw,\n        SingleLayerWater.RefractionMaskTexture,\n        Specular, SingleLayerWater.DistortionParams,\n        SunIlluminance, WaterDiffuseIndirectIlluminance, EnvBrdf,\n        CameraIsUnderWater, WaterVisibility, EyeIndex,\n        bSeparateWaterMainDirLightLuminance, SeparatedWaterMainDirLightLuminance\n    #if USE_LIGHT_FUNCTION_ATLAS\n        , GetLocalLightFunctionCommon(SvPositionToResolvedTranslatedWorld(In.SvPosition), GetDirectionalLightData().LightFunctionAtlasLightIndex)\n    #endif\n        ).Luminance;\n#endif\n}\n#endif\n<\/code><\/pre>\n<p>\u5728\u666e\u901a\u8868\u9762 lit \u4e4b\u540e\uff0c\u518d\u7b97 \u6c34\u9762\u4e0b\u7684\u6c34\u4f53\u6563\u5c04\/\u900f\u5c04\/\u6298\u5c04\u76f8\u5173\u4eae\u5ea6\uff0c\u52a0\u8fdb Color<\/p>\n<\/li>\n<li>\n<p>\u8ba1\u7b97Thin Translucent<\/p>\n<pre><code class=\"language-glsl line-numbers\">AccumulateThinTranslucentModel(\n                      DualBlendSurfaceLuminancePostCoverage,\n                      DualBlendSurfaceTransmittancePreCoverage,\n                      DualBlendSurfaceCoverage,\n                      MaterialParameters,\n                      GBuffer,\n                      DiffuseColor,\n                      ColorSeparateSpecular,\n                      Emissive,\n                      Opacity);\nColor = 0;\nOpacity = 1.0f;\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<h4>\u586b\u5145\u8f93\u51fa\u7684RT<\/h4>\n<p>\u6700\u540e\u5c31\u662f\u5c06\u8ba1\u7b97\u7684\u7ed3\u679c\u586b\u5145\u5230\u8f93\u51fa\u7684RT<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662fBasePass BasePass\u662f\u4f4d\u4e8e\u5ef6\u8fdf\u7ba1\u7ebf\u7684PrePass\u4e4b\u540e\u7684\u4e00\u4e2aPass\uff0cDeferred \u4e0b\u4e0d\u900f\u660e BasePa &#8230;<\/p>","protected":false},"author":1,"featured_media":451,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/chenglixue.top\/index.php?rest_route=\/wp\/v2\/posts\/493"}],"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=493"}],"version-history":[{"count":3,"href":"http:\/\/chenglixue.top\/index.php?rest_route=\/wp\/v2\/posts\/493\/revisions"}],"predecessor-version":[{"id":496,"href":"http:\/\/chenglixue.top\/index.php?rest_route=\/wp\/v2\/posts\/493\/revisions\/496"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/chenglixue.top\/index.php?rest_route=\/wp\/v2\/media\/451"}],"wp:attachment":[{"href":"http:\/\/chenglixue.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/chenglixue.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=493"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/chenglixue.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}