Skip to main content

🚀 Optimization

Before packaging, it's crucial to optimize your project for performance and size. A well-optimized game runs smoothly on target hardware, loads quickly, and downloads faster. This lesson covers profiling tools, common performance issues, and techniques to reduce your package size.

🎯 Learning Objectives

By the end of this lesson, you will be able to:

  • Use Unreal's profiling tools to identify bottlenecks
  • Optimize textures, meshes, and materials
  • Improve Blueprint and level performance
  • Reduce package size with content auditing
  • Apply LOD and culling techniques

Estimated Time: 40-50 minutes

Prerequisites: Lesson 10.1 (Project Settings)

📑 In This Lesson

Profiling Tools

Before optimizing, you need to know what's actually slow. Guessing wastes time—profiling shows you exactly where to focus your efforts.

Stat Commands

Type these in the console (~ key) while playing:

Command Shows
stat fps Frames per second
stat unit Frame time breakdown (Game, Draw, GPU)
stat unitgraph Visual graph of frame times
stat game Game thread performance
stat gpu GPU rendering costs
stat scenerendering Render pass costs
stat memory Memory usage

Understanding Frame Time

Frame time tells you more than FPS:

  • 60 FPS = 16.67ms per frame
  • 30 FPS = 33.33ms per frame
  • stat unit shows: Game thread, Draw thread, GPU time
  • The longest time determines your framerate

Interpreting stat unit:

  • Game: High = Blueprint/C++ logic is slow
  • Draw: High = CPU rendering commands bottleneck
  • GPU: High = Graphics are too demanding
Frame Time Breakdown (stat unit) 0ms 16.67ms (60fps target) Game: 5ms Draw: 4ms GPU: 8ms Target Game Thread Blueprint, Physics, AI Draw Thread CPU render commands GPU Time Rendering, Shaders

Figure: Frame time breakdown shows where your game spends time each frame.

GPU Visualizer

For GPU bottlenecks, use the GPU Visualizer:

  1. Press Ctrl+Shift+, (comma) while playing
  2. Or type profilegpu in console
  3. Shows detailed GPU pass timing
  4. Identifies expensive rendering passes

Unreal Insights

For deep profiling:

  1. Enable via Tools → Session Frontend
  2. Or launch with -trace=default
  3. Records comprehensive performance data
  4. Analyze with Unreal Insights tool

💡 Profile First, Optimize Second

Never guess what's slow. Run stat unit to see if you're Game, Draw, or GPU bound. Then use specific tools to find the exact bottleneck. Optimizing the wrong thing wastes time.

Content Optimization

Content—textures, meshes, materials—often has the biggest impact on both performance and package size. Optimizing assets is usually the most effective improvement.

Texture Optimization

Textures are often the largest assets:

Technique Impact How
Reduce resolution Memory, size Use appropriate sizes (512-2K for most)
Enable streaming Memory Texture Streaming (default on)
Compress textures Size, memory Use compressed formats (BC/DXT)
Generate mipmaps Performance Enable in texture settings (default)
Texture atlasing Draw calls Combine small textures

Texture Size Guidelines:

  • Hero assets (main character, key props): 2048-4096
  • Standard props: 512-1024
  • Background/distant objects: 256-512
  • UI elements: Smallest size that looks good

Mesh Optimization

High-poly meshes hurt performance:

  • Reduce polygon count: Use lowest that looks acceptable
  • Enable Nanite: For UE5 projects with compatible meshes
  • Set up LODs: Lower detail at distance
  • Use instances: Static Mesh instances share resources
  • Merge actors: Combine static meshes to reduce draw calls

Level of Detail (LOD)

LODs swap to simpler meshes at distance:

  1. Select mesh in Content Browser
  2. Right-click → Create LOD
  3. Or import with LODs already created
  4. Configure LOD distances in Static Mesh editor
Level of Detail (LOD) System Camera LOD 0 10,000 tris 0-50 meters LOD 1 2,500 tris 50-150 meters LOD 2 500 tris 150-300 meters Culled 0 tris 300+ meters Objects use simpler geometry as they get farther away

Figure: LODs reduce polygon count based on camera distance.

Material Optimization

  • Simplify shader complexity: Fewer instructions = faster
  • Use Material Instances: Share base materials, vary parameters
  • Reduce texture samples: Each sample costs performance
  • Enable material instancing: Batches similar materials
  • Avoid complex math: Simplify where possible

⚠️ Nanite Considerations

Nanite is fantastic for high-poly static meshes but has limitations: no skeletal meshes, no translucency, no world position offset. Check if your meshes are Nanite-compatible before relying on it.

Runtime Optimization

Game logic, Blueprints, and level setup affect runtime performance. These optimizations happen in how your game runs, not just its content.

Blueprint Optimization

Issue Solution
Heavy logic in Event Tick Use timers, events, or lower tick rate
Expensive casts every frame Cache references, cast once
Get All Actors frequently Cache results, use tags for filtering
Complex for loops Spread over frames, use async
Many string operations Use Names instead of Strings

Tick Rate Control:

  • Actors can have custom tick intervals
  • Set in Class Defaults → Actor Tick → Tick Interval
  • Disable tick entirely for static actors
  • Use timers for periodic updates instead of tick

Culling and Visibility

Don't render what the player can't see:

  • Frustum Culling: Automatic, hides objects outside view
  • Occlusion Culling: Hides objects behind other objects
  • Distance Culling: Set Max Draw Distance on actors
  • Cull Distance Volumes: Define areas with custom cull distances

Setting Max Draw Distance:

  1. Select actor(s) in the level
  2. In Details, find LOD → Max Draw Distance
  3. Set the distance (in cm) beyond which the actor disappears
  4. Small detail objects should have lower distances

Lighting Optimization

  • Bake static lighting: Much faster than dynamic
  • Limit dynamic lights: Each adds rendering cost
  • Use light importance: Set to Low for minor lights
  • Reduce shadow-casting lights: Shadows are expensive
  • Use Lumen wisely: Adjust quality vs. performance
Culling: Only Render What's Visible Camera Occluder Hidden Culling Types Rendered (in view) Frustum culled Occlusion culled

Figure: Culling prevents rendering objects the player can't see.

Physics Optimization

  • Simplify collision: Use simple shapes, not complex meshes
  • Disable physics when not needed: Set Simulate Physics = false
  • Use physics LOD: Simpler physics at distance
  • Reduce physics tick rate: In Project Settings if needed

Reducing Package Size

Smaller packages download faster, use less storage, and improve user experience. Here's how to audit and reduce your package size.

Size Map Tool

Find what's taking space:

  1. Go to Window → Developer Tools → Size Map
  2. Or use Asset Audit (Window → Developer Tools)
  3. See which assets consume the most space
  4. Focus optimization on the biggest offenders

Common Size Culprits

Issue Typical Size Impact Solution
Oversized textures 100s of MB Reduce resolution, compress
Unused assets Variable Delete or exclude from cook
Duplicate assets 2x+ size Consolidate references
High-res audio 10s of MB Compress, stream long files
Debug content Variable Exclude from Shipping
Uncompressed movies 100s of MB Compress video files

Excluding Unused Content

In Project Settings → Packaging:

  • Directories to never cook: Add test/debug folders
  • Cook only maps: Disable to include all referenced content

Finding unused assets:

  1. Right-click folder → Audit Assets
  2. Or use Reference Viewer on individual assets
  3. Assets with no references may be unused
  4. Be careful—some assets are loaded by string paths

Compression Settings

Project → Packaging:

  • Create compressed cooked packages: Enable for smaller size
  • Pak File Compression: Zlib (compatible) or Oodle (smaller)

Per-asset compression:

  • Textures: Use compressed formats (BC/DXT)
  • Audio: Enable compression, use streaming for long files
  • Meshes: Enable mesh compression in import settings
Package Size Reduction Example Before Optimization 2.5 GB 4K textures, unused assets Optimize After Optimization 800 MB Compressed, cleaned up 68% size reduction!

Figure: Proper optimization can dramatically reduce package size.

✅ Quick Wins

  • Reduce max texture size in Project Settings (e.g., 2048 max)
  • Enable pak file compression
  • Delete Starter Content if not using it
  • Remove unused plugins

Hands-On: Optimizing Your Project

Let's profile your project, identify issues, and apply optimizations. You'll use profiling tools to find bottlenecks and apply techniques to improve performance and reduce size.

🎯 Exercise Goal

Profile your game to establish baseline performance, identify and fix common issues, audit content for size optimization, and verify improvements. These skills ensure your packaged game runs well.

Part 1: Establish Baseline Performance

Step 1: Open Your Main Level

  1. Open the level you'll be packaging (your main gameplay level)
  2. Make sure it's representative of typical gameplay

Step 2: Enable Stat Display

  1. Press Play to start PIE
  2. Press ~ (tilde) to open console
  3. Type: stat fps and press Enter
  4. Type: stat unit and press Enter
  5. Note your current FPS and frame times

Step 3: Record Baseline

  1. Walk around your level, especially busy areas
  2. Note minimum FPS and maximum frame times
  3. Record these numbers:
    • Average FPS: _____
    • Minimum FPS: _____
    • Game Thread: _____ ms
    • Draw Thread: _____ ms
    • GPU: _____ ms
Recording Baseline Stats stat fps 62 FPS 16.1 ms stat unit Game: 4.2ms Draw: 3.1ms GPU: 9.8ms Bottleneck GPU Bound Focus on rendering

Figure: Record baseline stats to measure improvement.

Part 2: Identify Bottlenecks

Step 4: Determine Bottleneck Type

Based on your stat unit results:

  • Game > Draw and GPU: You're CPU/Game bound → optimize Blueprints
  • Draw > Game and GPU: You're Draw call bound → reduce objects/materials
  • GPU > Game and Draw: You're GPU bound → reduce rendering complexity

Step 5: GPU Profiling (if GPU bound)

  1. While playing, press Ctrl+Shift+, (comma)
  2. GPU Visualizer opens showing render pass costs
  3. Look for the most expensive passes:
    • BasePass: Material/geometry complexity
    • Shadows: Shadow map rendering
    • Translucency: Transparent materials
    • PostProcessing: Screen effects

Step 6: Check Specific Stats

Try these additional stat commands:

  • stat scenerendering — Detailed render stats
  • stat initviews — View culling information
  • stat particles — Particle system costs
  • stat anim — Animation costs

Part 3: Apply Optimizations

Step 7: Optimize Textures

  1. Open Window → Developer Tools → Size Map
  2. Find the largest textures
  3. For oversized textures:
    • Open the texture asset
    • Set Maximum Texture Size to appropriate value (1024 or 2048)
    • Ensure Compression Settings uses a compressed format
    • Apply and save

Step 8: Add LODs to Key Meshes

  1. Identify high-poly meshes used frequently
  2. Right-click mesh in Content Browser → Create LOD
  3. Choose reduction settings (50% for LOD1, 25% for LOD2)
  4. Open Static Mesh editor, adjust LOD screen sizes

Step 9: Set Distance Culling

  1. Select small detail objects in your level
  2. In Details, find LOD → Max Draw Distance
  3. Set appropriate distances:
    • Small props: 3000-5000
    • Medium objects: 8000-15000
    • Large structures: Leave at 0 (no limit)

Step 10: Check Blueprint Tick

  1. Open your main gameplay Blueprints
  2. Check Event Tick usage
  3. Move non-critical logic to timers
  4. Cache frequently accessed references
  5. For Actors that don't need tick:
    • In Class Defaults → Actor Tick
    • Uncheck Start with Tick Enabled

Part 4: Audit Content Size

Step 11: Check Project Size

  1. Open Window → Developer Tools → Size Map
  2. Click Load All to analyze entire project
  3. Sort by size to find largest assets
  4. Note total estimated cooked size

Step 12: Find Unused Assets

  1. Right-click Content folder → Audit Assets
  2. Or use Reference Viewer on suspicious assets
  3. Look for assets with 0 referencers
  4. Verify they're truly unused before deleting

Step 13: Clean Up

  1. Delete confirmed unused assets
  2. Right-click Content → Fix Up Redirectors in Folder
  3. This cleans up after moved/renamed assets

Part 5: Verify Improvements

Step 14: Re-test Performance

  1. Play your level again
  2. Enable stat fps and stat unit
  3. Walk through the same areas as before
  4. Record new numbers and compare:
    • New Average FPS: _____ (was: _____)
    • New Minimum FPS: _____ (was: _____)
    • Frame time improvement: _____

Step 15: Check Size Map Again

  1. Reopen Size Map
  2. Compare estimated size to before
  3. Note size reduction achieved

✅ Exercise Complete!

You've profiled and optimized your project:

  • Established baseline performance metrics
  • Identified your bottleneck type (Game/Draw/GPU)
  • Applied texture, mesh, and culling optimizations
  • Audited and reduced content size
  • Verified performance improvements

Your project is now optimized and ready for final packaging!

Troubleshooting

⚠️ Common Issues

Stats don't show:

  • Make sure you're in play mode (not just in editor)
  • Type commands without typos
  • Try stat none then re-enable

No improvement after optimization:

  • You may be optimizing the wrong bottleneck
  • Check if Game/Draw/GPU changed after optimization
  • Some optimizations need level rebuild (Lighting)

Size Map shows 0 or wrong values:

  • Click "Load All" to scan entire project
  • May need to save all and restart editor

Can't delete assets (referenced):

  • Use Reference Viewer to see what's using them
  • May be blueprint references or level instances
  • Force delete only as last resort (can break things)

Optimization Targets

Platform Target FPS Frame Budget
High-end PC 60+ FPS 16.67ms
Mid-range PC 30-60 FPS 16.67-33.33ms
Console 30 or 60 FPS (locked) 16.67 or 33.33ms
Mobile 30 FPS 33.33ms

Bonus Challenges

  1. Merge Actors: Select static meshes → Actor → Merge Actors to reduce draw calls
  2. HLOD: Set up Hierarchical LOD for open world areas
  3. Async Loading: Implement level streaming for large levels
  4. Niagara GPU: Convert heavy particle systems to GPU simulation
  5. Material Instances: Replace duplicate materials with instances

Summary

In this lesson, you've learned to profile your project, identify performance bottlenecks, and apply optimizations. A well-optimized game runs smoothly, loads quickly, and provides a better player experience.

Key Concepts

Profiling First: Always measure before optimizing. Use stat unit to identify whether you're Game, Draw, or GPU bound. Profile specific systems with stat gpu, GPU Visualizer, or Unreal Insights.

Content Optimization: Textures, meshes, and materials often have the biggest impact. Reduce texture sizes, enable compression, set up LODs, and use appropriate polygon counts. Nanite helps with high-poly meshes on compatible hardware.

Runtime Optimization: Blueprint performance matters—avoid heavy logic in Event Tick, cache references, and use timers. Enable culling (frustum, occlusion, distance) to skip rendering invisible objects. Optimize lighting with baking and fewer dynamic lights.

Package Size: Use Size Map to find large assets. Remove unused content, compress textures and audio, and enable pak file compression. Smaller packages download faster and use less storage.

Profiling Commands Quick Reference

Command Purpose When to Use
stat fps Show framerate Quick performance check
stat unit Frame time breakdown Identify bottleneck type
stat gpu GPU render costs When GPU bound
stat game Game thread details When Game bound
stat scenerendering Render pass timing Detailed render analysis
stat memory Memory usage Memory issues
Ctrl+Shift+, GPU Visualizer Detailed GPU profiling

Optimization Techniques

Category Techniques
Textures Reduce resolution, enable compression, use streaming, generate mipmaps
Meshes Set up LODs, reduce poly count, use Nanite, merge static actors
Materials Simplify shaders, use Material Instances, reduce texture samples
Blueprints Avoid Tick abuse, cache references, use timers, disable unused ticks
Rendering Distance culling, bake lighting, limit dynamic lights/shadows
Package Size Remove unused assets, compress content, exclude debug folders

Best Practices

  • Profile first: Never guess—measure to find real bottlenecks
  • Optimize the right thing: GPU optimizations don't help if you're CPU bound
  • Test on target hardware: Your dev machine may hide issues
  • Iterate: Make one change, measure, repeat
  • Budget your frame time: Know your target and stay under it
  • Use LODs and culling: Don't render what players can't see
  • Audit content regularly: Unused assets accumulate over time
  • Enable compression: Smaller files = faster downloads
Optimization Workflow 1. Profile stat unit GPU Visualizer Measure baseline 2. Identify Game bound? Draw bound? GPU bound? 3. Optimize Apply targeted techniques for your bottleneck 4. Verify Re-measure Compare to baseline Repeat if needed Iterate until target achieved

Figure: The optimization cycle—profile, identify, optimize, verify, repeat.

What's Next?

With your project configured and optimized, the final lesson covers Building and Distribution. You'll package your game, create installers, and prepare for release on different platforms.

Knowledge Check

Question 1

What console command shows the breakdown of Game, Draw, and GPU frame times?

Correct answer: Bstat unit shows the breakdown of Game thread, Draw thread, and GPU time per frame. The longest time indicates your bottleneck. stat fps only shows framerate.

Question 2

If your Game thread time is highest in stat unit, what type of optimization should you focus on?

Correct answer: C — High Game thread time indicates CPU-bound gameplay logic. Focus on Blueprint optimization: reduce Tick usage, cache references, use timers. Texture and shader optimizations help GPU-bound situations.

Question 3

What is the purpose of Level of Detail (LOD) systems?

Correct answer: B — LODs swap to simpler meshes as objects get farther from the camera. Since distant objects appear smaller, reduced detail isn't noticeable but significantly improves performance by reducing polygon count.

Question 4

What tool helps you find which assets are consuming the most disk space?

Correct answer: C — Size Map (Window → Developer Tools → Size Map) analyzes your project and shows asset sizes. Sort by size to find the biggest offenders—usually textures, meshes, and audio.

Question 5

What's a common Blueprint optimization mistake to avoid?

Correct answer: B — Event Tick runs every frame (60+ times per second). Heavy logic there multiplies rapidly. Use timers for periodic checks, events for responses, and disable Tick on actors that don't need it.

Question 6

What does Max Draw Distance do for an actor?

Correct answer: B — Max Draw Distance culls actors beyond the specified distance. Objects farther away simply don't render, saving GPU resources. Use for small detail objects that aren't visible at distance anyway.

Question 7

What's the recommended approach before starting optimization?

Correct answer: C — Always profile first. Optimizing the wrong area wastes time—reducing textures won't help if you're CPU bound. Use stat unit to identify whether Game, Draw, or GPU is your bottleneck, then focus efforts there.