A short intro to optimizing assets & levels for (V)RAM usage. Learn what tools you can use to track excessive memory usage in your scene, then optimize it easily, in bulk.
This article is based on my Twitch stream, where I dived deeper into these optimization techniques:
Unreal Engine, obviously, uses both RAM and GPU memory. Understanding this distinction is crucial for optimization. Focusing on optimizing GPU memory can significantly enhance performance since it is both valuable and costly (and not as easy extendable on PC - need to replace the GPU). Therefore, look to VRAM as the first area of risk.
Scene optimization starts with evaluating scalability settings. While “Epic” settings offer the highest quality, “High” settings often strike a good balance between visual fidelity and performance. Adjusting them, including resolution scale, helps to get a good starting point. Use sg.* commands in a running build to tweak them live.
Key Memory Consumers#
Meshes, textures, physics data, full-screen buffers, and volumetric effects are the primary consumers of memory in Unreal Engine.
High-resolution assets can quickly deplete available memory. A 4x wider texture is 16x the memory! (because it’s the area, so ^2 growth)
Viewport’s visualization tools allow to inspect the wireframe. Look for unnecessarily heavy (dense) assets. But generally, go deeper - watch my video about quad overshading, for example.
Optimization Techniques#
Texture Memory Usage#
Use the Tools → Statistics and Render Resource Viewer windows to analyze which textures consume the most memory. Playing the scene ensures accurate statistics.
Texture Optimization#
Adjust LOD Bias - either per platform (Device Profiles) or per texture (in its editor). Increasing the bias removes the highest resolution mipmaps. With bias 2, for example, the old “mip 2” becomes a current “mip 0”. You can set a Maximum Texture Size too. This ensures textures will be downscaled. Personally, I use the Bias.
Static Mesh Optimization#
Use LOD Settings in the Static Mesh editor. This panel offers a polygon reduction slider, or you can import custom ones. The goal is to reduce the number of triangles in a mesh based on its distance from the camera.
Lightmap Resolutions#
Ensure proper texel density on assets if you’re using lightmaps rather then Lumen. Lower resolutions can significantly save memory, though this may impact visual quality.
Dynamic Loading#
Properly managing dynamic loading and streaming of textures and meshes is crucial for optimizing memory usage during runtime. Setting up assets to load only when needed and unloading them when not in use prevents unnecessary memory occupation. Learn about Soft References if you’re a Blueprint or C++ code author.
Fixing Stuff in Bulk#
Builtin tools, Python and Editor Utility Widgets provide opportunities for batch processing and automating repetitive tasks. By doing operations in batch, you can efficiently manage multiple textures and meshes after they were imported.
Your best friend for mass optimization is the Property Matrix (known before as Bulk Edit). It allows you to review & tweak properties (be it Compression Type or LOD bias) of hundreds of assets with easy. Simply select multiple files in the Content Browser and find it in the right-click menu.
Debugging and Analysis#
Utilize Optimization View Modes, like Quad Overdraw, to identify areas with excessive detail.
Regularly verify and test changes to ensure optimizations achieve the intended memory savings without compromising visual quality. Do your profiling on a build - not in Editor!
Continuous refinement based on analysis helps maintain a well-optimized, high-performance project.
To Sum Up#
Key Takeaways:
- Set Scalability to “High” and tweak the resolution scale
- Check the Render Resource Viewer window regularly to spot heavy textures
- Reduce triangle count and set LODs for static meshes
- Adjust lightmap resolutions based on the importance of the mesh
- Use bulk edit tools for batch processing
- Develop custom tools using editor scripting for repetitive tasks
The Bistro scene used in demonstrations was made by Dominique Buttiens and released for free. Thanks!
