Archived

This topic is now archived and is closed to further replies.

Moving vertices of a mesh in real time?

This topic is 5575 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I still do not understand DX too much or shaders. but How come I never see any 3d games that have deformable meshes. NOT replacing one mesh with another mesh but actually manipulating the vertices to the one and only mesh. For example say I have a sphere that is about 300 triangles. Is it a problem to make a demo where you shoot balls at the sphere and it dents the sphere (ie changes some of the vertices of the mesh to other positions) I just never see a demo.. game or anything that does something like that... is it difficult technically to do? or MAYBE is this what vertex shaders are all about?

Share this post


Link to post
Share on other sites
A couple of reasons:

(a) hard to program for anything usefull besides a demo - you need to know in the damage engine what would be a "good and sensible" deformation, and this is not too easy for more than simple things.
(b) reuse - normally meshes are reused for objects on the screen more than once. Deforming the mesh would kill the reuse factor.
(c) looks better - the graphics guy can "tweak" the deformation.

I would say (b) is a strong technical reason, though.


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
a- It seems no harder to program that a 3d physics engine. And I know it would not be useful for human models. But ... well now that I think of it maybe it would not be REAL useful but it must look better than canned damage models. I know.. Take a demolition derby game for example. That would be a good example. You start out with a car frame and over time the vertices change and are bent depending on the force of the other cars.

b- not sure what you mean. You could make multiple copies and just deform (change the values in the vertex buffer?) the ones you want.

c- Just textures are good enough now. shoot holes in the wall? Just add textures to the plane. Far easier than modifying the geometry

quote:
Original post by thona
A couple of reasons:

(a) hard to program for anything usefull besides a demo - you need to know in the damage engine what would be a "good and sensible" deformation, and this is not too easy for more than simple things.
(b) reuse - normally meshes are reused for objects on the screen more than once. Deforming the mesh would kill the reuse factor.
(c) looks better - the graphics guy can "tweak" the deformation.

I would say (b) is a strong technical reason, though.


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)


Share this post


Link to post
Share on other sites
quote:

How come I never see any 3d games that have deformable meshes. NOT replacing one mesh with another mesh but actually manipulating the vertices to the one and only mesh.



Unreal Tourn. 2003 plus many others use deformable meshes. You have to look close to notice them - most engines use deformable meshes for things like grass, etc. Clothing is another great use for deformable meshes. It''s true that you should use multiple copies of the same mesh, as each copy deforms seperately. However, you usually reserve the resources for important objects, like your main character''s clothes, etc.



Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
and Focus On: Advanced Animation with DirectX

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by thona
(a) hard to program for anything usefull besides a demo - you need to know in the damage engine what would be a "good and sensible" deformation, and this is not too easy for more than simple things.
Plastic Mechanics.
quote:
Original post by thona
(b) reuse - normally meshes are reused for objects on the screen more than once. Deforming the mesh would kill the reuse factor.
Incorrect in the shader implementation, correct for locking the buffer and editing. Shaders do not actually change the position of the mesh in the vertex buffer. You would feed in the matricies that rotated the bones along with Bezier information to deform the mesh in the shader. You would set the transformations as constants to the vertex shader and used an index buffer to index the one buffer that contains the mesh in a single instance.

Pick up "Real Time Rendering Tricks and Techniques in DirectX" by Kelly Dempski. This has examples for using bezier patches and indexing through constants in a vertex buffer. It also states (along with numerous other sources) that vertex shaders do not actually edit the data sent through them, they just reinterpret based on the transforms.
quote:
Original post by thona
(c) looks better - the graphics guy can "tweak" the deformation.

Correct. However, This is a matter of taste. If you have a good artist, then yes, the By-hand deformations look better, but not entirely accurate unless you wanted to store the deformation for several different situations and interpolate between them.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
About grass... thats what vertex shaders are for now right?

I think I am beginning to see how vertex shaders and vertex buffers all come into play. So are vertex shaders a way to change the geometry without changing the vertex buffer right? because changing the vertex buffer is BAD?

Deformations seem to go together with physic engines like mathengine as far as the future of gfx . That being all movement and collisions are done for you. The world is nothing but deforming triangles reacting to each other

I say it will take about another 6 years though then no more canned animations

quote:
Original post by Anonymous Poster
[quote]Original post by thona
(a) hard to program for anything usefull besides a demo - you need to know in the damage engine what would be a "good and sensible" deformation, and this is not too easy for more than simple things.
Plastic Mechanics.
quote:
Original post by thona
(b) reuse - normally meshes are reused for objects on the screen more than once. Deforming the mesh would kill the reuse factor.
Incorrect in the shader implementation, correct for locking the buffer and editing. Shaders do not actually change the position of the mesh in the vertex buffer. You would feed in the matricies that rotated the bones along with Bezier information to deform the mesh in the shader. You would set the transformations as constants to the vertex shader and used an index buffer to index the one buffer that contains the mesh in a single instance.

Pick up "Real Time Rendering Tricks and Techniques in DirectX" by Kelly Dempski. This has examples for using bezier patches and indexing through constants in a vertex buffer. It also states (along with numerous other sources) that vertex shaders do not actually edit the data sent through them, they just reinterpret based on the transforms.
quote:
Original post by thona
(c) looks better - the graphics guy can "tweak" the deformation.

Correct. However, This is a matter of taste. If you have a good artist, then yes, the By-hand deformations look better, but not entirely accurate unless you wanted to store the deformation for several different situations and interpolate between them.

Share this post


Link to post
Share on other sites
Myth by Bungie had deformable terrain. This is different than models because there in only one instance of the terrain.

Red Faction has a deformable environment at well. You could shoot hols in the wall, etc.


Doing deformable environments correctly is not a trivial matter, it is much easier to make damage models & swap them. ( the artists do all the work )

Red Faction did it because it was one of the main parts of the technology.

Myth did it because they designed it in from the beginning.

Both the above games only used it on the environment, not on models. ( of course, Myth didn''t use models for it people, it used 3d sprites. )

Having a deformable mesh for Human models might be a real interesting thing. Lets say I am developing a Fighting game in the style of ''toon. Then, deforming the Coyote''s head when the roadrunner kicks it in might be fairly amusing.

or take an action game:
Samurai Bob slices enemy Jill with his sword, killing her. given Jill''s model & the plane that Bob''s sword swept through, slice the models meshes into multiple meshes that can then fall to the ground in pieces. While this is sure to get you a M rating, if you add in slo-mo like Max Payne, its also sure to get you some kind of cult following as well.


When you are building a game/engine/etc & you are thinking about adding deformable meshes like this, ask yourself this question: Is it worth it? Will it make the game better or more fun? Does it even make sense? & most importanct: Will this feature work given the memory & speed limitations of the machine?

Share this post


Link to post
Share on other sites
quote:
Original post by angrytofu
I still do not understand DX too much or shaders. but

How come I never see any 3d games that have deformable meshes. NOT replacing one mesh with another mesh but actually manipulating the vertices to the one and only mesh.

For example say I have a sphere that is about 300 triangles. Is it a problem to make a demo where you shoot balls at the sphere and it dents the sphere (ie changes some of the vertices of the mesh to other positions)

I just never see a demo.. game or anything that does something like that... is it difficult technically to do?

or MAYBE is this what vertex shaders are all about?



Yes... A vertex shader can adjust x,y,z of a vertex while it is being processed. Pass in a time value and adjust z by sin(time+x+2*y) in the vertex shader and you get waves for free.

Check the SDK docs on skin meshes and the demo with the girl walking. That girl is just one skin mesh, using bones, she walks using animating the bones and deforming in a vertex shader.

Share this post


Link to post
Share on other sites
demo with a girl walking? Where exactly can I find that?

So it is one mesh that looks at the values of the bone structure and moves the mesh around it accordingly?

How does this compare to a half-life animation that uses bones and animations?

Is the main difference that the mesh is created at run time for every frame (vertex shader) ?

and the other is already calculated. . am I understanding?

quote:
Original post by Fidelio_
[quote]Original post by angrytofu
I still do not understand DX too much or shaders. but

How come I never see any 3d games that have deformable meshes. NOT replacing one mesh with another mesh but actually manipulating the vertices to the one and only mesh.

For example say I have a sphere that is about 300 triangles. Is it a problem to make a demo where you shoot balls at the sphere and it dents the sphere (ie changes some of the vertices of the mesh to other positions)

I just never see a demo.. game or anything that does something like that... is it difficult technically to do?

or MAYBE is this what vertex shaders are all about?



Yes... A vertex shader can adjust x,y,z of a vertex while it is being processed. Pass in a time value and adjust z by sin(time+x+2*y) in the vertex shader and you get waves for free.

Check the SDK docs on skin meshes and the demo with the girl walking. That girl is just one skin mesh, using bones, she walks using animating the bones and deforming in a vertex shader.


Share this post


Link to post
Share on other sites