Skip to content

flutter_scene 0.17.0

Choose a tag to compare

@bdero bdero released this 10 Jun 19:28
  • Added SceneView, a widget that renders a Scene and drives its per-frame loop, so apps no longer write their own CustomPainter. It takes a fixed camera or a cameraBuilder(elapsed) and exposes the scene to descendants through SceneScope.
  • Added debug-mode hot reload for assets, driven by SceneView. Editing a .fmat updates the running scene in place (culling, blending, shading model, and parameter defaults, plus the GLSL body) with no app code, and re-exporting a .glb (or editing a referenced prefab) patches the scene in place while preserving node identity, transforms, and animation playback. Load materials and scenes by source path (loadFmatMaterial, loadScene) to participate; loadScene takes an optional onReload callback for re-applying per-instance customizations after a scene is patched.
  • Added DataAssets-backed GLB import: buildScenes can auto-discover assets/**/*.glb and register the generated .fsceneb packages as DataAssets, and loadScene / SceneRegistry load them by source path. Requires Dart data assets (flutter config --enable-dart-data-assets). The composed document and its GPU resources are cached per scene, so loading the same scene again instantiates a fresh node graph cheaply, sharing those resources. The dart run flutter_scene:init hook wires up both buildScenes and buildMaterials. Both accept a discoveryRoot to auto-discover under a directory other than assets/, or an explicit list to bypass discovery.
  • Added AnimationClip.rebind / AnimationPlayer.rebind (animation re-binding across a hot reload, keeping playback state) and Mesh.clone so cloned scene instances get independent materials.
  • Skinned geometry imported by buildScenes carries an offline-baked pose-union bound (the union of every animated pose's extent), so skinned content is frustum-culled soundly instead of being treated as always visible.
  • Breaking: removed the .model format. Node.fromAsset and Node.fromFlatbuffer are gone, along with the fromFlatbuffer constructors on Geometry, Material, Skin, and Animation. Convert .glb sources with the buildScenes build hook and load them by source path with loadScene, or load glTF binaries at runtime with Node.fromGlbAsset / Node.fromGlbBytes (no conversion step needed).
  • Breaking: .fmat materials are now auto-discovered under assets/ (matching where .glb models are discovered) instead of materials/, and loadFmatMaterial resolves a material by its .fmat source path (for example assets/toon.fmat) instead of by material name, so materials that share a name in different directories no longer collide. Move .fmat files under assets/, or pass an explicit list to buildMaterials.
  • Building .fmat materials and models now requires flutter_gpu_shaders 0.5.0.
  • Added the .fscene / .fsceneb serialized scene format: author scenes as text or import them from .glb with buildScenes, and load them by source path with loadScene (with in-place hot reload, prefabs, and streaming). Prefab expansion is deterministic, so an unchanged scene composes to the same ids across sessions and platforms.
  • Added scene serialization: serializeScene captures a live node graph back into a document (geometry, materials, skins, animations, visibility, and hand-built meshes included), and realizeStage / serializeStage apply and read back scene-level render settings (environment, skybox, sky lighting, exposure, tone mapping). A realized scene round-trips through writeFsceneb byte-stably.
  • Added optional texture compression for imported scenes, opt in via compressTextures on the importers and build hooks. Images are stored as mipped, supercompressed KTX2 block payloads and transcoded at load to a format the device supports; transcoding runs off the main isolate. Opaque textures take BC1, ETC2 RGB8, or ASTC; textures with alpha take BC3, ETC2 RGBA8, or ASTC with per-block RGBA endpoints, with an rgba8 fallback everywhere.
  • Breaking: fixed vertically inverted image-based lighting. The environment prefilter and the diffuse spherical-harmonics projection read source equirectangular images with the up hemisphere at the bottom, so every image-based environment lit scenes from below and reflected upside down. Both now use the standard convention (up pole at the top of the image), and the procedural studio environment was flipped to match, so scenes lit by loaded panoramas or HDRs will render differently (correctly so).
  • Added a skybox: assign Scene.skybox to draw a background behind all geometry, with no user geometry or draw ordering. The built-in EnvironmentSkySource shows the scene environment with a blurriness control that reuses the prefiltered roughness bands, so the backdrop always matches reflections.
  • Added custom sky shaders. ShaderSkySource draws a full-screen sky fragment (the engine supplies the world view direction as v_ray), and a .fmat with a sky { vec3 Sky(vec3 direction) } block compiles to one through the existing material pipeline: load it with loadFmatSky for typed parameters and in-place hot reload, and declare requires: [environment] to sample the scene's prefiltered radiance.
  • Added sky-driven lighting. EnvironmentMap.fromSky bakes any shader sky into the image-based lighting (specular and diffuse, projected on the GPU), and Scene.skyEnvironment keeps the bake fresh on a refresh policy (manual with invalidate(), an interval, or every frame). After a binding's first synchronous bake, re-bakes are time-sliced one GPU pass per frame into double-buffered targets, so refreshes never spike a frame.
  • Added built-in procedural skies: GradientSkySource (zenith/horizon/ground colors with an HDR sun disk) and PhysicalSkySource (an analytic single-scattering daylight atmosphere driven by a sun direction).
  • The diffuse spherical-harmonics coefficients are now sampled from a small texture instead of packed into a uniform, and EnvironmentMap.fromGpuTextures accepts a diffuseShTexture computed on the GPU.
  • A .fmat that fails to compile during hot reload no longer fails the whole build: the last good shaders stay active and the compile error is reported in the console, both from the build hook and in the running app.
  • Build-hook conversions (scenes and materials) are now cached by input content, so a hook rerun for an unrelated edit skips unchanged sources. Editing one .fmat no longer re-imports every scene on hot reload. Set FLUTTER_SCENE_DISABLE_BUILD_CACHE to always reconvert.
  • Fixed progressive slowdown on the web backend during long sessions: render passes leaked a GL framebuffer (and ran a synchronous completeness check) every pass of every frame, and some passes re-linked GL programs every frame. Framebuffers and linked programs are now cached, and per-draw uniform uploads no longer allocate.