September 5th, 2024

UE5 Nanite in WebGPU

The Nanite WebGPU project replicates Unreal Engine 5's technology for web rendering using WebGPU in Chrome, featuring meshlet LOD, software rasterization, and interactive demo scenes for real-time adjustments.

Read original articleLink Icon
CuriosityExcitementConfusion
UE5 Nanite in WebGPU

The Nanite WebGPU project on GitHub aims to replicate the Nanite technology from Unreal Engine 5, enabling the rendering of high-detail 3D models in web browsers using WebGPU, which is currently supported only in Chrome. The project features a meshlet level of detail (LOD) hierarchy, a software rasterizer, and various culling techniques to enhance rendering performance. It supports a custom file format for meshes while also accommodating OBJ files. Users can interact with demo scenes that showcase the technology's capabilities, allowing for real-time adjustments to rendering parameters. The repository includes links to demo scenes, such as the Jinx Scene and Many Objects Scene, which can be explored directly in the browser. This project represents a significant advancement in web-based 3D rendering, demonstrating the potential of modern web technologies for high-fidelity graphics.

- The project replicates Unreal Engine 5's Nanite technology for web rendering.

- It utilizes WebGPU, currently supported only in Chrome.

- Features include a meshlet LOD system, software rasterization, and culling techniques.

- Users can interact with demo scenes and adjust rendering parameters in real-time.

- The project serves as a practical implementation of advanced rendering techniques for the web.

Related

20x Faster Background Removal in the Browser Using ONNX Runtime with WebGPU

20x Faster Background Removal in the Browser Using ONNX Runtime with WebGPU

Using ONNX Runtime with WebGPU and WebAssembly in browsers achieves 20x speedup for background removal, reducing server load, enhancing scalability, and improving data security. ONNX models run efficiently with WebGPU support, offering near real-time performance. Leveraging modern technology, IMG.LY aims to enhance design tools' accessibility and efficiency.

GPU profiling for WebGPU workloads on Windows with Chrome

GPU profiling for WebGPU workloads on Windows with Chrome

Challenges of GPU profiling for WebGPU in Chrome on Windows are addressed. A workaround using a custom DLL enables GPU profiling with tools like AMD's Radeon GPU Profiler and Nvidia's Nsight, enhancing performance metrics for WebGPU applications.

Show HN: Free e-book about WebGPU Programming

Show HN: Free e-book about WebGPU Programming

"WebGPU Unleashed" is a tutorial for beginners in graphics programming using the WebGPU API, covering foundational concepts, basic tasks, and advanced techniques like Gaussian splatting in an interactive format.

Diffusion Models Are Real-Time Game Engines

Diffusion Models Are Real-Time Game Engines

GameNGen, developed by Google and Tel Aviv University, simulates DOOM in real-time at over 20 frames per second using a two-phase training process, highlighting the potential of neural models in gaming.

Notan: Cross-Platform Multimedia Layer

Notan: Cross-Platform Multimedia Layer

Notan is a cross-platform multimedia framework that simplifies application development with user-friendly APIs, modular design, and promising rendering capabilities, supporting WebAssembly and various operating systems. Contributions are encouraged.

AI: What people are saying
The comments on the Nanite WebGPU project reveal a mix of technical insights and user experiences.
  • Several users discuss the technical aspects of Nanite, including its mesh representation and the need for GPU hardware improvements to fully utilize its capabilities.
  • There is confusion regarding the project's name, with some clarifying that it is not the same as Unreal Engine 5's Nanite but rather an independent implementation of similar concepts.
  • Users express concerns about compatibility issues with different browsers and devices, particularly regarding WebGPU support.
  • Some commenters highlight the performance of the demos, noting impressive frame rates despite the complexity of the scenes.
  • There is interest in how other game engines handle level of detail (LOD) systems compared to Nanite's approach.
Link Icon 30 comments
By @Animats - 8 months
Oh, nice. Third party implementations of Nanite playback.

Nanite is a very clever representation of graphics meshes. They're directed acyclic graphs rather than trees. Repetition is a link, not a copy. It's recursive; meshes can share submeshes, which in turn can share submeshes, all the way down. It's also set up for within-mesh level of detail support, so the submeshes drop out when they're small enough. So you can have repetitive content of very large size with a finite amount of data and fast rendering times. The insight is that there are only so many pixels on screen, so there's an upper bound on rendering work really needed.

There's a really good SIGGRAPH video on this from someone at Epic.

Current GPU designs are a mismatch for Nanite, Some new hardware operations are needed to do more of this in the GPU, where it belongs. Whether that will happen, with NVidia distracted by the AI market, is a good question.

The scene needs a lot of instancing for this to pay off. Unreal Engine demos show such things as a hall of identical statues. If each statue was different, Nanite would help far less. So it works best for projects where a limited number of objects are reused to create large areas of content. That's the case for most AAA titles. Watch a video of Cyberpunk 2077, and look for railings and trash heaps. You'll see the same ones over and over in totally different contexts.

Making a nanite mesh is complicated, with a lot of internal offsets for linking, and so far only Unreal Engine's editor does it. With playback now open source, someone will probably do that.

Those internal offsets in the format present an attack surface which probably can be exploited with carefully crafted bad content, like hostile Microsoft Word .doc files.

By @jms55 - 8 months
It's been mentioned a couple of times in this thread, but Bevy also has an implementation of Nanite's ideas (sometimes called Virtual Geometry). I'm the author of that, happy to answer questions :)

As for this project, Scthe did a great job! I've been talking with them about several parts of the process, culminating in some improvements to Bevy's code based on their experience (https://github.com/bevyengine/bevy/pull/15023). Always happy to see more people working on this, Nanite has a ton of cool ideas.

By @soulofmischief - 8 months
Is the demo using user agent strings to determine compatibility? That's not good, and feature compatibility should be determined on a case-by-case basis by simply attempting to detect/use the specific feature.

I am on Chromium, not Chrome, and use WebGPU all the time, but the demos tell me to use Chrome, which I cannot do ethically. Would love to try the demos out, this looks like a lot of hard work!

By @cubefox - 8 months
Here is the somewhat neglected original 2009 dissertation by Federico Ponchio, the guy who invented the dynamic mesh simplification algorithm on which Nanite is based, with lots of illustrations:

https://vcg.isti.cnr.it/~ponchio/download/ponchio_phd.pdf (107 pages!)

By @jsheard - 8 months
It's cool that it kind of works, but they had to make some nasty compromises to get around WebGPUs lack of 64 bit atomics. Hopefully that will be added as an optional extension at some point, hardware support is almost ubiquitous on desktop-class hardware at least (AMD and Nvidia have had it forever but Apple has only had it since the M3).
By @TaylorAlexander - 8 months
It says my iPhone 12 Pro Max doesn’t have WebGPU, but I enabled it in experimental features and another website[1] with WebGPU demos now works. Has anyone gotten this working on iPhone? Would be nice if the web app gave more info on what failed.

[1] https://webgpu.github.io/webgpu-samples/?sample=texturedCube

By @devit - 8 months
Name and description are very confusing and a trademark violation since despite the claims it seems to be completely unrelated to actual Nanite in UE5, just an implementation of something similar by a person unaffiliated with UE5.

There is also Bevy's Virtual Geometry that provides similar functionality and is probably much more useful since it's written in Rust and integrated with a game engine: https://jms55.github.io/posts/2024-06-09-virtual-geometry-be...

By @forrestthewoods - 8 months
Note: this isn't actually UE5 Nanite in WebGPU. It's a totally independent implementation of the same idea as Nanite.

This technique is starting to appear in a variety of places. Nanite definitely made the idea famous, but Nanite is the name a specific implementation, not the name of the technique.

By @KronisLV - 8 months
I wonder how other engines compare when it comes to LODs and similar systems.

Godot has automatic LOD which seems pretty cool for what it is: https://docs.godotengine.org/en/stable/tutorials/3d/mesh_lod...

Unity also has an LOD system, though despite how popular the engine is, you have to create LOD models manually: https://docs.unity3d.com/Manual/LevelOfDetail.html (unless you dig through the asset store and find a plugin)

I did see an interesting approach in a lesser known engine called NeoAxis: https://www.neoaxis.com/docs/html/NeoAxis_Levels.htm however that engine ran very poorly for me on my old RX580, although I haven't tried on my current A580.

As far as I can tell, Unreal is really quite far ahead of the competition when it comes to putting lots of things on the screen, except the downside of this is that artists will be tempted to include higher quality assets in their games, bloating the install sizes quite far.

By @eigenvalue - 8 months
Whenever I see rendered scenes like this (I.e., lots of repetitive static geometry) I imagine that annoying guy’s voice going on about “unlimited detail” from that old vaporware video. I guess nanite really did solve that problem for real, as opposed to whatever that old thing was using (I remember something about oct-trees or something).
By @SaintSeiya - 8 months
Honest question: It is calim that software rasterizer is faster than hardware one. Can someone explain me why? isn't the purpose of the GPU to accelerate rasterization itself? Unless is a recent algorithm or the "software rasterizer" is actually running on the GPU and not the CPU I don't see how
By @theogravity - 8 months
Using latest chrome on M2 Max for the jinx demo:

  WebGPU error [frame][validation]: Fill size (7398781) is not a multiple of 4 
  bytes.
  - While encoding [CommandEncoder "main-frame-cmd-buffer"].ClearBuffer([Buffer 
  "rasterize-sw"], 0, 7398781).
By @pjmlp - 8 months
On Windows it can't handle device loss.

  ID3D12Device::GetDeviceRemovedReason failed with   DXGI_ERROR_DEVICE_HUNG (0x887A0006)
   - While handling unexpected error type Internal when allowed errors are (Validation|DeviceLost).
      at CheckHRESULTImpl (..\..\third_party\dawn\src\dawn\native\d3d\D3DError.cpp:119)
      at CheckAndUpdateCompletedSerials (..\..\third_party\dawn\src\dawn\native\d3d12\QueueD3D12.cpp:179)
      at CheckPassedSerials (..\..\third_party\dawn\src\dawn\native\ExecutionQueue.cpp:48)
      at Tick (..\..\third_party\dawn\src\dawn\native\Device.cpp:1730)

  Backend messages:
   \* Device removed reason: DXGI_ERROR_DEVICE_HUNG (0x887A0006)
By @mbforbes - 8 months
Funny coincidence, was just reading through an amazing thread on the three.js form a couple days ago about a web graphics implementation of virtual geometry (nanite). webgl, 2021: https://discourse.threejs.org/t/virtually-geometric/28420

it's closed source, but I found the discussion and description of the tradeoffs interesting

By @moralestapia - 8 months
Outstanding work. Also, thanks for proving actual demos of the tech. I get 60-120fps on my MBP which is phenomenal given the amount of triangles in the scene.
By @astlouis44 - 8 months
Here's an actual implementation of UE5 in WebGPU, for anyone interested.

Just a disclaimer that it will only work on WebGPU-enabled browser on Windows (Chrome, Edge, etc) unfortunately Mac has issues for now. Also, there is no Nanite in this demo, but it will be possible in the future.

https://play.spacelancers.com/

By @smartmic - 8 months
Wow, I can't remember the last time I read a project summary with so much jargon - I literally didn't understand anything:

> UE5's Nanite implementation using WebGPU. Includes the meshlet LOD hierarchy, software rasterizer and billboard impostors. Culling on both per-instance and per-meshlet basis.

By @moffkalast - 8 months
> No WebGPU available. Please use Chrome.

Getting that on Chromium, lol.

By @macawfish - 8 months
The camera controls on my phone are very hard to get down
By @tech-no-logical - 8 months
getting the message

    No WebGPU available. Please use Chrome.
on chrome (Version 129.0.6668.29 (Official Build) beta (64-bit)) , under windows
By @replete - 8 months
Intel Mac, Chrome and ungoogled chromium: index.web.ts:159 Uncaught (in promise) OperationError: Instance dropped in popErrorScope
By @nox101 - 8 months
This is amazing! I will be so great when Safari and Firefox but finish their WebGPU implementations so it runs everywhere.
By @vladde - 8 months
Got to love in the stated goals:

> I could have built this with Vulkan and Rust. None would touch it.

By @hising - 8 months
I would love to see this but it wont work on Linux + Chrome even if WebGPU is enabled.
By @readyplayernull - 8 months
Will virtual geometry be integrated into GPUs some day?
By @desdenova - 8 months
The examples don't work, though.
By @meindnoch - 8 months
Can someone explain what Nanite is? The other day someone was saying it uses software rendering because the triangles are so small. Wtf?
By @jesse__ - 8 months
> If you want to add this tech to the existing engine, I'm not a person you should be asking (I don't work in the industry).

Fucking .. bravo man.