WebGPU bug, error: no matching constructor for vec4

Hello!

I am experimenting with the new WebGPU renderer for Freeciv3D, available at Freeciv3D - FCIV.NET 3D browser version of the turn-based strategy game Freeciv. Source code: GitHub - fciv-net/fciv-net: Fciv.net the 3D version of the Freeciv strategy game

I am using this WebGPU renderer build: GitHub - danrossi/three-webgpu-renderer

This is the problem, after a while, when the game becomes “complex”, with many units and cities, the game will crash, with this error message:

The error indicates that an attempt is being made to form a vector with 5 components. This can’t work.
vec4(vec4, f32) → vec4(x1, x2, x3, x4, x5)
Do you perhaps have a few lines of code so that we can see how you create this vector with the node elements?

1 Like

This error is happening deep inside the Three.js WebGPU code, I am not creating any vectors in the game JavaScript code. This error occurs always when there are a huge amount of objects in the game after a while.

The normal WebGl renderer doesn’t have this error.

Source code: GitHub - fciv-net/fciv-net: Fciv.net the 3D version of the Freeciv strategy game

Thank you so far.

This is a very nice project. Can you help me find my way around your code?
If you don’t create wgsl code yourself, the node system will do it for you. But I would have to see the places in your code where you use the node elements. The vec4 node e.g. Since your project is very extensive, I would first have to search through many of the modules. It would be more helpful if you could tell me where I can find the node modules used to see how they are used.
Something in the code wants to form a five-dimensional vector in wgsl. It would be interesting to find out the cause

1 Like

The JavaScript Three.js code is here: https://github.com/fciv-net/fciv-net/blob/48fe090325fa94454d4b2a774034d8ad07676cd6/freeciv-web/src/main/webapp/javascript/webgl/

And: https://github.com/fciv-net/fciv-net/tree/main/freeciv-web/src/main/webapp/javascript/webgpu/libs

All the code I’ve seen so far is designed for webgl.
When using webgpu, I can only recommend building on a webgpu version, because the differences are significant. This is not only due to three.js with the new node system but also to webgpu with its shader language wgsl itself. There are big differences between glsl and wgsl.
Do I understand correctly that you yourself have not integrated any node elements from the node system of three.js?
So far I haven’t seen a node from the node system, only webgl materials.
But at a certain point you try to use the webgpuRenderer with the code designed for webgl?
If that’s the case, I can only speculate as to what’s going wrong.

1 Like

Solution: NodeMaterial: Use type 'vec3' when getting color attribute, fixing crash in WebGPU. by andreasrosdal · Pull Request #27210 · mrdoob/three.js · GitHub

2 Likes