Jump to content
  • Advertisement
Sign in to follow this  
schupf

Instancing only for static geometry?

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

Hello, I've just discovered instancing in D3D10 and have a question about it. Since the positioning data (aka the world matrix) is placed in a vertexbuffer one had to update the vertexbuffer in order to move the instanced entities. This leads me to the conclusion that instantinc is preferably used for static data, for example 100 trees whoes properties (position, scale, color etc) NEVER change. Is this true?

Share this post


Link to post
Share on other sites
Advertisement
This is actually not the case. Your transformation for each model can be loaded into a dynamic vertex buffer every frame. I believe that there are some examples of this in the SDK. The buffer can then be instanced per model so as to use the same transformation for all vertices in the model, but a different transform for each instance. Updating this data each frame shouldn't cause any performance impacts since it's one of the primary scenarios for dynamic resources.

Share this post


Link to post
Share on other sites
To expand on what DieterVW was saying, hardware instancing (as the DX SDK calls it) uses two vertex streams. The first one is generally the model that you're drawing, and the other one is the per-instance data.

So take your tree example, you would have stream 0 be the vertex buffer housing the mesh of the tree, which doesn't change. The each frame you fill a second vertex buffer with the world matrices for each tree and set that as stream 1.

So the idea is to separate the static and dynamic data into two vertex buffers, where you only need to modify the dynamic data.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!