Live data from Hacker News

Porting WebGL Shaders to WebGPU

construct.net

31–40 of 64 posts

Re: Porting WebGL Shaders to WebGPU

#31

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?

A single player title? Yeah, no thanks.

However, think of the convenience of joining your friends on a web-based Minecraft-like game. And then hyperlinking to another server with some in-game mechanic.

This is something I'm really interested in doing open source, once WebUDP is more mature.

Re: Porting WebGL Shaders to WebGPU

#32

Earlier quoted context omitted.

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.

You're maybe not saving the game to disk, but you still have to download it. At least the assets you're going to interact with. And if you want to play again, then you keep the game/assets in a browser cache somewhere and there's not much difference with downloading and installing the game, in terms of bandwidth/diskspace

Re: Porting WebGL Shaders to WebGPU

#33
post #8

I took a very different approach for porting my WebGPU shaders over: I have far too many shaders to port (sometimes pretty massive ones! [0]), so I used Naga [1] at to runtime-translate my GLSL shaders to WGSL. I had to get involved a bit upstream to fix quite a few different bugs in the implementation, but once I got it working I was really happy with the result. It's quite fast, it compiles to a pretty light-weight…

Why do you do this translation at runtime--causing every user to have to re-execute it--instead of at compile-time? Is there some kind of per-user optimization this makes possible?

Re: Porting WebGL Shaders to WebGPU

#34

Earlier quoted context omitted.

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

You're maybe not saving the game to disk, but you still have to download it. At least the assets you're going to interact with. And if you want to play again, then you keep the game/assets in a browser cache somewhere and there's not much difference with downloading and installing the game, in terms of bandwidth/diskspace

Of course, but from the user’s perspective this is all transparent. Parent comment is talking from the UX perspective.

Re: Porting WebGL Shaders to WebGPU

#35
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…

The same WebGPU API can be used as a cross platform layer to do graphics, no js needed. For example rust's wgpu can just be used without a browser.

Re: Porting WebGL Shaders to WebGPU

#36

Earlier quoted context omitted.

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.

To detriment of players experience, because neither Web 3D APIs are a match to native hardware capabilities.

Re: Porting WebGL Shaders to WebGPU

#37
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.

It can only expose a subset of their capabilities.

Don't expect using mesh shaders on WebGPU for example.

Re: Porting WebGL Shaders to WebGPU

#38
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…

Web 3D APIs are castrated, they will never be able to match native APIs.

Going for GL ES 3.0 subset, when devices do GL ES 3.2?

Going for a MVP 1.0 with minimum overlap across Metal, Vulkan and DX12 instead of using their full blown capabilities?

In both cases, having to use native GPU debugging tools anyway.

Rather give the 30%.

Re: Porting WebGL Shaders to WebGPU

#40
> GLSL supports the ternary ?: operator. WGSL does not support this, but provides the built-in function select(falseValue, trueValue, condition) which does much the same thing (although mind that parameter order!).

I'd really like to hear a justification for that parameter order. To me it seems like the 4th best option out of 6.

Post reply on HN