Framerate Optimization
Maintaining a robust, high-frequency frame rate is critical for passenger comfort. Frame drops or tracking latency inside a moving vehicle can cause immediate motion sickness.
To maximize the rendering performance of your procedural scenes on mobile devices, apply the following systemic guidelines:
1. Visual Range and Spawner Extents
The most immediate bottleneck for main-thread rendering performance is the total active object count drawn by the GPU.
- Optimize Spawner Extents: Every spawner node provides an Extents parameter that dictates the physical boundary size of its active grid. Reducing a spawner's extents by 50% quarters the total active geometry instances spawned in the scene.
- Conceal Spawner Popups: While reducing extents significantly boosts frame rates, it can cause distant objects to pop into view abruptly. To conceal popup effects, implement the following design workflows:
- Volumetric Fog Fading: Fade objects in smoothly as they enter the spawner grid using fog or custom depth-shading.
- Procedural Animation Scaling: Use scale-in, fly-in, or drop-down scripts triggered in the prefab's
OnEnable()lifecycle call.
- Harness Quarter Size Terrain: Activate the
quarter size terrainoption on yourElasticSceneGenerator. This renders the native Unity terrain mesh at a quarter of the ESG's full boundaries. Critically, this option does not affect the underlying map data, meaning spawners and graph masks still evaluate the full ESG boundary coordinates perfectly, letting you cull rendering without sacrificing layout accuracy.
2. Spawner Tweaks & Billboard Optimization
- Distance-Dependent LODs: Apply standard Distance Transforms to your road network masks to calculate how close objects can spawn relative to the vehicle's driving lane. If objects only spawn far away from the road, replace complex 3D meshes with simple billboards (flat 2D quad planes mapped with diffuse textures).
- Prefab Consolidation: If your scene populates dense clusters of props (e.g., combining a rock, grass clump, and flower), do not spawn them with separate spawners. Combine them into a single consolidated prefab in Unity and spawn them together. This reduces CPU draw call overhead.
- Harness
GridSpawner: For dense environmental clutter (spacing under 20 meters), replace resource-heavyPoseSetSpawnerswith high-performanceGridSpawners.GridSpawnerruns on optimized native code blocks while still supporting random rotations, map-driven elevation, andPrefabSelectorvariations.
3. Overdraw Mitigation
Overdraw occurs when the GPU wastes cycles rasterizing multiple overlapping transparent or opaque triangles on the same screen pixel.
- Eliminate Hidden Geometry: Refine all prefab meshes by deleting internal or bottom surfaces that are never visible to the player but still require GPU rasterization.
- Smooth Far-Off Terrain: Avoid creating highly rugged, alternating hills near the horizon. Use Distance Transforms to smooth out far-off terrain boundaries—this minimizes back-to-front rendering passes behind nearby hills.
- Avoid Opaque Overlaps: Sort opaque objects efficiently. Ensure large structural walls are rendered with early depth testing (z-test) to reject hidden fragments quickly.
4. Mobile & IVI Rendering Optimizations
For mobile processors and built-in vehicle screens, fragment operations are the first address for optimization:
- Bake Highlights & Shadows: Minimize dynamic lighting. Disable real-time shadow casting for small environmental props and bake ambient occlusion, lighting, and static shadows directly into the textures.
- Limit Terrain Texture Layers: Keep painted terrain layers to a maximum of 4 layers. Using more than 4 terrain layers requires multiple rendering passes, which can severely degrade performance on mobile chips.
- Use Diffuse Only on Terrain: Disable normal, gloss, or detail textures on your terrain splatmaps. Set the terrain shader to use diffuse textures only.
- Minimize Transparencies: Avoid complex transparent shaders, alpha-blended smoke particles, and overlapping foliage planes. Where possible, utilize alpha-test (cutoff) shaders rather than alpha-blend.
- Disable Multi-Pass Shaders: Never use custom shaders that require multiple render passes. Keep all environmental materials to a single, optimized pass.
5. Resolution Trade-Offs & Foveated Rendering
- Downscale Render Resolution: Reduce the target viewport resolution and upscale the buffer. While this can introduce slight pixelation (notably on fine display text), the massive reduction in pixel fill-rate is highly effective at boosting frame rates.
- Activate Foveated Rendering: If your VR headset's SDK provides foveated rendering, always enable it. This decreases fragment shader resolution in the player's peripheral vision while keeping the focal center sharp, saving immense GPU bandwidth.
6. Physics and Build Settings
- Deactivate Unused Physics: Remove rigidbodies, continuous collision detection, and complex colliders from background props. Use simple box or sphere primitives only when interaction is strictly required.
- Disable Auto Sync Transforms: Go to Unity's Physics Settings and uncheck Auto Sync Transforms. This stops Unity from updating physics colliders every time a transform changes—which can severely bog down the CPU as the ESG continuously shifts positions during vehicle motion.
- Disable Stack Traces: Ensure that console logging stack traces are completely disabled in your production build settings.
- Deploy Release Builds Only: Always compile production packages as non-debug release builds with no profilers attached.