Any way to collide with mesh with vertex shader?

Hello there!

Is there a way to collide with object which have a vertex shader? I mean if vertex shader significantly change geometry of the mesh we cant collide in proper way with him. Maybe somebody knows any good solution?

PS: I try to collide camera with mesh.


I wrote a quite simple WebGPU collision compute shader based on AABB collisions. I’m still messing with it and trying to get the fastest speeds. Once it’ll be ready I’ll be happy to share it with you (with the community too ofcourse).

I just started to explore WebGPU shaders but I think you can share the vertex buffer with the compute shader and calculate the collisions.

I believe @Evgeni_Popov will know the answer.


you can share the vertex buffer with the compute shader

I did a bit of research and seems it’s not the case. Maybe we could calculate the vertex positions in a compute shader and pass them to a dumb simple vertex shader. We could calculate the collisions in the compute shader along with the vertex positions. Just an idea, not verified.

1 Like

Doing the collision checks on the CPU would mean to retrieve the updated vertices from the GPU to the CPU, which is not practicable because too slow, except if the changes of vertices are (very) infrequent (and in WebGPU, you will suffer a one frame delay minimum). To make it performant, you would have to perform the collision checks on the GPU, but it means you would have to write all the necessary code to make it happen (only on WebGPU, with compute shaders)…

1 Like

Thanks for your answers guys!
I just repeated vertex displacements that i have in shader in code by updating vertex data by a texture. So I close this topic

1 Like