Mesh instance
Hello,
I would like to know, how hardware instancing works and how can i make it ? I can't find any information about that.
I hope, it's not only to save pointer to new instanced object hehe.
Thank you very much for any information :) if you know any websites, i will be happy ;-)
Ah, sorry :)
DirectX 9 native API in c++
i thought, It's almost same in XNA and classic c++ code :)
DirectX 9 native API in c++
i thought, It's almost same in XNA and classic c++ code :)
Well you'll definitely want to have a look at the Instancing sample in the SDK. That will demonstrate the API calls and how to setup your shaders. You can also have a look at this sample.
The basic premise is like this:
-Your mesh and index data stays the same (your triangles must be indexed for instancing to work)
-In addition to your mesh data, you create a secondary vertex buffer containing all per-instance data for all instances that you want to draw. This might be a position, a full world matrix, a color, UV offsets, anything that can change from instance to instance.
-Your vertex declaration must contain all elements in your mesh vertex buffer, as well as all elements in your instance data buffer (with the instance data elements mapped to stream 1 instead of stream 0).
-When you're ready to draw, you bind the mesh vertex buffer to stream 0 and your instance data buffer to stream 1. You then set the frequency divider to indicate how many instances you need to draw.
-In your vertex shader, you include inputs for instance data elements. You then transform vertices like you normally would.
The basic premise is like this:
-Your mesh and index data stays the same (your triangles must be indexed for instancing to work)
-In addition to your mesh data, you create a secondary vertex buffer containing all per-instance data for all instances that you want to draw. This might be a position, a full world matrix, a color, UV offsets, anything that can change from instance to instance.
-Your vertex declaration must contain all elements in your mesh vertex buffer, as well as all elements in your instance data buffer (with the instance data elements mapped to stream 1 instead of stream 0).
-When you're ready to draw, you bind the mesh vertex buffer to stream 0 and your instance data buffer to stream 1. You then set the frequency divider to indicate how many instances you need to draw.
-In your vertex shader, you include inputs for instance data elements. You then transform vertices like you normally would.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement