Performance Optimization
Optimizing your vehicle mods for better performance.
Understanding Performance Impact
Polygon Count
Lower polygon count = better performance
LOD System (Level of Detail):
- LOD0 - Highest detail (up to 50m) → 30,000-50,000 polygons
- LOD1 - Medium detail (50m-100m) → 15,000-25,000 polygons
- LOD2 - Low detail (100m-200m) → 5,000-10,000 polygons
- LOD3 - Distant (200m+) → 1,000-3,000 polygons
Example impact:
Vehicle without LODs: 50,000 polygons always -> 30 percent FPS loss
Same vehicle with LODs:
- Near: 50,000 polygons (full detail)
- Far: 2,000 polygons (minimal)
- Result: 10 percent FPS loss
Texture Optimization
Texture Size Impact:
| Size | Memory | Loading |
|---|---|---|
| 512x512 | 1 MB | Under 1ms |
| 1024x1024 | 4 MB | 2ms |
| 2048x2048 | 16 MB | 8ms |
| 4096x4096 | 64 MB | 32ms |
Best Practice:
- Use 1024x or 2048x for main textures
- Use 512x for detail maps
- Compress using DXT5 format
Draw Calls
Fewer draw calls = better performance
Multiple materials: 5 draw calls
Combined material: 1 draw call
Result: 4x faster rendering
Optimization Techniques
1. Geometry Optimization
Before: 45,000 polygons
- Remove hidden faces: -10,000
- Decimate mesh: -8,000
After: 27,000 polygons (40% reduction)
Process:
- Remove internal faces (not visible)
- Use decimate modifier (Blender)
- Merge nearby vertices
- Remove duplicate geometry
- Test in-game frequently
2. Texture Optimization
Before:
- Diffuse: 2048x2048 (8MB)
- Normal: 2048x2048 (8MB)
- Specular: 2048x2048 (8MB)
Total: 24MB
After:
- Diffuse: 1024x1024 (2MB)
- Normal: 1024x1024 (2MB)
- Specular: 512x512 (0.5MB)
Total: 4.5MB (81% reduction)
3. Material Atlasing
Combine multiple small textures:
Before: 10 separate 512x512 textures (10MB)
After: 1 combined 2048x2048 atlas (4MB)
Result: 60% reduction + faster loading
4. LOD Configuration
<Distances>
<LOD0>0-50</LOD0> <!-- Full detail nearby -->
<LOD1>50-150</LOD1> <!-- Medium detail mid-range -->
<LOD2>150-300</LOD2> <!-- Low detail far -->
<LOD3>300+</LOD3> <!-- Minimal detail very far -->
</Distances>
Handling Optimization
Physics Simplification
<!-- Complex handling -->
<fSuspensionForce>1.5</fSuspensionForce>
<fSuspensionCompDamp>0.25</fSuspensionCompDamp>
<fSuspensionReboundDamp>0.22</fSuspensionReboundDamp>
<!-- Simplified (similar feel, less CPU) -->
<fSuspensionForce>1.2</fSuspensionForce>
<fSuspensionCompDamp>0.15</fSuspensionCompDamp>
<fSuspensionReboundDamp>0.12</fSuspensionReboundDamp>
Weight Reduction
Lower mass = faster calculations:
<!-- Heavy vehicle -->
<fMass>2500.0</fMass>
<!-- Optimized weight -->
<fMass>1800.0</fMass> <!-- Still feels realistic -->
Network Optimization
File Size
Keep mod sizes small:
Vehicle mod breakdown:
- Models (.yft): 15MB
- Textures (.ytd): 20MB
- Audio (.awc): 8MB
- Config (.xml/.meta): 0.1MB
Total: 43MB
Optimized:
- Models: 8MB (LODs + decimation)
- Textures: 6MB (reduced resolution + compression)
- Audio: 4MB (compressed)
- Config: 0.1MB
Total: 18MB (58% reduction)
Streaming
Load assets efficiently:
-- Bad: Loads all immediately
RequestModel(modelHash)
while not HasModelLoaded(modelHash) do
Wait(0)
end
-- Good: Async loading
RequestModelAsync(modelHash)
while not HasModelLoaded(modelHash) do
Wait(10) -- Don't spam CPU
end
Testing Performance
FPS Monitoring
local frameCount = 0
local lastTime = GetGameTimer()
Citizen.CreateThread(function()
while true do
Wait(1000)
local currentTime = GetGameTimer()
local fps = frameCount * 1000 / (currentTime - lastTime)
TriggerEvent('chat:addMessage', {
args = {"FPS", tostring(math.floor(fps))}
})
frameCount = 0
lastTime = GetGameTimer()
end
end)
Memory Profiling
Monitor resource usage:
-- Check model memory
print("Model loaded: " .. GetModelHeapSize(modelHash))
-- Monitor vehicle memory
local vehicle = GetVehiclePedIsIn(PlayerPedId())
print("Vehicle memory: " .. GetVehicleHeapSize(vehicle))
Optimization Checklist
- LOD models created for all assets
- Textures compressed (max 2048x2048)
- Polygon count reduced to minimum viable
- Materials combined where possible
- Handling physics simplified
- Vehicle mass realistic
- File size < 50MB total
- FPS impact < 5% in testing
- All features work correctly
- No visual glitches at distance
Performance Benchmarks
Recommended Specs
| System | Expected Impact |
|---|---|
| High-end PC | Less than 1 percent FPS loss |
| Mid-range PC | 3-5 percent FPS loss |
| Low-end PC | 8-15 percent FPS loss |
Target Sizes
| Asset | Recommended Size |
|---|---|
| Single vehicle | 30-50MB |
| Vehicle pack (5 cars) | 150-250MB |
| Full mod suite | 500MB+ |
Advanced Optimization
Baking Lightmaps
Pre-calculate lighting:
Dynamic lighting: 25% GPU load
Baked lighting: 2% GPU load
Result: 12x faster rendering
Instancing
Reuse geometry:
Unique vehicles: 5
Shared wheels: 1 wheel instance × 5 = 5 wheels
Memory saved: 80% on wheel data
Compression Formats
Use appropriate compression:
Uncompressed: 64MB texture
DXT1 (no alpha): 16MB
DXT5 (with alpha): 32MB
BC6H (HDR): 32MB
Result: 75% memory reduction
Pro Tips
- Profile first - Identify bottlenecks
- Optimize iteratively - One change at a time
- Test on lower-end hardware - Ensures compatibility
- Use LOD system - Essential for performance
- Compress textures - Biggest impact for size
- Reduce polygon count - Second biggest impact
- Monitor FPS - Track actual performance
- Keep backups - Before optimizing
Optimization Tools
- Blender - LOD generation, decimation
- Substance Painter - Texture optimization
- Texture Baker - Lightmap baking
- CodeWalker - Model analysis
- GPU-Z - GPU monitoring
- HWiNFO - System monitoring
Performance optimization is key to making vehicles that work well across all player systems!