-
Notifications
You must be signed in to change notification settings - Fork 2
Performance Tips
Practical optimization guide for SparkEngine. Covers rendering, physics, audio, networking, and general best practices for shipping smooth games.
Before optimizing, measure. SparkEngine provides several profiling tools:
| Tool | How to access | What it shows |
|---|---|---|
| FPS counter | Press F3 or ShowFPS = true in settings |
Frame rate and frame time |
| Profiler panel | Editor → Window → Profiler | Per-system frame timing |
| Scene Statistics panel | Editor → Window → Scene Statistics | Entity/component counts, draw calls, triangles |
| Console commands | See below | On-demand metrics |
render_stats # Draw calls, triangles, batches
physics_metrics # Physics step time, body count, contacts
audio_metrics # Active sources, mix time
metrics # All-in-one system overview
game_stats # Game module performance
Enable GPU timing queries to identify GPU bottlenecks:
[Rendering]
EnableGPUTiming = trueQuality presets adjust multiple settings at once:
render_quality low # Mobile/low-end
render_quality medium # Integrated graphics
render_quality high # Discrete GPU (default)
render_quality ultra # High-end GPU
Keep draw calls under control. The default budget is 1000 per frame:
[Rendering]
MaxDrawCalls = 1000Reduce draw calls by:
- Using material atlases (fewer unique materials = fewer draw calls)
- Enabling frustum culling (on by default)
- Enabling occlusion culling for dense scenes:
OcclusionCulling = true - Using LOD (Level of Detail) for distant objects
- Batching small objects into single meshes
Shadows are often the most expensive effect. Tune them:
[Graphics]
ShadowQuality = 1 # 0=Off, 1=Low, 2=Medium, 3=High
[Rendering]
ShadowMapSize = 1024 # Lower = faster (default 2048)
CascadeCount = 2 # Fewer cascades = faster (default 3)Or disable shadows entirely for a large performance win:
shadows off
Each post-processing effect adds a full-screen pass. Disable effects you don't need:
[PostProcess]
BloomEnabled = true # Keep — relatively cheap
[SSAO]
Enabled = false # Expensive — disable if needed
[SSR]
Enabled = false # Expensive — disable if needed
[Volumetric]
Enabled = false # Expensive — disable if needed
[MotionBlur]
Enabled = false # Moderate costCost ranking (approximate, GPU-dependent):
| Effect | Cost | Notes |
|---|---|---|
| FXAA | Very low | Cheap AA |
| Bloom | Low | 6 blur passes |
| TAA | Low–Medium | Good quality/perf ratio |
| MSAA 4x | Medium | Memory + bandwidth |
| Motion Blur | Medium | Depends on sample count |
| SSAO | Medium–High | 16 samples per pixel default |
| SSR | High | Ray-marching per pixel |
| Volumetric Fog | High | 3D ray-marching |
Scale internal resolution for a quick FPS boost without changing window size:
[Graphics]
RenderScale = 0.75 # 75% internal resolutionLet the engine auto-adjust quality to maintain a target framerate:
[DynamicQuality]
Enabled = true
TargetFrameTimeMs = 16.67 # 60 FPS target
MinRenderScale = 0.5 # Won't go below 50% resolutionThe scaler adjusts render scale, shadow resolution, LOD bias, and texture mip bias automatically using a PID controller.
Control texture memory usage:
tex_quality medium # Reduce texture resolution
tex_memory 512 # Set 512 MB texture budget
[Rendering]
MaxTextureSize = 1024 # Cap texture dimensions
AnisotropyLevel = 4 # Lower anisotropy (default 16)Choose the right rendering path for your scene:
| Path | Best for | Setting |
|---|---|---|
| Forward | Simple scenes, few lights | RenderPath = 0 |
| Deferred | Many lights, complex materials |
RenderPath = 1 (default) |
| Forward+ | Many lights, transparent objects | RenderPath = 2 |
| Clustered | Very many lights (100+) | RenderPath = 3 |
The default physics timestep is 60 Hz (16.67ms). For simpler games, 30 Hz saves CPU:
[Physics]
FixedTimestep = 0.03333 # 30 Hz physics
MaxSubSteps = 2 # Fewer sub-stepsMonitor your physics body count:
physics_metrics # Shows active/sleeping body counts
physics_list # List all bodies
Tips:
- Remove far-away dynamic bodies or put them to sleep
- Use static bodies for immovable geometry (cheaper than kinematic)
- Use simple collision shapes (box, sphere, capsule) instead of mesh colliders where possible
- Jolt supports multithreaded physics — this is on by default via the Job System
Physics debug draw is expensive. Only enable it during development:
physics_debug off # Always disable for profiling
Limit concurrent audio sources:
[AudioExtended]
MaxSources = 16 # Default 32; reduce for low-endIf your game doesn't need spatial audio, disable it:
[AudioExtended]
Enable3D = false # Skip 3D spatializationDSP effects add CPU cost:
[AudioExtended]
EnableReverb = false # Disable reverb processing
EnableEAX = false # Disable EAX effectsTune AI settings for your game's needs:
[AI]
DetectionRange = 20.0 # Shorter detection = fewer checks
ReactionTime = 0.5 # Slower reactions = fewer updates
CoverSearchRadius = 10.0 # Smaller search radiusNot all AI agents need to think every frame. The AI system uses behavior trees — complex trees with many conditions are more expensive. Keep trees shallow and use simple condition checks.
Lower the replication rate for games that don't need fast updates:
[Network]
ReplicationRate = 10.0 # 10 Hz instead of default 20 HzEnable compression for bandwidth-limited scenarios:
[Network]
EnableCompression = trueAdjust send/receive buffers based on your game's needs:
[Network]
SendBufferSize = 32768 # Default 65536
ReceiveBufferSize = 32768Prevent runaway scripts from stalling the engine:
[Scripting]
ExecutionTimeoutMs = 50.0 # Kill scripts after 50ms (default 100)
MaxCallStackDepth = 32 # Limit recursion (default 64)
MaxScriptMemoryMB = 32 # Limit script memory (default 64)Disable hot-reload in shipping builds to save file-watch overhead:
[Scripting]
HotReloadEnabled = falseEnable animation compression to reduce memory:
[Animation]
CompressionQuality = 3 # 0=None, 1=Low, 2=Medium, 3=HighReduce animation quality at distance:
[Animation]
LodDistanceMultiplier = 0.5 # More aggressive LOD transitionsCap concurrent animation montages:
[Animation]
MaxActiveMontages = 2 # Default 4Textures are typically the largest memory consumer. Guidelines:
| Texture Type | Recommended Size | Notes |
|---|---|---|
| Character diffuse | 2048×2048 | Main characters |
| Environment | 1024×1024 | Tiling textures |
| Props | 512×512 | Small objects |
| UI | 256×256 or atlas | UI elements |
| Normal maps | Same as diffuse | BC5 compressed |
For large worlds, the streaming system loads/unloads areas automatically. Monitor it via the Streaming editor panel or console.
Always profile with Release builds. Debug builds are 5–10x slower:
cmake --build build --config ReleaseDisable subsystems you don't use to reduce overhead:
cmake -B build \
-DENABLE_AI=OFF \ # If your game has no AI
-DENABLE_NETWORKING=OFF \ # If single-player only
-DENABLE_PROFILING=OFF # For shipping buildsFor dedicated servers, disable all rendering:
./SparkEngine -headless -game MyGame.dllThis skips graphics initialization entirely and uses NullRHIDevice.
-
Measure first — Use
render_stats,physics_metrics,metrics -
Use quality presets —
render_quality mediumfor quick wins - Check draw calls — Keep under 1000; enable frustum/occlusion culling
- Tune shadows — Often the single biggest performance lever
- Disable unused post-processing — SSAO, SSR, volumetrics
- Use dynamic quality scaling — Let the engine adapt automatically
- Monitor physics body count — Use simple shapes, remove distant bodies
- Limit audio sources — 16–32 concurrent sources is plenty
- Profile with Release builds — Debug builds are not representative
-
Test on target hardware — Use
-test-frames 1000for benchmarking
Run a reproducible benchmark:
# Run 1000 frames and exit
./SparkEngine -test-frames 1000 -window-size 1920x1080 -game MyGame.dllCheck frame timing in the output log. Compare across changes to catch regressions.
- Configuration Reference — All settings and commands
- Profiler and Debugging — Detailed profiling guide
- Performance Profiling Guide — Frame profiling workflows
- Rendering and Graphics — Graphics pipeline details
- Dynamic Quality Scaler — Auto quality adjustment
- Troubleshooting — Performance-related issues
Published from ad9c3c1953cc. Edit the canonical source in wiki/.
- Documentation
- Docs route
- Wiki index
- Guides
- Tutorials
- Samples
- Examples
- API Reference
- API route
- Reference
- Build Guide
- Dependencies
- FAQ
- Changelog
- Roadmap
- Contributing
- Code of Conduct
- Home
- FAQ
- Getting Started
- Quick-Start Tutorial
- Making Your First Game
- Making Your First Multiplayer Game
- Artist Workflow Guide
- Editor Walkthrough
- Migration Guide
- How SparkEngine Works
- Architecture Overview
- Engine Architecture Flowchart
- Creating a Game Module
- Game Modules (catalog)
- Entity Component System
- Rendering and Graphics
- Physics
- Cloth Simulation
- Audio
- Input System
- Camera System
- Scripting with AngelScript
- Visual Scripting
- AI and Navigation
- Animation
- 2D Systems
- Networking
- Dedicated Server
- Multiplayer Quick Start
- Area Server Architecture
- Scene Management
- Large World Support
- Collaborative Editing
- Coroutine System
- Event System
- Event Response System
- Job System
- UI System
- UI Layout Extensions
- Localization
- Dialogue System
- Destruction System
- Replay System
- Achievement System
- Loading System
- Mod System
- Content Delivery
- Tween System
- Memory Integrity
- Gameplay Systems
- Terrain and Procedural Generation
- Save System
- Persistence System
- Day Night Cycle and Weather
- Cinematic Sequencer
- Runtime Prefabs
- SparkEditor
- Editor Tutorials
- SparkConsole
- SparkDaemon
- Shader Pipeline
- Asset Pipeline
- Asset Validation
- Asset Migration
- Game Packaging
- Online Services
- DataTable System
- Loot and Crafting System
- CSG System
- Font System
- Timer Manager
- Movie Render Pipeline
- HLOD and World Partition
- Remote Debug System
- Selection Manager
- Asset Dependency Graph
- Editor Automation
- File Watcher
- Project Templates
- System Requirements
- VR Support
- Mobile Platform
- Accessibility
- Platform Input
- Cross-Compilation: Wine Testing
- RHI Abstraction Layer
- D3D11 Backend
- D3D12 Backend
- Vulkan Backend
- OpenGL Backend
- Metal Backend
- DXR Raytracing
- Hybrid Ray Tracing
- Upscaling (DLSS/FSR)
- Render Graph
- Shader Graph
- GPU Particles
- GPU-Driven Rendering
- Volumetric Fog
- Volumetric Clouds
- Global Illumination
- Virtual Texturing
- Water Rendering
- Clustered Lighting
- Material System
- Post-Processing
- Shadow System
- Particle System
- Decal System
- Sky and Atmosphere
- Foliage System
- Mesh Shaders
- Neural Rendering
- Configuration Reference
- Performance Tips
- Benchmark Framework
- Threading Model
- Memory Safety
- Memory Management Patterns
- Build System and CMake Modules
- Profiler and Debugging
- Performance Profiling Guide
- Telemetry System
- Golden Image Testing
- Utilities
- Testing
- Codebase Statistics
- Codebase Health
- Error Handling Patterns
- Hot Reload Overview
- Troubleshooting
- Contributing
- Workflow Patterns
- Build Optimizations
- CI Reproducible Builds
- GitHub API and PR Checks
- Git Rebase Conflicts
- Clang-Format
- Code Quality Violations
- AI Bloat Pattern
- MinGW + Wine Cross-Compilation
- Live Editor Testing
- Engine & Renderer Landscape
- DuetOS Portability Catalog
- Five-Engine Analysis
- Eleven-Engine Analysis
- ThorVG / Unity Graphics Analysis
- Advanced Techniques Catalog
- Third-Party Library Evaluation
- Engine Viability Evaluation
- Engine Feature Recommendations
- Project Recommendations
- Mac Compatibility Analysis
- Codebase Observations
- Codebase Bloat Audit
- Test Suite Audit
- Documentation Coverage Audit
- ThirdParty Dependencies Audit
- Load Test Baseline
- Gameplay Systems Status
- SparkGame Module Status
- Stub and Abandoned Features
- Memory Integrity System
- Memory Safety Evaluation
- Hardware Acceleration Systems
- Jolt Physics Integration
- GPU/CPU Separation Plan
- Daemon Services Architecture
- Reflection & Polymorphism Refactoring Plan
- SparkBuild In-Tree
- Wine No-JobSystem Breakthrough
- Wine Role and Fallback Tiers