Twinklebear / webgl-volume-raycaster

A WebGL Volume Raycaster
MIT License
249 stars 30 forks source link

Add OpenVDB support #3

Closed virtualritz closed 4 years ago

virtualritz commented 4 years ago

Because ... why not?

Twinklebear commented 4 years ago

😄 It might not be as bad to do as it sounds at first, I haven't written something using OpenVDB, but you could write a C interface to the subset you need, compile OpenVDB and that interface to WebASM using Emscripten, then write a Javascript wrapper which gives some nice interface to the C API. Then you can use that library to load OpenVDB files directly in the browser and render them with WebGL2, or preferably WebGPU to get access to some more modern GPU functionality. It just depends on how hard that first step of getting the WebASM OpenVDB library working is. I also found that while 3D textures are in the WebGPU spec, they aren't fully implemented in the nightly browsers yet, but that will be done at some point. Alternatively, Emscripten can also compile full applications to WebASM + WebGL2/WebGPU, but I haven't tried that path out yet.

I did something similar yesterday for LAStools, a C++ library for reading las/laz LIDAR data sets, making LAStools.js and rendering it with WebGPU

Edit: after looking at OpenVDB's dependencies it will probably be difficult, but it depends how those are used and if they're optional. Requiring TBB for threading is an issue b/c there aren't really shared memory threads available now (maybe coming back? it was disabled for security a while ago), and Boost (interprocess communication?) will be tough as well. Basically to make the WebASM library, all dependencies will also need to be compiled to WebASM so they're available (and those library's dependencies, etc.). So the deeper that rabbit hole is, the tougher it'll be, and some of those may not be buildable at all to a web distribution, I'm not sure. If most of those are optional for some lightweight build that'd help, but I didn't look too far. Without that, you'd either need an OpenVDB loader which has fewer/no dependencies (either in JS, or native code compiled to WebASM for perf.), or a server to manage loading the data and sending it to the client in an easier format.

virtualritz commented 4 years ago

I was just joking. :) I think such a component could be interesting to people running 3D asset platforms (e.g. Sketchfab) with realtime previews because they could extend their offering to those kind of files. If you were interested in that you should write to those people and ask them how deep their pockets are. :)

Twinklebear commented 4 years ago

Haha I guessed, but it's an interesting thing to think about. Maybe if I look to do some contracting, it could be neat to mess with