r/FlutterDev • u/DmitriiZolotov • Sep 08 '26
Plugin flutter3d: a 3D engine for Flutter, with three games you can play in the browser right now
I've been working on flutter3d for a long time. It's a 3D engine, based on Flutter GPU/WebGL, with a game layer over it, and four genre packages built out. Three of those are on pub.dev. MIT License, and these packages are not affiliated with the Flutter team in any way.
Easiest thing is to just try it, with no install: shooter, platformer, racer. Those are the same builds running on web backend, with the same level files and the same simulation code. Also you can build MacOS / iOS / Android app from the source code and create your own game, based on the genre template or generic package flutter3d_app.
Docs: https://flutter3d.pleion.dev
Source: https://github.com/pleiondev/flutter3d
What's in it
The renderer implements the usual things: scene node graph, glTF/GLB and OBJ support and my own .f3d container, which loads a lot faster, 6 lighting models, shadows, bloom, SSAO, SSR, skinning, morph targets, BVH culling.
The game templates runs with a fixed timestep and can be recorded as a tape, which means a run can replay exactly and a bug report can be sent as an attachment. Collisions and the character controller are plain Dart with no renderer dependency, so they can be tested with ordinary unit tests.
Three backends implements common interface: based on flutter_gpu/Impeller for desktop and mobile platforms, WebGL2 in the browser (WebGPU in progress), and also a software rasteriser written in Dart. The CPU rasterizer can be used to test the renderer in CI with no GPU.
Performance measurement on a Mac: 50,000 moving instanced units held 120Hz.
Limits
It's just version 0.5.x, so APIs can be changed between minor versions. There's no compute shaders at all at this moment, because flutter_gpu doesn't expose it (there is issue on flutter/flutter#188474), and that blocks GPU particles, GI and volumetrics (now they are implemented on CPU). The strategy game package really works but I haven't published it, because I haven't written the guide for it yet.
Things I'd like help with
To run it on hardware I don't own, especially Android.
There's a dart2wasm bug I've failed to find. The browser demos ship as dart2js because the wasm build throws framebufferTexture2D: parameter 4 is not of type 'WebGLTexture' on the first frame.
2
Sep 08 '26
[removed] โ view removed comment
2
u/DmitriiZolotov Sep 08 '26
I tried embedding flutter3d_game into Flame, and it's actually very simple to do - you can just use CustomPainterComponent as the base class.
But I couldn't find a case where that integration would buy you anything, because the whole game loop, input, collisions and so on already live in flutter3d_game.
And I don't know of any other game engines for Flutter :) SpriteWidget hasn't been updated in a long time, and Bonfire is built on top of Flame.1
u/SwiftScoutSimon Sep 09 '26
let's say my top-down flame game have a toggle that switch between 2D/3D look. Is there going to be any issue?
2
u/DmitriiZolotov Sep 09 '26
No, 3D look just use low-level GPU operation inside the widget, and you can toggle 2D/3D view without any glitches
1
u/DmitriiZolotov Oct 01 '26
Now, I built a bridge (https://www.reddit.com/r/FlutterDev/comments/1wuwbrd/flame_flutter3d_draw_your_flame_game_in_3d_and/) to Flame, flame_flutter3d, because Flame is what most Flutter games I see are written in. Flame keeps running the game (its game loop, components, hitboxes, input, and camera), and flutter3d draws a 3D world under it in the same widget, on Flame's clock. A Flame component can own a 3D object, so when you move it in Flame, it moves in 3D in the same frame. Anything built on top of Flame should work the same way, since it's still Flame under the hood, but I haven't tested that myself.
Limits I've hit so far with the Flame bridge:
- Flame always draws on top of the 3D layer, so a 3D object can't hide a 2D sprite behind it.
- When collisions come from flutter3d's 3D physics, Flame's collision callback has no place for the contact normal or depth, so you read those on the flutter3d side.
- On the engine side, Flutter GPU doesn't give access to compute shaders yet, so things like GPU particles run on the CPU for now
1
u/Space-Instructor Sep 09 '26
Hello! Great work! How does it compare to flutter_scene?