Sign in to follow this  

How do you efficently change a vertex's location?

This topic is 3731 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

About 3 years ago, I was messing around with directx 9 and I decided to impelement a program I had done many decades earlier, something that took hours to do which could easily be done in real time now. Basically this program renders 'surface' like water that has waves and ripples going through it. Anyhow, this program recomputed a grid of vertexes every frame and this grid was like 100x100 or even 400x400. Recently I leanred that modifying the vertex buff directly is bad, and you should use a matrix transform instead. However, I only know how to apply a matrix transform against a polygon, not a vertex. Imagine a triangle and I just want adjust the Y value of each vertex, how can I do that without running through the vertex buffer and accesing each Y component individually? Is there some faster way apply a bumpmap of sorts, or a heightmap of sorts that is dynamically changing then just editing each vertex's Y coordinate?

Share this post


Link to post
Share on other sites
If you're working with a newer video card that supports reading textures in the vertex shader, you could read from a height map and perform displacement mapping. There was a feature on the technique used for doing this in the game Pacific Fighters over on Gamasutra. Of course you don't need to use a texture, and you could modify the position in the vertex shader in a number ways (like arrays of shader constants).

Otherwise you can modify the vertices directly in vertex buffer via locking, you just have to be careful of how you do it. If you lock a buffer that the GPU is dependent upon for rendering, you will cause a stall and your performance will suffer. However if you double-buffer things, you may be able to avoid a stall.

Share this post


Link to post
Share on other sites

This topic is 3731 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this