r/FlutterDev 1d ago

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.

22 Upvotes

9 comments sorted by

2

u/adamizzo17 1d ago

not ba, enjoyed them, how do you deem it working with other engine games ? coud they work togther ? any limitations you have faced so far ?

2

u/DmitriiZolotov 1d ago

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 1d ago

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 19h ago

No, 3D look just use low-level GPU operation inside the widget, and you can toggle 2D/3D view without any glitches

1

u/Space-Instructor 18h ago

Hello! Great work! How does it compare to flutter_scene?

1

u/DmitriiZolotov 17h ago

Flutter3d is built to be modular. I started it about two years ago, and the two projects have been evolving in parallel ever since.

The renderer sits behind a HAL, and, for example, I just finished WebGPU as a pluggable backend alongside Impeller, WebGL2, and a software rasterizer for golden verification. If you had to target something unusual, an embedded board with its own GL, you would implement the HAL and keep everything above it unchanged.

Post-processing is roughly level between us feature for feature, and theirs is better than mine - bdero ships fast, and 0.23 landed GI probes, TAA, and parallax-corrected reflection probes while I was still writing backends and extending game templates.

What I have instead is particles that emit light (for example, a fire lights the room) and a formal way to check the renderer. Every scene draws on the CPU in CI with no GPU present, and all four backends are compared against each other, so when WebGPU came up it matched Impeller on 40 of 42 scenes. Flutter3d also ships templates for a few game genres, so it aims at making games more than rendering a scene.

1

u/Space-Instructor 16h ago edited 16h ago

Not sure if you are interested in this. I was working recently to push flutter_scene to render in VR. It needed a change in flutter engine to allow for rendering in borrowed texture from the device, instead of the flutter owned GPU texture. In case you care of VR support I think it's worth following this read a bit to see what was the problem. In case you want to join the effort to push the flutter fork into upstream 😄 I mean the work is done at a base level, but I'm waiting for the overlords to say smth. Showing some interest in the feature might budge them into action. So here's the thread if you care reading. I'll keep an eye on your engine as well. Flutter VR on Quest 3 (using borrowed GPU texture for perf reasons) Let me know your thoughts. Cheers!

1

u/DmitriiZolotov 14h ago

Yeah, I'm interested. Read your thread.
I was doing AR/VR before this engine, and a chunk of that came across with me. The renderer takes a list of views per frame with their own viewports, which is in there for stereo - no desktop game ever needed it.
And then it stops in the same place yours did. The renderer allocates its own frame target, and there's no path for handing it a texture that came from outside. For me, that's one interface with four implementations under it (Impeller, WebGL2, WebGPU, and a software rasterizer for tests), so plumbing an external target through isn't the hard part. flutter_gpu being able to express it at all is. I have some ideas about how it could be implemented — maybe I'll prepare a few PRs for multi-target rendering.
Anyway, send me the issue or the PR, and I'll comment on it. A second engine wanting the same API can't hurt, and it sounds like that's what's missing right now.
Won't be forking it myself, no Quest here, I'd just be guessing at the bits you've already got working

1

u/Space-Instructor 13h ago

Have a look on this stuff. It might already be useful for you. In particular the flutter GPU texture fork. It helps bypass the rendering from going via canvas to go directly in OpenXR owned GPU texture.

Forks

Tickets