Performance Tips
Performance Tips
Section titled “Performance Tips”Guidelines for optimizing Strata applications across different platforms.
Platform Targets
Section titled “Platform Targets”| Platform | Target FPS | Key Constraints |
|---|---|---|
| Mobile | 30-60 | GPU limited, thermal |
| Desktop | 60 | Balanced |
| High-end | 60-144 | Full quality |
General Principles
Section titled “General Principles”1. Profile First
Section titled “1. Profile First”Always measure before optimizing:
import { Perf } from 'r3f-perf';
<Canvas> <Perf position="top-left" /> {/* Your scene */}</Canvas>2. Use LOD
Section titled “2. Use LOD”Enable level-of-detail for all systems:
<Terrain lodLevels={3} lodDistances={[50, 150, 400]} /><TreeInstances lodLevels={4} billboardDistance={200} /><GrassInstances fadeStart={80} fadeEnd={100} />3. Limit Draw Calls
Section titled “3. Limit Draw Calls”Target < 100 draw calls on mobile:
// ❌ Bad: Individual meshes{trees.map(t => <TreeMesh position={t.pos} />)}
// ✅ Good: Instanced rendering<TreeInstances count={trees.length} positions={treePositions} />Feature-Specific Optimization
Section titled “Feature-Specific Optimization”Terrain
Section titled “Terrain”// Mobile<Terrain resolution={32} chunkSize={64} viewDistance={2} />
// Desktop<Terrain resolution={64} chunkSize={32} viewDistance={4} />// Mobile - disable expensive effects<Water segments={64} reflections={false} caustics={false}/>
// Desktop - enable effects<AdvancedWater segments={128} reflections reflectionResolution={512} caustics/>Vegetation
Section titled “Vegetation”| Quality | Grass | Trees | Rocks |
|---|---|---|---|
| Mobile | 3,000 | 100 | 50 |
| Desktop | 15,000 | 500 | 200 |
| High-end | 50,000 | 2,000 | 500 |
Volumetrics
Section titled “Volumetrics”// Mobile<VolumetricFogMesh steps={16} animated={false} />
// Desktop<VolumetricFogMesh steps={32} animated />// Mobile<ProceduralSky stars={false} moon={false} />
// Desktop<ProceduralSky stars starCount={5000} moon />Adaptive Quality
Section titled “Adaptive Quality”import { useDevice } from '@strata-game-library/capacitor-plugin/react';
function AdaptiveScene() { const device = useDevice(); const isMobile = device.deviceType === 'mobile';
const quality = isMobile ? { grassCount: 3000, treeCount: 100, waterReflections: false, volumetricSteps: 16, } : { grassCount: 15000, treeCount: 500, waterReflections: true, volumetricSteps: 32, };
return ( <Canvas dpr={isMobile ? 1 : [1, 2]}> <GrassInstances count={quality.grassCount} /> <TreeInstances count={quality.treeCount} /> <Water reflections={quality.waterReflections} /> <VolumetricFogMesh steps={quality.volumetricSteps} /> </Canvas> );}Common Issues
Section titled “Common Issues”Issue: Low FPS
Section titled “Issue: Low FPS”- Check draw call count (use r3f-perf)
- Reduce instance counts
- Lower texture resolutions
- Disable post-processing
Issue: Memory Warnings
Section titled “Issue: Memory Warnings”- Dispose unused geometries/materials
- Use texture atlases
- Implement object pooling
- Lower texture resolutions
Issue: Thermal Throttling
Section titled “Issue: Thermal Throttling”- Cap frame rate to 30fps on mobile
- Reduce shader complexity
- Disable shadows
- Use simpler effects