Jump to content
  • Advertisement
Sign in to follow this  
wh1sp3rik

Mesh instance

This topic is 3009 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 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 ;-)

Share this post


Link to post
Share on other sites
Advertisement
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.

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!