A quick way to modify vertices of a mesh (similar to a skinned mesh?)I

Say I have a mesh where the vertices are calculated every frame and I want to update the mesh on the graphics card. I assume this can be done in a fast way because of how SkinnedMeshRender works.

In particular it is a mesh that will be deformed in different ways not compatible with a bone system (so I can’t use a skinnedMeshRender). Maybe I might decide to put ripples on it or twist it or something. Like a water droplet.

So the calculations will be done on the CPU not in a vertex shader. So how do I pass the values quickly to the graphics card. Should I use a vertex shader as a go-between? I’m not quite sure how skinnedMeshRender does it. (Is it done as a vertex shader or just setting the vertices in the Mesh object?)

You’d be surprised what can be done with bones. Rippling water would be fairly straight forward to implement.

I’m not actually sure if there is a valid answer. The point of bones is they require you to pass less data to the graphics card. There is no shortcut efficient way to pass every vertex to the graphics card.

Do you know how the bone system works? I was trying to think how its done. It must be passing something from the CPU to the GPU. But I’m not sure in what format. Is it an array of transforms passed to a vertex shader? I can’t see that would be any faster than just passing in a new vertex array.

I tried to see if there was a “skinned renderer” shader in the standard shaders but couldn’t find one.

You’re right I guess you could have a ripple effect using a bone to interpolate between two mesh states. Should I be looking at “blend shapes” maybe? I am using Blender.

You are talking right on the edge of my expertise. So I might be wrong here. @zombiegorilla probably has a better understanding.

As I understand it a skinned renderer requires you to pass the mesh to the graphics card once. You also pass a set of ‘bone weights’ for each vertex.

Then in future all you need to send is a list of all of the bones position and rotation. The graphics system can work out the position of each individual vertex from that infomation.

Like I said, this is the very edge of my technical knowledge. I know how to use a skinned renderer just fine. But how they work underneath is somewhat automagical to me.

I guess this is efficient if the number of vertices is vastly more than the number of bones. Probably for very low-poly models, it wouldn’t make much difference if you just sent the vertex array each frame. (unless there is some penalty for doing that). Interesting.

Thanks.

Is there any reason you don’t want to use a vertex shader? You can do a pretty wide range of things in shaders. What effect are you trying to accomplish?

Sending small vertex arrays each frame won’t kill the GPU, but in general you want to avoid sending data to the GPU when it’s possible to do things in shaders.

1 Like

Well, imagine the mesh is some kind of soft body object. So pretty much all the vertex positions would be calculated on the CPU. I think vertex shaders are for more predictable kinds of behaviour that can be done simply on the GPU.