diff --git a/01-Diary/周小结/2024.9.md b/01-Diary/周小结/2024.9.md index adae427..a27f1d7 100644 --- a/01-Diary/周小结/2024.9.md +++ b/01-Diary/周小结/2024.9.md @@ -30,3 +30,62 @@ 2. 人工检查。 3. ~~P4 Shelf协作方法测试。~~ 理论可行,但字节并没有使用这种方式。 4. 之后大活的实现方式。新建大地图,需要的场景手动移植到新的大地图。 + + +```c++ +/** Adds a render graph pass to copy a region from one texture to another. Uses RHICopyTexture under the hood. + * Formats of the two textures must match. The output and output texture regions be within the respective extents. + */ +RENDERCORE_API void AddCopyTexturePass( + FRDGBuilder& GraphBuilder, + FRDGTextureRef InputTexture, + FRDGTextureRef OutputTexture, + const FRHICopyTextureInfo& CopyInfo); + +/** Simpler variant of the above function for 2D textures. + * @param InputPosition The pixel position within the input texture of the top-left corner of the box. + * @param OutputPosition The pixel position within the output texture of the top-left corner of the box. + * @param Size The size in pixels of the region to copy from input to output. If zero, the full extent of + * the input texture is copied. + */ +inline void AddCopyTexturePass( + FRDGBuilder& GraphBuilder, + FRDGTextureRef InputTexture, + FRDGTextureRef OutputTexture, + FIntPoint InputPosition = FIntPoint::ZeroValue, + FIntPoint OutputPosition = FIntPoint::ZeroValue, + FIntPoint Size = FIntPoint::ZeroValue) +{ + FRHICopyTextureInfo CopyInfo; + CopyInfo.SourcePosition.X = InputPosition.X; + CopyInfo.SourcePosition.Y = InputPosition.Y; + CopyInfo.DestPosition.X = OutputPosition.X; + CopyInfo.DestPosition.Y = OutputPosition.Y; + if (Size != FIntPoint::ZeroValue) + { + CopyInfo.Size = FIntVector(Size.X, Size.Y, 1); + } + AddCopyTexturePass(GraphBuilder, InputTexture, OutputTexture, CopyInfo); +} +``` + +SSR: +SHADER_PARAMETER_RDG_TEXTURE_SRV(Texture2D, SceneColor) + +```c++ +FRDGTextureSRVRef InputColor = GraphBuilder.CreateSRV(FRDGTextureSRVDesc(CurrentSceneColor)); +if (SSRQuality != ESSRQuality::VisualizeSSR) +{ + if (View.PrevViewInfo.CustomSSRInput.IsValid()) + { InputColor = GraphBuilder.CreateSRV(FRDGTextureSRVDesc( + GraphBuilder.RegisterExternalTexture(View.PrevViewInfo.CustomSSRInput.RT[0]))); + } else if (GSSRHalfResSceneColor && View.PrevViewInfo.HalfResTemporalAAHistory.IsValid()) + { InputColor = GraphBuilder.CreateSRV(FRDGTextureSRVDesc( + GraphBuilder.RegisterExternalTexture(View.PrevViewInfo.HalfResTemporalAAHistory))); + } else if (View.PrevViewInfo.TemporalAAHistory.IsValid()) + { FRDGTextureRef TemporalAAHistoryTexture = GraphBuilder.RegisterExternalTexture(View.PrevViewInfo.TemporalAAHistory.RT[0]); + InputColor = GraphBuilder.CreateSRV(TemporalAAHistoryTexture->Desc.IsTextureArray() + ? FRDGTextureSRVDesc::CreateForSlice(TemporalAAHistoryTexture, View.PrevViewInfo.TemporalAAHistory.OutputSliceIndex) + : FRDGTextureSRVDesc(TemporalAAHistoryTexture)); + }} +``` \ No newline at end of file