diff --git a/03-UnrealEngine/性能优化/UE5优化方法与实践笔记.md b/03-UnrealEngine/性能优化/UE5优化方法与实践笔记.md index cd901de..12d894e 100644 --- a/03-UnrealEngine/性能优化/UE5优化方法与实践笔记.md +++ b/03-UnrealEngine/性能优化/UE5优化方法与实践笔记.md @@ -7,8 +7,11 @@ rating: ⭐⭐ --- ## 前言 -视频推荐:https://www.youtube.com/watch?v=ZRaeiVAM4LI -其他:https://zhuanlan.zhihu.com/p/629225258 +- 视频推荐: + - https://www.youtube.com/watch?v=ZRaeiVAM4LI +- 其他: + - https://zhuanlan.zhihu.com/p/629225258 + - Tomlooman的优化建议:https://www.tomlooman.com/wp-content/uploads/2022/11/Unreal-Engine-Game-Optimization-on-a-Budget.pdf GPU Visualizer工具显示命令: **ProfileGPU** CPU优化方法:https://www.unrealengine.com/en-US/blog/how-to-improve-game-thread-cpu-performance @@ -23,6 +26,13 @@ CPU优化方法:https://www.unrealengine.com/en-US/blog/how-to-improve-game-thre - we see that it is being called 10 times a frame 4. We then need to go look at who is calling AddLight via a break point. And see why adding a specific light or lights is so slow. Usually it is the case that a specific light being added in a way that is doing more work than actually needs to be done. (e.g. attaching / reattaching it) +# 优化前需做 +- r.vsync 0 +- t.maxfps 0 +- SmoothFrameRate=False (Project Settings) +- Lighting Built & MapCheck Errors fixed. +- Packaged Game build + - 使用Standalone进行优化。 ## 优化笔记 r.Lumen.DiffuseIndirect.MeshSDF.RadiusThreshold 让物体包围球的半径大于上述两个决定的数值的时候,才参与mesh sdf的软追踪。 @@ -212,3 +222,54 @@ UE5使用DLSS时需要关闭TAA,并且调整[[ScreenPercentage与描边宽度 # 内存数据查看 - stat llm:查看**虚拟内存数据**。需要在启动方式里添加`-llm`才会有数据。 - MemoryInsight:需要在启动方式里添加`-trace=memory`,之后才能在UnrealInsight中查看。 + +# 材质优化 MIN/MAX DRAW DISTANCE +使用DistanceCullFade节点将过远的部分给Cull掉。 +![[Unreal-Engine-Game-Optimization-on-a-Budget_MINMAX DRAW DISTANCE.png]] + +# FREEZERENDERING +冻结渲染以此查看剔除情况。 +- ‘FreezeRendering’ + ; (semi-colon) to fly with DebugCamera +- Verify occlusion is working as expected +- ‘pause’ (Freeze Game Thread) + +# LIGHT CULLING (Stationary & Movable) +- Automatic ScreenSize culling not strict enough + - MinScreenRadiusForLights (0.03) +- Cull earlier case-by-case + - MaxDrawDistance + - MaxDistanceFadeRange +- Profiling + - Show > LightComplexity (Alt+7) + - Show > StationaryLightOverlap + - ToggleLight + +# LEVEL STREAMING +关卡流调试方法 +- Streaming Volumes vs. Manual Load/Unload + - Camera Location based (caution: third person view and cinematic shots) + - Cannot combine both on a specific sublevel, can mix within the game +- Profiling + - stat levels + - Loadtimes.dumpreport (+ loadtimes.reset) + - Unreal Insight + - UnrealInsight相关标签:Look for level load & “GC” bookmarks + - UnrealInsight相关追踪内容:loadtime,file categories + +# Animation +## ANIMATION: FAST PATH +- Allow ‘Fast Path’ by moving Computations out of AnimGraph (into EventGraph) + - Use WarnAboutBlueprintUsage to get warnings in AnimGraph +- Profiling + - stat anim + +## ANIMATION: QUICK WINS +- **Update Rate Optimization (URO) for distant SkelMeshes**:根据距离调整骨骼物体的更新频率,该选项位于SkeletalMeshComponent。 +- VisibilityBasedAnimTickOption (DefaultEngine.ini) + - OnlyTickPoseWhenRendered + - AlwaysTickPoseAndRefreshBones + - … +- More Bools! + - bRenderAsStatic :UE5.2不存在该选项。 + - bPauseAnims:该选项位于SkeletalMeshComponent。 + - bNoSkeletonUpdate:该选项位于SkeletalMeshComponent。 \ No newline at end of file diff --git a/03-UnrealEngine/性能优化/UnrealInsight以及其他性能监测工具.md b/03-UnrealEngine/性能优化/UnrealInsight以及其他性能监测工具.md index c7c526e..4dcc36e 100644 --- a/03-UnrealEngine/性能优化/UnrealInsight以及其他性能监测工具.md +++ b/03-UnrealEngine/性能优化/UnrealInsight以及其他性能监测工具.md @@ -165,7 +165,11 @@ Game Thread 造成的开销,基本可以归因于 C++ 和蓝图的逻辑处理 针对Tick可使用: - **stat game**:显示 Tick 的耗时情况 - **dumpticks**:可将所有正在 _tick_ 的 _actor_ 打印到 _log_ 中 + - dumpticks grouped - **stat tickables** +- **listtimers** +- **stat uobjects** +- [[#MOVING SCENE COMPONENTS]] 复杂逻辑:需要借助 Unreal Frontend Profiler / Unreal Insights 等工具对游戏逻辑中开销较大的代码进行定位。 ### LandscapeSubsystem Tick @@ -234,6 +238,42 @@ Draw Thread 的主要开销来源于 **Visibility Culling** 和 **Draw Call** - 对于纹理的优化,后续将另开新篇加以详细介绍 ![](https://pic1.zhimg.com/80/v2-81aea063a7fd1de8c2eef38b355268bc_720w.jpg) +## 内存 +- MEMREPORT -full + - Runs a number of individual commands for memory profiling +- obj list class= + - Example: obj list class=AnimSequence +- Only in Packaged Builds + - Example: AnimSequence twice as large in editor builds. + +这样就就可以查看指定Object的内存占用情况。 + +## COLLISION & PHYSICS +- Unreal configured to work out of the box. + - “Collision Enabled” => Physics + Query + - Most things require just ‘QueryOnly’ +- Disable on components players can’t reach or interact with. +- Profiling + - stat physics, stat collision + - obj list class=BodySetup + - show CollisionPawn, show CollisionVisibility +- Tip: Landscape may use lower collision MIPs + +## MOVING SCENE COMPONENTS +移动场景组件可能会造成一些性能问题,需要注意以下几点: +- Move/Rotate only once per frame +- **Disable Collision & GenerateOverlaps=False** +- AutoManageAttachment + - Audio & Niagara +- Profiling + - stat component + +### MOVING COMPONENTS - BOUNDS +- ***UseAttachParentBound=True*** + - Skips “CalcBounds” +- 检查命令:show Bounds / showflag.bounds 1 + +蓝图中勾选***UseAttachParentBound***,以此跳过计算CalcBounds的问题。 ## UnrealFrontend Profiler 官方文档:[Profiler Tool](https://docs.unrealengine.com/4.27/zh-CN/TestingAndOptimization/PerformanceAndProfiling/Profiler/) 其他参考文章: diff --git a/08-Assets/Images/ImageBag/Rendering/Optimise/Unreal-Engine-Game-Optimization-on-a-Budget_MINMAX DRAW DISTANCE.png b/08-Assets/Images/ImageBag/Rendering/Optimise/Unreal-Engine-Game-Optimization-on-a-Budget_MINMAX DRAW DISTANCE.png new file mode 100644 index 0000000..98fe008 Binary files /dev/null and b/08-Assets/Images/ImageBag/Rendering/Optimise/Unreal-Engine-Game-Optimization-on-a-Budget_MINMAX DRAW DISTANCE.png differ