Hi BabylonJS Community,
I’m currently working on a project to develop a cross-platform 3D viewer targeting both desktop (via Dawn/WebGPU) and web (via BabylonJS), and I’m exploring the feasibility of integrating BabylonJS with a shared C++ backend.
Our Approach:
- C++ Backend:
- The core of the application handles:
- Asset loading and optimization (e.g., glTF parsing, texture compression).
- Simulation logic (e.g., physics, procedural content generation).
- Rendering logic (e.g., shader management, post-processing effects).
- Compiled to WebAssembly (Wasm) for use in the web.
- BabylonJS Frontend:
- Handles high-level rendering, UI, and interactivity on the web.
- Consumes data (e.g., transformed vertices, simulation results, or optimized assets) generated by the C++ backend.
- Potentially shares shaders and materials defined in the backend.
- Key Integration Points:
- Scene Management: Sync the C++ scene graph with BabylonJS’s representation for rendering.
- Compute Tasks: Use the C++ backend for physics or other GPU-heavy tasks (e.g., particle simulations) and visualize results in BabylonJS.
- Resource Sharing: Leverage preprocessed assets (e.g., textures, meshes) from the backend in BabylonJS.
- WebGPU Context: Explore whether BabylonJS and the C++ backend can share a common WebGPU context on the web target.
Questions for the Community:
- Feasibility:
- Are there known limitations or challenges in using BabylonJS as the frontend for a WebAssembly-powered backend?
- Has anyone successfully integrated BabylonJS with WebAssembly for similar use cases?
- Best Practices:
- How can we efficiently sync a scene graph between BabylonJS and the C++ backend without introducing significant overhead?
- What’s the best way to handle resource sharing (e.g., buffers, textures) between BabylonJS and a WebAssembly module?
- WebGPU Context Sharing:
- If we use WebGPU on both the C++ backend (via Dawn) and BabylonJS, is it feasible to share a single WebGPU context, or would BabylonJS expect exclusive control?
- BabylonJS Strengths:
- Which BabylonJS features (e.g., Node Material Editor, PBR materials, built-in physics) could complement our backend effectively?
We’d love to hear your thoughts, feedback, and any potential pitfalls or recommendations for this approach. If there are relevant examples, patterns, or documentation, pointing us in the right direction would be greatly appreciated.
Looking forward to learning from the expertise in this amazing community!