Why We Built a Dual 2.5D + Filament 3D Architecture
Most mobile endless runners lock players into a single heavy 3D engine that struggles on affordable phones across West Africa. For Flood Surfers V2, we took a different engineering path inside Flutter: a single deterministic game simulation (GameEngine) drives three switchable viewports—a custom perspective 2.5D Canvas (default for instant zero-wait boot), a classic 2D Side View, and a real-time Google Filament 3D PBR viewport powered by thermion_flutter.
Solving Non-IBL Mobile PBR Shading (No Black Metals, No HDR Whiteout)
One of the first lessons in mobile Filament engineering is that shipping huge HDRI skyboxes inflates APK size and memory bandwidth. Yet without an IBL environment map, standard metallic PBR materials (metallicFactor >= 0.8) reflect pure black because dielectrics rely on diffuse lighting while metals rely almost entirely on environment reflections.
Our asset pipeline solves this across all 56 embedded .glb models through three strict rules:
- Capped non-IBL metalness: Every material stays at
metallicFactor <= 0.16with crisp roughness contrast so gold Naira coins, chrome magnets, and Accra's Black Star gleam brightly under directional lights instead of turning dark. - Paired baseColor + emissive textures: Binding the same embedded PNG texture to
emissiveTextureat a gentle0.26–0.34bounce factor eliminates flat grey shadow washout while keeping all emissives clamped<= 0.62to prevent bloom whiteout. - 4-Point Studio Directional Lighting: Warm golden key light with shadows, cool sky fill, aqua water up-bounce, and a warm back-rim light sculpt clear silhouettes on spinning pickups and moving buses.
Keeping Frame Times Smooth on Budget ARM Devices
Testing directly on everyday Android hardware (such as 32-bit android-arm and 64-bit android-arm64 entry-level devices) surfaced three concrete bottlenecks we systematically eliminated:
- Two-Phase Instant-Boot Asset Streaming: Instead of blocking Frame 1 while uploading all 4 regional city corridors (222,000+ triangles) and 10 bus fleets, Phase 1 uploads only the active city, active landmark, active bus livery, and equipped surfboard. Phase 2 streams the remaining 21 assets silently one frame at a time in the background.
- Zero Redundant FFI Transform Calls: Tracking hidden singleton sets (
_hideOnce) and pool high-water marks (_hideUnused) eliminated roughly 3,000 wasted Dart-to-C++ matrix marshaling calls every second when effects like rain, warp lines, or boss assets are inactive. - Strict Water Elevation Layering: Separating the corridor floodbed (
-0.260m), translucent scrolling caustic river mesh (-0.232mwith strictly non-negative wave displacement), rolling wave crests (-0.195m), wakes (-0.165m), surfer contact shadow (-0.150m), and shockwave rings (-0.115m) removed all mobile depth-buffer Z-fighting.
.glb models—surfer, 7 boards, 10 regional buses, 4 cities, 4 landmarks, animated caustic river, boss, and all 25 pickups/hazards—total just 4.54 MB combined.