just_graphics_engine 0.1.0-dev.2
just_graphics_engine: ^0.1.0-dev.2 copied to clipboard
3D renderer for Flutter on Flutter GPU: glTF 2.0 models, PBR materials, lights, shadows, skinned animation, image-based light and a scene widget.
0.1.0-dev.2 #
- Instance batches:
InstanceBatchinRenderScene.batches, each in a persistent instance buffer, culled whole and beyond its reach, casting shadows;Stats.batches. - Overlays and wireframes:
OverlayDrawinRenderScene.overlays, drawn last with line topology;GpuPrimitive.edges(ModelUploader(keepEdges:)). - View modes (
RenderViewMode: lit, unlit, wireframe), a clip plane, and the editor's unlit view in the lit shader. - Layered materials (
MaterialData.layered: four colour layers weighed by vertex colour) and texture coordinates in metres or from the world (MaterialData.uvMode);ModelUploader.material(maps:)takes every map. - Frames drawn before the GPU runs them keep their own data.
GpuDevice.frameDatacame from Flutter GPU'sHostBuffer, which hands a frame's memory out again four frames later whether or not the GPU has read it: an app drawing five or more views a frame (an editor's split view and its game preview) drew views with another's camera, sky and lights, flickering. Each frame now writes into memory of its own, reused once the GPU has finished with it, and so does each frame's joint texture.
0.1.0-dev.1 #
First release, a dev release: a 3D renderer for Flutter on Flutter GPU, standing alone (no game engine) and drawing the 3D of just_game_engine. Requires Flutter 3.47.1 or newer.
gpu.dart:GpuDeviceover Flutter GPU (createGpuDevice, null with a reason where it can't run: the web, Impeller off, Android's OpenGL ES fallback), aNullGpuDevicethat records commands,PipelineSet,RenderTargetPool,SortKey,UniformWriterandClipFixup. The backend skips calls that repeat what a pass already holds, since draw calls cost tens of microseconds on Android.assets.dart: glTF 2.0 loading (loadModelData):.glband.gltf, node hierarchies, every material map, sparse accessors,KHR_texture_transform,KHR_materials_unlit,KHR_materials_emissive_strength,KHR_mesh_quantizationandKHR_lights_punctual. Files that require Draco, meshopt or KTX2 are refused by name. Images decode once and get sRGB-correct CPU mips.- Meshes made in code:
MeshBuilder(triangles, quads, faces, boxes, lathes, discs) builds aShapeMesh;ShapeMesh.toPrimitiveandModelUploader.uploadPrimitiveput it on the GPU,ModelUploader.materialgives it a material made in code. renderer.dart:Renderer3Dwith frustum culling, sorted and instanced draws, metallic-roughness PBR lit by a sun, 8 point/spot lights and a hemisphere ambient, a gradient sky, and HDR with 4x MSAA and ACES tonemapping.Renderer3D.tryCreatemakes one on this platform's GPU, or gives null and says why.RenderStatscounts draws, shadow draws, casters, skinned instances and joints.Scene3DView: a widget that draws aRenderScenefrom aRenderViewevery frame (or when rebuilt), sizes the image from its layout, sets a perspective projection for its aspect ratio, and shows the reason when there is no GPU or drawing fails.- Sun shadows: two cascades of
r32fshadow maps fitted to the view with texel snapping, 3×3 PCF and normal-offset bias (Renderer3D.shadows,ShadowSettings.cascades,cascadeSplit,fitSunShadow). - Image-based light:
EnvironmentMapData(a gradient sky or an equirectangular Radiance.hdr,decodeRadianceHdr; GGX-prefiltered cube levels and SH9 diffuse light, built on another isolate) andGpuEnvironmentMap. Lit surfaces take ambient light and reflections fromEnvironment.map;Environment.skyboxdraws it as the sky. - Fog, over the sky's horizon too; bloom (
Renderer3D.bloom,BloomSettings) through a chain of half-size targets; FXAA (Renderer3D.fxaa) for when MSAA is too dear;DynamicResolution, which lowers a render scale while frames run long. - Skinned animation: skins and animations from glTF;
AnimationClip(step, linear and cubic-spline keys),Pose(and blending),Skeleton,PosedModel; joint palettes in one float texture (instanced skinned draws) or, as a fallback, uniform blocks. - Model import:
ModelImportSettings(saved beside a model as<model>.import.json: scale, largest texture, mipmaps, material changes) andcookModel, which writes a cooked copy (<model>.jmodel,CookedModel) with every texture decoded, shrunk and mipped: no glTF parsing, no image decoding where it is loaded. ETC2/ASTC compression is accepted in the settings but not made yet (cooked uncompressed, with a warning). - For editors and tools:
GpuModel.withMaterialValues(previews change materials without uploading),ImageData.levels,ModelUploader.uploadImage. testing.dart: GPU test helpers (gpuUnavailableReason,submitAndWait,readPixels,compareImages),GlbWriterfor generated fixtures, andskinnedBarGlb,jointChainGlbandmannequinGlb(a walking character made in code).- Shaders compile into one bundle with the app's Flutter SDK (
hook/build.dart, GLSL ES 3.00 on OpenGL ES). Web builds, JavaScript or WebAssembly, compile and leave the bundle out. example/: models, walking characters, lights and a sky drawn by aScene3DViewfrom an orbiting camera, with no game engine, and the Flutter GPU switch in every runner.- GPU tests (tag
gpu) run headless on Windows withflutter test --enable-impeller --enable-flutter-gpu --tags gpu.