When it comes to delivering exceptional user experiences in your app or game, speed is everything. Unreal Engine 4 (UE4) provides several tools and techniques to help you optimize load times and reduce asset sizes, ensuring a seamless experience for your users.
Reducing Asset Sizes
To start, let's dive into some tips for reducing asset sizes. One approach is to use the "CompressAnimations" commandlet, which compresses all animation sequences in your project. You can also set individual animations to not be compressed using the "Do not override compression" option.
Another technique is to adjust the r.screenpacentage setting to reduce pixel shader costs. Additionally, you can use the Graphics Debugger (GD) to capture and check the cost of each draw call, helping you identify areas for improvement.
Optimizing Load Times
When it comes to load times, there are several areas to focus on. First, let's talk about profiling and optimization. The Stat Levels console command provides a colored list of your game's current levels, showing their current load status. This can help you quickly identify which levels are taking the longest to load.
Next, use the LoadTimes.DumpReport command to generate a detailed report on load times for each package (asset). You can also use the LowTime=0.05 option to eliminate packages whose load-time is under a specified value from the list.
Profiling AddToWorld
To dive deeper into load times, enable the PERF_TRACK_DETAILED_ASYNC_STATS define and use the AsyncLoading.h file. This will dump detailed statistics on the AddToWorld() function, helping you identify bottlenecks.
Optimizing Asset Loading
When it comes to optimizing asset loading, consider using a Pak file. Combining all content into a single UnrealPak is necessary for using the Event Driven Loader, which is optimized for consoles.
Additionally, compression can have different impacts on different projects, so be sure to test your project's performance on the target hardware.
Optimizing Load Times FileOpenOrder
Another easy win for optimizing load times is sorting assets in Pak files by file open order. This arranges the files on disk in the order they are loaded, reducing load times and improving overall performance.
Eliminating Data That's Never Used
Finally, eliminate data that's never used to reduce asset sizes and improve performance. Some examples include disabling features like material shader permutation reduction, vertex reverse index buffer, and adjacency index buffer.
Preloading with Asset Manager
To simplify logic in your BeginPlay function, consider preloading assets using the Asset Manager. This can help reduce load times and improve overall performance.
Garbage Collection
When it comes to garbage collection (GC), be aware that noticeable and unacceptable hitches can occur due to GC costs. To profile GC costs, use the Log loggarbage log command, which provides detailed statistics on GC costs.
By implementing these tips and tricks for reducing asset sizes and optimizing load times, you can deliver a faster, more seamless user experience in your app or game.