Sufficit.Graphics.Babylon
1.0.26
The Babylon.js backend was removed on 2026-11-29. Use Sufficit.Graphics.WebGpu: <WebGpuView> renders the same Sufficit.Graphics scene and explains when the browser has no WebGPU.
See the version list below for details.
dotnet add package Sufficit.Graphics.Babylon --version 1.0.26
NuGet\Install-Package Sufficit.Graphics.Babylon -Version 1.0.26
<PackageReference Include="Sufficit.Graphics.Babylon" Version="1.0.26" />
<PackageVersion Include="Sufficit.Graphics.Babylon" Version="1.0.26" />
<PackageReference Include="Sufficit.Graphics.Babylon" />
paket add Sufficit.Graphics.Babylon --version 1.0.26
#r "nuget: Sufficit.Graphics.Babylon, 1.0.26"
#:package Sufficit.Graphics.Babylon@1.0.26
#addin nuget:?package=Sufficit.Graphics.Babylon&version=1.0.26
#tool nuget:?package=Sufficit.Graphics.Babylon&version=1.0.26
Sufficit.Graphics
A C# 3D graphics library inspired by Babylon.js. You build, load and animate scenes in .NET. The scene model does not depend on the GPU backend, so the backend can be swapped.
- Scene model in pure C#. Nodes, meshes, PBR materials (metallic-roughness), textures, cameras, punctual lights, skins, morph targets, keyframe animation with cross-fade, and procedural meshes. No GPU dependency; trimmable and AOT-compatible.
- Formats. glTF 2.0 and GLB, both read and write. OBJ and MTL, read only.
- Character physics. de Leva segment masses, centre of mass, damped pendulums for limbs,
and an inverted-pendulum balance controller. Balance profiles (
normal,drunk,focused,fatigued, or blends) can be switched by game events. - Native WebGPU renderer for Blazor. C# owns the WGSL shaders (metallic-roughness PBR),
the camera, skinning matrices, transparency sorting and the per-frame draw list. A thin
JavaScript layer only forwards resources and one binary packet per frame to
navigator.gpu. - Babylon.js backend for Blazor. A compatibility backend: the C# scene stays authoritative, Babylon.js draws it and skins on the GPU, with bones linked to the nodes you animate in C#.
Live viewer · Plan · Similar projects and opportunities · Renderer comparison
Packages
| Package | Contents |
|---|---|
Sufficit.Graphics |
Scene graph, assets, animation, MeshBuilder |
Sufficit.Graphics.Formats.Gltf |
GltfReader (glTF and GLB) and GltfWriter (GLB) |
Sufficit.Graphics.Formats.Obj |
ObjReader (OBJ and MTL) |
Sufficit.Graphics.Physics |
BalanceController, DampedPendulum, SegmentMassTable, SupportPolygon |
Sufficit.Graphics.WebGpu |
<WebGpuView> component and WebGpuRenderer (own renderer, WebGPU) |
Sufficit.Graphics.Babylon |
<BabylonView> component and BabylonRenderer (Babylon.js backend) |
Sufficit.Graphics.Cli |
sufficit-graphics inspect and convert (.NET tool) |
glTF coverage
The reader supports:
- Embedded, external and GLB buffers.
- Sparse accessors and normalised or quantised attributes (
KHR_mesh_quantization). - All primitive modes.
- Skins, morph targets, and animations with
LINEAR,STEPandCUBICSPLINEinterpolation, including weights. - Cameras.
- Extensions:
KHR_lights_punctual,KHR_texture_transform,KHR_materials_unlit,KHR_materials_emissive_strength,EXT_texture_webp, andKHR_texture_basisu(passed through to the backend).
Files that require an extension the reader does not support, such as Draco or meshopt, fail with a clear message.
Validated against 24 Khronos glTF sample assets and 150 production assets. The production assets are Quaternius characters with 65 joints and 43 clips, Stylized Nature MegaKit glTF and OBJ files, and Ultima's GLBs. Every asset also passes a GLB round trip.
Usage
using Sufficit.Graphics;
using Sufficit.Graphics.Animation;
using Sufficit.Graphics.Formats.Gltf;
var scene = GltfReader.Load("character.glb");
var player = new AnimationPlayer();
player.Play(scene.FindAnimation("Walk_Loop")!);
player.Update(1 / 60f); // writes the pose into the nodes
GltfWriter.Save(scene, "copy.glb");
Blazor with the native WebGPU renderer (no third-party engine):
<WebGpuView Scene="scene" OnFrame="dt => { player.Update((float)dt); return ValueTask.CompletedTask; }" />
Blazor with the Babylon.js backend (Babylon.js must be on the page, for example
<script src="https://cdn.babylonjs.com/v9.38.0/babylon.js"></script>):
<BabylonView Scene="scene" OnFrame="dt => { player.Update((float)dt); return ValueTask.CompletedTask; }" />
Balance with event-driven profiles:
using Sufficit.Graphics.Physics;
var balance = new BalanceController(gravity: Gravity.Default) { Profile = BalanceProfile.Normal };
balance.Profile = BalanceProfile.Lerp(BalanceProfile.Normal, BalanceProfile.Drunk, intoxication);
balance.Impulse(new(110, 0), bodyMass: 75, centerHeight: .98); // N·s
var state = balance.Advance(new BalanceInput(com, leftFoot, rightFoot, soleHalfExtents, speed, dt));
Command line:
dotnet run --project tools/Sufficit.Graphics.Cli -- inspect path/to/assets
dotnet run --project tools/Sufficit.Graphics.Cli -- convert model.obj model.glb
Renderers
The viewer uses the native WebGPU renderer
and falls back to Babylon.js when the browser has no WebGPU adapter; ?renderer=babylon
forces the compatibility backend. On the Khronos samples the two renderers differ
by 1 to 3 levels out of 255 on average per channel without tone mapping. Against the Khronos
glTF Render Fidelity path-traced goldens, ?preset=fidelity scores -12.5 dB on MetalRoughSpheres,
on par with three.js/model-viewer (-12.5) and ahead of Babylon.js (-11.9); see the
renderer comparison.
Viewer query options: demo=forest&count=N (instancing and culling stress test), demo=lake (water, calm=1 for
a mirror), demo=night (fog, spot and point lights), wind=, winddir=, rain=, fog=, envint=, elev=, azim=, renderer=babylon, preset=fidelity, env=<url.hdr> or env=none,
skybox=1, tonemap=none|agx|aces, exposure=, envrot= (degrees), bg=r,g,b (background, 0..1),
embed=1 (canvas only), still=1 (rest pose), and radius= with fov= for a fixed (0, 0, radius) camera.
WebGpu (own) |
Babylon |
|
|---|---|---|
| Shaders and lighting | WGSL in C#, glTF reference BRDF | Babylon.js PBRMaterial |
| Skinning | Joint matrices computed in C#, applied on the GPU | Babylon bones linked to C# nodes |
| Browsers | WebGPU (Chrome, Edge, Safari 26, Firefox 141+) | WebGL2 and WebGPU |
| Image-based lighting | Split-sum IBL with GGX prefilter on the GPU, SH9 diffuse, multiple-scattering compensation; .hdr environments or the built-in neutral studio; optional skybox |
Babylon environment (not wired by default) |
| Output | Linear HDR target (MSAA), specular anti-aliasing, alpha-to-coverage, SSAO, bloom, output pass with PBR Neutral, AgX or ACES and the exact sRGB curve | Babylon image processing |
| Lights | Up to 8 glTF punctual lights (candela/lux per spec), shadow map from the first directional light | Babylon lights (point/spot intensity treated as luminous power) |
| Morph targets | Yes (GPU, weights per frame from C#) | Not yet |
| Nature | Wind (GPU vegetation sway shared with physics drag), rain streaks, wet surfaces, water with Gerstner waves, planar mirror, refraction and foam | No |
| Light effects | Cascaded sun shadows (up to 4, texel-snapped), spot-light shadows, alpha-tested shadow casters, volumetric fog with light cones and point-light halos | Babylon volumetric light (separate) |
| Throughput | Frustum culling in C# (camera, light and mirror), automatic instancing, delta packets (only changed objects are sent), WASM AOT viewer, per-frame C#/JS timings | Babylon scene graph |
| Materials | Metallic-roughness plus KHR_materials_ior, specular, clearcoat, sheen, transmission, volume (factors), unlit, emissive_strength |
Babylon PBR |
| Missing | Textures of the KHR material extensions, KTX2, point-light shadows, second UV set, render bundles, GPU culling | Morph targets |
Conventions
- Right-handed, +Y up, metres, glTF units (lux and candela for lights).
System.Numericsrow-vector matrices. glTF column-major arrays map element by element.- Default gravity is 9.8 m/s².
- Each class or record lives in its own file, and no file exceeds 400 lines. The test suite enforces both rules.
Development
dotnet test Sufficit.Graphics.slnx
dotnet run --project samples/Sufficit.Graphics.Viewer
FBX and USD are converted to glTF offline. See the plan.
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.0)
- Sufficit.Graphics (>= 1.0.26)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.0.35 | 118 | 11/29/2026 | |
| 1.0.34 | 103 | 11/29/2026 | |
| 1.0.33 | 110 | 11/29/2026 | |
| 1.0.32 | 105 | 11/29/2026 | |
| 1.0.31 | 101 | 11/29/2026 | |
| 1.0.30 | 110 | 11/29/2026 | |
| 1.0.29 | 110 | 11/29/2026 | |
| 1.0.28 | 99 | 11/29/2026 | |
| 1.0.27 | 104 | 11/29/2026 | |
| 1.0.26 | 103 | 11/29/2026 | |
| 1.0.25 | 115 | 11/29/2026 | |
| 1.0.24 | 105 | 11/29/2026 | |
| 1.0.23 | 106 | 11/29/2026 | |
| 1.0.22 | 106 | 11/29/2026 | |
| 1.0.21 | 106 | 11/29/2026 | |
| 1.0.20 | 107 | 11/29/2026 | |
| 1.0.19 | 105 | 11/29/2026 | |
| 1.0.18 | 109 | 11/29/2026 | |
| 1.0.17 | 108 | 11/29/2026 | |
| 1.0.15 | 108 | 11/28/2026 |