🚀 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 unitshows: 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
Figure: Frame time breakdown shows where your game spends time each frame.
GPU Visualizer
For GPU bottlenecks, use the GPU Visualizer:
- Press Ctrl+Shift+, (comma) while playing
- Or type
profilegpuin console - Shows detailed GPU pass timing
- Identifies expensive rendering passes
Unreal Insights
For deep profiling:
- Enable via Tools → Session Frontend
- Or launch with
-trace=default - Records comprehensive performance data
- 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:
- Select mesh in Content Browser
- Right-click → Create LOD
- Or import with LODs already created
- Configure LOD distances in Static Mesh editor
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:
- Select actor(s) in the level
- In Details, find LOD → Max Draw Distance
- Set the distance (in cm) beyond which the actor disappears
- 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
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:
- Go to Window → Developer Tools → Size Map
- Or use Asset Audit (Window → Developer Tools)
- See which assets consume the most space
- 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:
- Right-click folder → Audit Assets
- Or use Reference Viewer on individual assets
- Assets with no references may be unused
- 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
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
- Open the level you'll be packaging (your main gameplay level)
- Make sure it's representative of typical gameplay
Step 2: Enable Stat Display
- Press Play to start PIE
- Press ~ (tilde) to open console
- Type:
stat fpsand press Enter - Type:
stat unitand press Enter - Note your current FPS and frame times
Step 3: Record Baseline
- Walk around your level, especially busy areas
- Note minimum FPS and maximum frame times
- Record these numbers:
- Average FPS: _____
- Minimum FPS: _____
- Game Thread: _____ ms
- Draw Thread: _____ ms
- GPU: _____ ms
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)
- While playing, press Ctrl+Shift+, (comma)
- GPU Visualizer opens showing render pass costs
- 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 statsstat initviews— View culling informationstat particles— Particle system costsstat anim— Animation costs
Part 3: Apply Optimizations
Step 7: Optimize Textures
- Open Window → Developer Tools → Size Map
- Find the largest textures
- 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
- Identify high-poly meshes used frequently
- Right-click mesh in Content Browser → Create LOD
- Choose reduction settings (50% for LOD1, 25% for LOD2)
- Open Static Mesh editor, adjust LOD screen sizes
Step 9: Set Distance Culling
- Select small detail objects in your level
- In Details, find LOD → Max Draw Distance
- Set appropriate distances:
- Small props: 3000-5000
- Medium objects: 8000-15000
- Large structures: Leave at 0 (no limit)
Step 10: Check Blueprint Tick
- Open your main gameplay Blueprints
- Check Event Tick usage
- Move non-critical logic to timers
- Cache frequently accessed references
- 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
- Open Window → Developer Tools → Size Map
- Click Load All to analyze entire project
- Sort by size to find largest assets
- Note total estimated cooked size
Step 12: Find Unused Assets
- Right-click Content folder → Audit Assets
- Or use Reference Viewer on suspicious assets
- Look for assets with 0 referencers
- Verify they're truly unused before deleting
Step 13: Clean Up
- Delete confirmed unused assets
- Right-click Content → Fix Up Redirectors in Folder
- This cleans up after moved/renamed assets
Part 5: Verify Improvements
Step 14: Re-test Performance
- Play your level again
- Enable
stat fpsandstat unit - Walk through the same areas as before
- Record new numbers and compare:
- New Average FPS: _____ (was: _____)
- New Minimum FPS: _____ (was: _____)
- Frame time improvement: _____
Step 15: Check Size Map Again
- Reopen Size Map
- Compare estimated size to before
- 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 nonethen 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
- Merge Actors: Select static meshes → Actor → Merge Actors to reduce draw calls
- HLOD: Set up Hierarchical LOD for open world areas
- Async Loading: Implement level streaming for large levels
- Niagara GPU: Convert heavy particle systems to GPU simulation
- 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
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: B — stat 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.