Skip to main content
gamedev.net
🔒 Locked

flickering with multiple instance animation

Started by b3rs3rk 5 replies 1.1k views
Original Post
b3rs3rk
b3rs3rk
ok,i'll go right to the point. I've created a class for loading and managing md5 meshes, and another one that manages single objects in my engine.Basically,this last class handles the world matrix for that object, has a pointer to the mesh and other cool stuff. The problem is that some objects share the same mesh, and it could be animated, so when i render everything i get a real boring flickering problem. This is what i do every frame:

clear the target and set the camera
for every object
   object.update_animation(time);
   pDevice->SetTransform(D3DTS_WORLD , &object.MatWorld);
   object.mesh->render();


the update_animation function updates the current animation according to the current time and the current frame (that is internally stored in the object class). Another problem is that all the objects show the same animation at the same frame in spite of (for example) one should be walking and another should be simply standing... [Edited by - b3rs3rk on August 27, 2006 3:06:14 PM]
Specchum
Specchum
That's cos you're using a single vertex buffer for your shared meshes i think. Each time you update the buffer for your animation it's reflected for all your models that share the buffer, which is not ideally what you want. Each instance of your model should have its own render buffer that is updated independent of the original shared vertex buffer for animation operations.
"There is no dark side of the moon." - Pink Floyd
gammaGT
gammaGT
I disagree with Speccum. I did almost exactly that in one of my older FFP apps. Are you sure, that you didn't change something else producing that problem?
--I love deadlines. I like the whooshing sound they make as they fly by. (Douglas Adams)
Supernat02
Supernat02
A little more detail might help. What is the logic flow for your animation update and your rendering code? Do you actually update the verts in a single vertex buffer, then render them? Or does the update_animation routine update a series of transforms for each bone while the render routine sets the world transform for each bone and renders that bone? Updating the verts for the same objects could cause a slowdown, because you may be ready to update the verts for Object #2, but Object #1 won't let you lock the verts because it's still rendering them. Compound that with multiple objects and large meshes. To solve, you could create a big vertex buffer big enough to hold 20 objects, then update the system memory in the update_animation code, then copy the system memory to the vertex buffer in stages. For instance, object one would lock the first 10 verts of the vertex buffer, object 2 would lock the next 10, etc. You can get a nice speed increase. This is a pretty common technique and one that Microsoft recommends.

So what exactly do you mean by flickering anyway? Does one object disappear and the other get rendered, etc.? Are the objects appearing to flicker between varying animation stances? Does it also flicker if you don't animate them? If the animation time is out of bounds every frame, it may start over at the beginning and create a similar flickering effect, so you'll want to verify that the time passed in is small and used correctly.
Chris ByersMicrosoft DirectX MVP - 2005
b3rs3rk
b3rs3rk
With the approach i've taken (which is the same of the book Programming role playing games with directx), all the objects that use the same mesh share the same index and vertex buffer (this way i can load the model only one time).
Every frame i cycle through the object list, update the buffers according to the i-th object current animation, then i render it.

If i don't animate the objects, everything is perfect. When animating, the first object of the list is rendered correctly, the others show the same animation of the first and sometimes they "disappear" ( = flicker ) for a nanosecond.

Any advices?
b3rs3rk
b3rs3rk
after a "bit" of redesigning, i've switched to .x files with animations. So now i have my cool mesh with bones exported, loaded and skinned on gpu. Everything works perfectly till i add a new instance of the model. Basically every entity has a pointer to the skinned model(that is shared between all of them) and an animation controller.

In my render function, i loop for all the instances, update the entity's animation controller and render it. Everything works fine, all the animations are correct but the flickering problem still remains o_O The first entity is rendered perfectly, then all the others are like disappearing ghosts (but show the correct animation :D )
How could i do?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.