New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it time to start transitioning x3dom from webgl2.0 to webgpu? #1272
Comments
That would be great if somebody would want to tackle it. |
Suggest adding, not breaking. X3D 4.0 includes full support for glTF 2.0, either as an Inline file or through use of corresponding X3D 4.0 nodes provide equivalent rendering capabilities. |
Just to clarify, glTF 2.0 does not depend on WebGPU. Base glTF 2.0 is already well supported by x3dom. The main piece missing is skinning. However, glTF extensions became more important, in particular the Khronos ratified ones: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos The added materials in particular would be a priority. |
@andreasplesch @brutzman |
Very cool, you did it ! It works for me in on Linux in Firefox nightly. I could not get WebGPU in Chrome to work on Linux. A looked around a bit in the code. A serious deep dive into the gfx rendering and figured how to use WebGPU. For the x3dom.WebGPU classes did you use an existing library or framework as a template ? I found for example https://pursuit.purescript.org/packages/purescript-webgpu/0.0.0 There are probably many others. https://jmberesford.github.io/webgpu-kit/docs/ I see you adapted the dynamic shader to make it work, more or less directly translating glsl I think. To be honest, I think the shader generation is not really sustainable the way it is. It may move to #defines et al. and chunks and webgpu may the opportunity to do that. Easier said than done. Ideally, we would want a way to reuse three.js shader chunks, I think. That may mean to also use similar webgpu layout, pipelines and such which may not be feasible. webgpu is so flexible since lower level than webgl that it may make sense to think more fundamentally about how to map best x3d to webgpu. Is there something which can be moved from the CPU to the GPU ? Porting and trying things may reveal more. Great progress ! |
I studied the examples in /webgpu.github.io. Sort out their program flow. |
Yeah, quite intimidating. Thanks for sharing ! |
To facilitate portability I wrote this "RenderPassResource" class. |
Added texture and sampling functionality https://jsitor.com/s4asRDroIR6 |
Yes, I translated glsl directly. |
There's something wrong with the near plane.This may be related to NDC. |
You probably have seen how znear is automatically calculated if not explicitly provided: x3dom/src/nodes/Navigation/Viewpoint.js Line 213 in c548975
Adding <viewpoint znear='0.1'></viewpoint> to the example avoids the clipping. So perhaps something is off how znear is automatically calculated or then used. |
Maybe it is time again to consider an option for the infinite projection matrix, #1207. It would be a good default, or a default if only znear is provided and no zfar. |
I got it, these two codes need to be modified together.The same code exists in two files. x3dom/src/nodes/Navigation/Viewpoint.js Lines 297 to 298 in c548975
Lines 315 to 325 in c548975
|
This looks like a perhaps unnecessary optimization to avoid having to generate a completely new SFMatrix4f object. Depending on how often this gets called (probably not every frame), it should be possible to replace it with something like this._projMatrix = x3dom.fields.SFMatrix4f.perspective ( fovy, aspect, znear, zfar ) ;
For infinite projection, perhaps it works best to special case in this function far == null (or -2 ?) and then return the infinite projection matrix ? |
28afa5d#diff-8ebd892c2d2e2ade6fcd1b6274ecced42d5bf6a7849fa713a03f611612353064L262 shows when that the recalculation of perspective in Viewpoint was optimized. |
This might be better:
|
Textured shapes does not seem to be affected by head light, is this expected? |
With the release of chrome 113, webgpu has been officially supported. Is it time to start transitioning x3dom from webgl2.0 to webgpu?
The text was updated successfully, but these errors were encountered: