vault backup: 2024-09-27 13:10:09
This commit is contained in:
parent
0aa3e87df7
commit
083d49a79c
@ -5,6 +5,62 @@ excerpt:
|
|||||||
tags:
|
tags:
|
||||||
rating: ⭐
|
rating: ⭐
|
||||||
---
|
---
|
||||||
|
# RenderBasePass()
|
||||||
|
传入RenderBasePass()的DepthStencil逻辑如下:
|
||||||
|
```c++
|
||||||
|
const FExclusiveDepthStencil::Type BasePassDepthStencilAccess =
|
||||||
|
bAllowReadOnlyDepthBasePass
|
||||||
|
? FExclusiveDepthStencil::DepthRead_StencilWrite
|
||||||
|
: FExclusiveDepthStencil::DepthWrite_StencilWrite;
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
FDeferredShadingSceneRenderer::RenderBasePass() =>
|
||||||
|
FDeferredShadingSceneRenderer::RenderBasePassInternal() =>
|
||||||
|
|
||||||
|
|
||||||
|
FBasePassMeshProcessor::TryAddMeshBatch =>
|
||||||
|
|
||||||
|
## 大致流程
|
||||||
|
1. 绑定GBuffer与Depth。
|
||||||
|
```c++
|
||||||
|
const FExclusiveDepthStencil ExclusiveDepthStencil(BasePassDepthStencilAccess);
|
||||||
|
|
||||||
|
TStaticArray<FTextureRenderTargetBinding, MaxSimultaneousRenderTargets> BasePassTextures;
|
||||||
|
uint32 BasePassTextureCount = SceneTextures.GetGBufferRenderTargets(BasePassTextures);
|
||||||
|
Strata::AppendStrataMRTs(*this, BasePassTextureCount, BasePassTextures);
|
||||||
|
TArrayView<FTextureRenderTargetBinding> BasePassTexturesView = MakeArrayView(BasePassTextures.GetData(), BasePassTextureCount);
|
||||||
|
FRDGTextureRef BasePassDepthTexture = SceneTextures.Depth.Target;
|
||||||
|
```
|
||||||
|
2. GBuffer Clear
|
||||||
|
```c++
|
||||||
|
GraphBuilder.AddPass(RDG_EVENT_NAME("GBufferClear"), PassParameters, ERDGPassFlags::Raster,
|
||||||
|
[PassParameters, ColorLoadAction, SceneColorClearValue](FRHICommandList& RHICmdList)
|
||||||
|
{
|
||||||
|
// If no fast-clear action was used, we need to do an MRT shader clear.
|
||||||
|
if (ColorLoadAction == ERenderTargetLoadAction::ENoAction)
|
||||||
|
{
|
||||||
|
const FRenderTargetBindingSlots& RenderTargets = PassParameters->RenderTargets;
|
||||||
|
FLinearColor ClearColors[MaxSimultaneousRenderTargets];
|
||||||
|
FRHITexture* Textures[MaxSimultaneousRenderTargets];
|
||||||
|
int32 TextureIndex = 0;
|
||||||
|
|
||||||
|
RenderTargets.Enumerate([&](const FRenderTargetBinding& RenderTarget)
|
||||||
|
{
|
||||||
|
FRHITexture* TextureRHI = RenderTarget.GetTexture()->GetRHI();
|
||||||
|
ClearColors[TextureIndex] = TextureIndex == 0 ? SceneColorClearValue : TextureRHI->GetClearColor();
|
||||||
|
Textures[TextureIndex] = TextureRHI;
|
||||||
|
++TextureIndex;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Clear color only; depth-stencil is fast cleared.
|
||||||
|
DrawClearQuadMRT(RHICmdList, true, TextureIndex, ClearColors, false, 0, false, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
3.
|
||||||
|
|
||||||
|
|
||||||
# SetDepthStencilStateForBasePass()
|
# SetDepthStencilStateForBasePass()
|
||||||
```c++
|
```c++
|
||||||
void SetDepthStencilStateForBasePass(
|
void SetDepthStencilStateForBasePass(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user