diff --git a/03-UnrealEngine/卡通渲染相关资料/渲染功能/PostProcess/ToonPostProcess.md b/03-UnrealEngine/卡通渲染相关资料/渲染功能/PostProcess/ToonPostProcess.md index 0b59b1a..d3b6047 100644 --- a/03-UnrealEngine/卡通渲染相关资料/渲染功能/PostProcess/ToonPostProcess.md +++ b/03-UnrealEngine/卡通渲染相关资料/渲染功能/PostProcess/ToonPostProcess.md @@ -393,4 +393,30 @@ FScreenPassTextureSlice SceneColorSlice = FScreenPassTextureSlice::CreateFromScr 将渲染结果转换成`FScreenPassTextureSlice`: ```c++ SceneColorSlice = FScreenPassTextureSlice::CreateFromScreenPassTexture(GraphBuilder, AddToonPostProcessBeforeTonemappingPass(GraphBuilder, View, PassInputs)); +``` + +```c++ +// Allows for the scene color to be the slice of an array between temporal upscaler and tonemaper. +FScreenPassTextureSlice SceneColorSlice = FScreenPassTextureSlice::CreateFromScreenPassTexture(GraphBuilder, SceneColor); +``` +## Viewport => TextureUV +```c++ +PassParameters->SvPositionToInputTextureUV = ( + FScreenTransform::SvPositionToViewportUV(Output.ViewRect) * + FScreenTransform::ChangeTextureBasisFromTo(FScreenPassTextureViewport(Inputs.SceneColorSlice), FScreenTransform::ETextureBasis::ViewportUV, FScreenTransform::ETextureBasis::TextureUV)); +``` + +在Shader中: +```c++ +Texture2D SceneColorTexture; +SamplerState SceneColorSampler; +FScreenTransform SvPositionToInputTextureUV; + +void MainPS( + float4 SvPosition : SV_POSITION, + out float4 OutColor : SV_Target0) +{ + float2 SceneColorUV = ApplyScreenTransform(SvPosition.xy, SvPositionToInputTextureUV); + OutColor.rgba = SceneColorTexture.SampleLevel(SceneColorSampler, UV, 0).rgba; +} ``` \ No newline at end of file