In my render loop I'm trying to change alpha value overtime to make objects to fade-in/out:
var blendedFillColor = /* color remains the same, just changing the alpha value */;
var vertices = (CustomVertex.TransformedColored[])_vertexBuffer.Lock(0, 0);
for (int vertexIndex = 0; vertexIndex < 4; vertexIndex++)
{
vertices[vertexIndex].Color = blendedFillColor.ToArgb();
}
_vertexBuffer.Unlock();
It's a performance cost, but pretty much an unavoidable one. You might be able to change some shared color somewhere or use some clever shader tricks, but building vertices at runtime is pretty much the simplest way to submit sprites and particles. You should be fine as long as you keep the number of Lock() and Unlock() calls to a minimum. For example, Lock() once, submit a bunch of geometry, Unlock(), and then call DrawPrimitive to draw everything.
Unlocking/locking the vertex buffer is a bad idea for performance reasons as kdmilller said. This is a perfect example of needing a vertex/pixel shader.
Instead of changing the information per vertex, why not set an alpha value per object? There isnt a need to change it per vertex when it can be set in the shader.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
Instead of changing the information per vertex, why not set an alpha value per object? There isnt a need to change it per vertex when it can be set in the shader.
Can you please share few links to the stuff you are talking about? Or may be a sample code to illustrate.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.