Live data from Hacker News

Porting WebGL Shaders to WebGPU

construct.net

21–30 of 64 posts

Re: Porting WebGL Shaders to WebGPU

#21

Our team is working to build out support for Unreal Engine 4 and Unreal Engine 5 to support WebGPU, so game developers and real-time 3D developers can export their creations to the web at near native performance and access features like computer shaders. Long term goal is to disrupt Steam and the App Stores. We're also working on WebXR support to enable UE VR apps on the web. If anyone is interested and wants to lear…

As a gamer though, why would I want to play any of these developers' games through the browser instead of Steam?

To try it out? Also to play or check in on a friend's computer or a public computer.

The ease of visiting a game like a website is sometimes preferred, depends on the game.

There's a game where the web client is mainly used to view streams of other players (instead of streaming video they mirrored the same packets they received/sent to your web client)

Re: Porting WebGL Shaders to WebGPU

#22

Our team is working to build out support for Unreal Engine 4 and Unreal Engine 5 to support WebGPU, so game developers and real-time 3D developers can export their creations to the web at near native performance and access features like computer shaders. Long term goal is to disrupt Steam and the App Stores. We're also working on WebXR support to enable UE VR apps on the web. If anyone is interested and wants to lear…

As a gamer though, why would I want to play any of these developers' games through the browser instead of Steam?

It's a bigger deal for developers, as they don't have to give up 30% to Steam, and they can directly distribute to their end users on their own site by embedding.

Not to mention instant cross-platform availability across PC/Mac/Android and iOS. Even Xbox supports WebGL2 via the new Chromium Edge they shipped on there recently.

Re: Porting WebGL Shaders to WebGPU

#23

Our team is working to build out support for Unreal Engine 4 and Unreal Engine 5 to support WebGPU, so game developers and real-time 3D developers can export their creations to the web at near native performance and access features like computer shaders. Long term goal is to disrupt Steam and the App Stores. We're also working on WebXR support to enable UE VR apps on the web. If anyone is interested and wants to lear…

As a gamer though, why would I want to play any of these developers' games through the browser instead of Steam?

No downloads and the ability to easily and quickly jump into the action, especially useful for multiplayer or social games.

Re: Porting WebGL Shaders to WebGPU

#24
post #18

My main worry with WebGPU is the dependence with Javascript. If I understand it correctly, you can't use web APIs nor stuff like WebGPU directly through web assembly anyway, so there's always a javascript glue layer involved. Now, I know some languages like Rust have decent bindings that hide all that, but I wonder about the performance cost of that glue. Has someone measured it, or estimated how better we could go w…

WebGPU is a less chatty API than WebGL. You can kick off a huge amount of GPU computation with just a couple of function calls. The overhead of the function calls themselves is usually not a big issue. That said, I know there has been work in Chrome to make these calls more efficient for WebGL and I think the overhead is actually small.

Re: Porting WebGL Shaders to WebGPU

#25
post #5
post #4

The confusion with `let` and `var` does seem confusing from a JS perspective, but it seems to be so that you can have the same mental model between WGSL and SPIR-V: https://github.com/gpuweb/gpuweb/issues/2207

It seems to be a syntax mismash between Rust, which uses `let` and `let mut`, and JavaScript, which uses `const` and `var`, giving WGSL's `let` and `var`, probably chosen because they are the shortest.

Javascript also has `let`. It's basically like var, but doesn't get hoisted. And can't be unassigned once assigned.

Re: Porting WebGL Shaders to WebGPU

#26
As a non-web-developer, I'm kinda excited about WebGPU. Specifically WebGPU native, that has potential to be a portable modern 3D graphics API without the difficulty of using Vulkan or DX12.

Re: Porting WebGL Shaders to WebGPU

#27
post #9

Is there any advantage at this point in time to port a game to WebGPU? Is it going to run faster, or have broader browser support in the future?

At this time I would recommend WebGL 2. WebGL 2 is finally supported in all major browsers now that Safari 15 shipped. WebGL 2 has some of the benefits mentioned in the article for WebGPU, such as a reasonable minimum texture size (2048 vs 64 in WebGL 1) and the built-in ability to get the size of a texture in a shader. WebGPU will not ship in all browsers for some time, and when it does it will not have have wider h…

It is currently shipping behind a flag in desktop versions of Chrome (and all its derivatives), Safari, and Firefox. It is also shipping behind a flag in Firefox for Android. I don't think it's too far out from finally shipping.

The biggest boon would be for mobile devs to help avoid the 30% store tax, but this is also the reason why mobile Chrome and mobile Safari (especially Safari) tend to lag behind in major ways.

Re: Porting WebGL Shaders to WebGPU

#28
post #27
post #9

Earlier quoted context omitted.

At this time I would recommend WebGL 2. WebGL 2 is finally supported in all major browsers now that Safari 15 shipped. WebGL 2 has some of the benefits mentioned in the article for WebGPU, such as a reasonable minimum texture size (2048 vs 64 in WebGL 1) and the built-in ability to get the size of a texture in a shader. WebGPU will not ship in all browsers for some time, and when it does it will not have have wider h…

It is currently shipping behind a flag in desktop versions of Chrome (and all its derivatives), Safari, and Firefox. It is also shipping behind a flag in Firefox for Android. I don't think it's too far out from finally shipping. The biggest boon would be for mobile devs to help avoid the 30% store tax, but this is also the reason why mobile Chrome and mobile Safari (especially Safari) tend to lag behind in major ways…

What Safari is shipping behind a flag is not anything like the current version of WebGPU. I don't think it supports WGSL, for example. It's going to be a long time before all three browsers have shipped implementations that are interoperable and not behind flags.

I don't think WebGPU is the biggest thing that's going to let mobile game devs start shipping on the web. WebGL 2 can do graphics well enough today. Other things hold the web back.

Monetization is the big thing that people always talk about. The lucrative interstitial app install ads that mobile games have aren't on web, and in-app purchases have a lot more friction. Handling large binary assets is also a place where the web is lacking and WebGPU won't fix that. Finally, there's a lot of ecosystem and tools stuff that needs to happen too. The engines need to add web platform support which goes more than skin deep. Shipping a game as one giant binary is not good enough for web, you need to split your code into dynamically loadable modules and stream your assets. You need Basis Universal compressed textures. Etc.

Fix all of the above and then web games can shine, with or without WebGPU. Realistically, fix monetization and the rest will follow. Big caveat though: I think many see the monetization techniques currently used by mobile games as exploitative. It's not clear that you could do web game monetization competitively without the same level of exploitation.

Re: Porting WebGL Shaders to WebGPU

#30
post #26

As a non-web-developer, I'm kinda excited about WebGPU. Specifically WebGPU native, that has potential to be a portable modern 3D graphics API without the difficulty of using Vulkan or DX12.

Agree, it gives you pretty low-level access if you need it, but you can still draw a triangle in under 100 lines, e.g. https://github.com/morzel85/webgpu-wgsl-hello-triangle
Post reply on HN