Instancing only for static geometry?

Started by
1 comment, last by gekko 14 years ago
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?
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.
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.
-- gekko

This topic is closed to new replies.

Advertisement