Here is the code I added
Pass.cpp
const bool bShouldRenderView = View.ShouldRenderView();
if (bShouldRenderView)
{
View.BeginRenderView();
auto* PassParameters = GraphBuilder.AllocParameters<FLightMyParameters>();
PassParameters->View = View.GetShaderParameters();
PassParameters->LightMyData = CreateLightMyPassUniformBuffer(GraphBuilder, SceneTextures);
PassParameters->RenderTargets.DepthStencil = FDepthStencilBinding(SceneTextures.Depth.Target, ERenderTargetLoadAction::ELoad, ERenderTargetLoadAction::ELoad,
FExclusiveDepthStencil::DepthWrite_StencilNop);
PassParameters->RenderTargets[0] = FRenderTargetBinding(SceneTextures.Color.Target, ERenderTargetLoadAction::ELoad);
PassParameters->RenderTargets[1] = FRenderTargetBinding(SceneTextures.MyTextTexture, ERenderTargetLoadAction::EClear);
View.ParallelMeshDrawCommandPasses[EMeshPass::LightMy].BuildRenderingCommands(GraphBuilder, Scene->GPUScene, PassParameters->InstanceCullingDrawParams);
GraphBuilder.AddPass(
RDG_EVENT_NAME("LightMy"),
PassParameters,
ERDGPassFlags::Raster | ERDGPassFlags::SkipRenderPass,
[this, &View, PassParameters](const FRDGPass* InPass, FRHICommandListImmediate& RHICmdList)
{
FRDGParallelCommandListSet ParallelCommandListSet(InPass, RHICmdList, GET_STATID(STAT_CLP_LightMy), View, FParallelCommandListBindings(PassParameters));
View.ParallelMeshDrawCommandPasses[EMeshPass::LightMy].DispatchDraw(&ParallelCommandListSet, RHICmdList, &PassParameters->InstanceCullingDrawParams);
});
}
Pass.usf
void MainPS(
FToonMeshPassVSToPS Input,
out float4 OutColor : SV_Target0,
out float4 OutColor2 : SV_Target1)
{
const float2 SceneBufferUV = SvPositionToBufferUV(Input.SvPosition);
// FMaterialPixelParameters MaterialParameters = GetMaterialPixelParameters(Input.FactoryInterpolants, Input.SvPosition);
// float2 NDC = MaterialParameters.ScreenPosition.xy / MaterialParameters.ScreenPosition.w;
// float2 ScreenUV = NDC * ResolvedView.ScreenPositionScaleBias.xy + ResolvedView.ScreenPositionScaleBias.wz;
float clampShadow = LightMyData.ToonShadowTexture.SampleLevel(LightMyData.ToonShadowTextureSampler, SceneBufferUV, 0).r;
float selfShadow = LightMyData.ToonShadowTexture.SampleLevel(LightMyData.ToonShadowTextureSampler, SceneBufferUV, 0).g;
float highLight = LightMyData.ToonShadowTexture.SampleLevel(LightMyData.ToonShadowTextureSampler, SceneBufferUV, 0).b;
OutColor = float4(1,0,0,1);
OutColor2 = selfShadow.xxxx;
// OutColor = float4(1.0f,0.0f,0.0f,1.0f);
}
This is the information I captured using RenderDoc