fenomas / noa

Experimental voxel game engine.
MIT License
608 stars 86 forks source link

webgpu? #193

Open bryanhpchiang opened 1 year ago

bryanhpchiang commented 1 year ago

do you think switching the engine to webgpu would help with performance?

babylon is supposed to support webgpu out of the box

fenomas commented 1 year ago

Hi, thanks for the reminder! It looks like the feature is still experimental, but this engine should be able to support it without any effects on the game client. I'll try it out soon and see if there's any performance difference yet.

fenomas commented 1 year ago

@JaegerBomBYT I've looked into this enough to find that it's not an easy change. Babylon doesn't have any built-in support for texture arrays (i.e. texture atlases), but they're a big win for voxels so this engine uses a custom shader for them. That shader doesn't work as-is in webGPU, though I don't know how hard it will be to convert or rewrite.

Also using webGPU means that Babylon's core init becomes async, which winds up meaning a lot of grunt work - basically noa's constructor and/or init methods will need to change signature, and some changes to internals to make sure that various initialization doesn't happen until after babylon's engine init finishes.

The latter changes can be hacked around for testing, but the shader rewrite is thornier - because without that bit, there's no easy way to test whether webGPU improves performance or not.