Jump to content
  • Advertisement
Sign in to follow this  
MattyRodg

Billboard Instancing with Effects

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

Sorry for the long post. What I'm trying to do is instancing of billboards, using a DX effect and a single vertex buffer. Thanks in advance for any help. What I have working so far is: 1. I have a billboard class (model space vertices, texture, vertex buffer). 2. I have a billboard instance class. (pointer to a billboard, an ID) 3. I have a "BillboardManager" class (don't kill me for using the term 'manager') that has the effect, an array of billboards and an array of billboard instances. My current rendering is like this: 1. Update the billboard rotation matrix, bbMatrix. (I only do this once per frame, using the [camera.LookAt - camera.Eye] vector. Saves a lot of calculations and doesn't look that bad. Is this acceptable or is there a better way?) 2. For each billboard, set the texture and vertex buffer data. 3. Loop though all billboard instances: { 4. If the instance ID matches the current billboard: 5. Calculate and set the worldViewProj matrix (bbMatrix * InstancePosition * view * proj) 6. Execute the effect. (which calls DrawPrimitive to draw a single quad for every instance). } This works, although slow as hell. What I want to do now is move the vertex buffer into the "Manager" class and fill it with every visible billboard instance once per frame, so I only have to call DrawPrimitive once per frame. So what I am trying to do now is: 1. On instantiation of a billboard instance, translate the model space vertices of the billboard by the position of the instance and store it in the instance object. New rendering would be: 1. Update the billboard matrix, bbMatrix. 2. For each billboard, set the texture and calculate the worldViewProj matrix (bbMatrix * view * proj) 3. Execute the effect. 4. Inside the effect (after BeginPass), loop through all billboard instances: { 5. If the instance ID matches the current billboard, add its translated vertices to the single vertex buffer in the Manager class. } 6. After the loop, set the vertex data and call DrawPrimitive once for all vertices. The results are: nothing shows up. I know it has to do with trying to translate the position on instantiation, which screws up the worldViewProj during rendering. Any advice would be much appreciated. I'll provide more implementation details if needed. Thanks. ~Matt

Share this post


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