vault backup: 2025-06-10 18:47:39

This commit is contained in:
BlueRose 2025-06-10 18:47:39 +08:00
parent b16e6624ee
commit e4a3fa687c

View File

@ -47,8 +47,7 @@ AShaderWorldActor::ProcessSegmentedComputation() <- AShaderWorldActor::TerrainAn
# 其他Bug
CacheMatDyn
MatDyn
## SetTextureParameterValue相关逻辑排查
- AShaderWorldActor中的SetTextureParameterValue
@ -56,21 +55,62 @@ MatDyn
- ~~AssignHeightMapToDynamicMaterial~~
- UpdateStaticDataFor
- ComputeHeight_Segmented_MapForClipMap似乎会设置
- UpdateCollisionMeshData
- ~~UpdateCollisionMeshData~~
- [x] [[#InitializeReadBackDependencies]]
- [x] InitiateMaterials
### UpdateStaticDataFor
### UpdateCollisionMeshData
Tick() -> CollisionManagement() -> CollisionGPU() -> UpdateCollisionMeshData()
### ComputeHeight_Segmented_MapForClipMap
AShaderWorldActor::Tick() -> AShaderWorldActor::TerrainAndSpawnablesManagement() -> AShaderWorldActor::ProcessSegmentedComputation() -> ComputeHeight_Segmented_MapForClipMap
### UpdateCollisionMeshData
- 作用:
1. 判断DynCollisionMat是否有效无效就使用`Generator`(高度数据生成材质)来创建。
2. 设置材质参数NoMargin、TexelPerSide、PatchFullSize、MeshScale。
3. 设置随机种子相关的材质参数。
4. 设置材质参数PatchLocation。
5. 生成碰撞数据到`CollisionRT`
6. 笔刷功能逻辑ApplyBrushStackToHeightMap()。
7. ExportPhysicalMaterialID逻辑。
8. GPU碰撞数据回读ShaderWorld::AsyncReadPixelsFromRT()。
1. ShaderWorld::GSWReadbackManager.AddPendingReadBack()将回读Task增加`TArray<FReadBackTask> PendingReads;`
2. 之后会在USWorldSubsystem::Tick()中调用ShaderWorld::GSWReadbackManager.TickReadBack(),不断检查是否可回读,并进行最终回读。
- 调用顺序Tick() -> CollisionManagement() -> CollisionGPU() -> UpdateCollisionMeshData()
```c++
namespace ShaderWorld
{
FORCEINLINE void AsyncReadPixelsFromRT(UShaderWorldRT2D* InRT, TSharedPtr<FSWColorRead, ESPMode::ThreadSafe> Destination, TSharedPtr < FThreadSafeBool, ESPMode::ThreadSafe> Completion)
{
ENQUEUE_RENDER_COMMAND(ReadGeoClipMapRTCmd)(
[InRT, HeightData = Destination, Completion = Completion](FRHICommandListImmediate& RHICmdList)
{
check(IsInRenderingThread());
if (HeightData.IsValid() && InRT->GetResource())
{
FRDGBuilder GraphBuilder(RHICmdList);
TSharedPtr<FRHIGPUTextureReadback> ReadBackStaging = MakeShared<FRHIGPUTextureReadback>(TEXT("SWGPUTextureReadback"));
FRDGTextureRef RDGSourceTexture = RegisterExternalTexture(GraphBuilder, InRT->GetResource()->TextureRHI, TEXT("SWSourceTextureToReadbackTexture"));
AddEnqueueCopyPass(GraphBuilder, ReadBackStaging.Get(), RDGSourceTexture);
GraphBuilder.Execute();
ShaderWorld::GSWReadbackManager.AddPendingReadBack(RHICmdList, GPixelFormats[RDGSourceTexture->Desc.Format].BlockBytes, RDGSourceTexture->Desc.Extent.X, RDGSourceTexture->Desc.Extent.Y, ReadBackStaging, const_cast<TSharedPtr<FSWColorRead, ESPMode::ThreadSafe>&>(HeightData), const_cast<TSharedPtr < FThreadSafeBool, ESPMode::ThreadSafe>&>(Completion));
}
});
}
```
### InitializeReadBackDependencies
BeginPlay() -> InitiateWorld() -> InitializeReadBackDependencies()
- 作用初始化几个GPU数据回读用的RT。
- 调用顺序BeginPlay() -> InitiateWorld() -> InitializeReadBackDependencies()
1. 初始化3个RTReadRequestLocation、ReadRequestLocationHeightmap、GeneratorDynamicForReadBack。
2. 会设置`TObjectPtr < UMaterialInstanceDynamic> GeneratorDynamicForReadBack`各种变量