lighttransport / tinyusdz

Tiny, dependency-free USDZ/USDA/USDC library written in C++14
Other
494 stars 37 forks source link

[TODO] WebGPU example #118

Open syoyo opened 8 months ago

syoyo commented 8 months ago

WebGPU is getting popular.

https://webkit.org/blog/14879/webgpu-now-available-for-testing-in-safari-technology-preview/ https://developer.mozilla.org/ja/docs/Web/API/WebGPU_API

Although currently WebGPU is not widely avaiable, it'd be nice to think about writing TinyUSDZ + WebGPU example at some point(Late 2024 ~ 2025?)

Cewein commented 8 months ago

I will look into this, WebGPU seem the rigth fit for this as there is currently no "real" online USDZ viewer. It would use the Wasm version of tinyUSDZ, so for some thing in safari migth lead to incompatibilities, rigth ?

syoyo commented 8 months ago

🙏

Yes, use WASM through Emscripten.

Something TinyUSDZ version of this effort:

https://github.com/Twinklebear/webgpu-cpp-gltf

i'm not sure how much inconsistencies will be happen for Safari. Probably we need to keep wasm(C++) part small(e.g, just for loading USD asset) and write more stuff in Javascript layer(e.g, setup shaders) to improve compatibilities across browsers.

Twinklebear commented 7 months ago

I'm not sure I fully know what you're both referring to about the Safari inconsistencies here, but my WebGPU/glTF/C++ demo does run in Safari Tech Preview (and uses tinygltf 😁 ). I think it should be fine to write the whole renderer in C++ using tinyUSDZ and compile to Wasm like the glTF demo. I have a little template repo that the glTF renderer used: https://github.com/Twinklebear/webgpu-cpp-wasm which might be helpful.

If you want to have the demo app in JavaScript/TypeScript and call into the tinyUSDZ Wasm library to load files, then render w/ WebGPU in TypeScript, that should also be doable.

What are the Safari-inconsistency issues?

syoyo commented 7 months ago

I have a little template repo that the glTF renderer used: https://github.com/Twinklebear/webgpu-cpp-wasm which might be helpful.

👍

Twinklebear commented 7 months ago

I started playing around with this a bit: https://github.com/Twinklebear/webgpu-cpp-usdz , https://www.willusher.io/webgpu-cpp-usdz/

syoyo commented 7 months ago

Awesome!

I'm working on Tydra https://github.com/syoyo/tinyusdz/tree/dev/src/tydra RenderScene API to convert USD scene graph to renderer-friendly data structure, including material/texturing/skinning and some basic animation support. Probably some working Tydra RenderScene is available from the beginning of Feb next month.

Cewein commented 7 months ago

You are fast, I am also working on my side on a native version with either webgpu-native.h or dawn. There is a nice repo : https://github.com/eliemichel/WebGPU-distribution were you can select the webGPU version you want.

syoyo commented 4 months ago

I'm working on Tydra https://github.com/syoyo/tinyusdz/tree/dev/src/tydra RenderScene API to convert USD scene graph to renderer-friendly data structure, including material/texturing/skinning and some basic animation support

It took time than expected, but now Tydra RenderScene should work for some USDZ models(dev branch). xform_nodes/material/texture/skinning/blendshapes are supported.

See API usage examples in

https://github.com/syoyo/Vulkan-glTF-USDZ-PBR/blob/f3530a40b182fbdc106022af883733253f6beb5c/base/VulkanUSDZModel.cpp#L971

https://github.com/syoyo/tinyusdz/blob/dev/examples/tydra_to_renderscene/to-renderscene-main.cc https://github.com/syoyo/tinyusdz/blob/dev/src/tydra/usd-export.cc (Write RenderScene data to USD again)