Archived

This topic is now archived and is closed to further replies.

BlackGhost

Using vertex buffers for bullets

Recommended Posts

I''m a begginer with DirectX, and am looking to implement a graphics engine for a simple 3D shooter game. I have all the moving entities implemented and rendered as meshes, but when it comes to bullets I don''t want to spend resources on a whole mesh as there are too many of them. If anyone has ever dealt with this issue before, I''d appreciate some advice on whether a dedicated vertex buffer for bullets would do the trick (performance-wise). That is, allocate space for a maximum number of bullets and create a buffer that can store that number of position-colored vertices. Then I lock the buffer each frame to move the vertices/bullets and render them as a point list. Would the buffer switches and locking/unlocking slow down the program? Do you think there might be a better way to do it? Thanks for any advice.

Share this post


Link to post
Share on other sites
You might not want to render the bullets at all. Rather, just test for the intersection of the bullets and other objects. So you never actually draw them, just show their effects. This makes sense to me, since you never see bullets in real life. Saves a lot of resources and time, too, considering there would be a lot of them to render.


Share this post


Link to post
Share on other sites
I think Circlesoft is right. You can have a bullet hole texture and place that on any places a bullet hits. But since bullets can''t be seen by the naked eye, you don''t have to render them flying through the air.

neneboricua

Share this post


Link to post
Share on other sites
I'm no DirectX expert, just starting actually, so I'm not going to attempt to answer this question from a technical standpoint. But think about tracers. I don't know exactly how they work, but I think they do like every third one or so. At any rate, rendering every third or so would cut down on resourse cost, and at the same time still show where the line of fire is.

I guess I'm assuming you're doing a machine gun. With a single shot, or even a shotgun, just showing where it hit with a bullethole or whatever would do the job.

[edited by - moonshot on October 20, 2003 9:06:13 PM]

[edited by - moonshot on October 20, 2003 9:06:51 PM]

Share this post


Link to post
Share on other sites
Thanks for these answers, but actually displaying the bullets all the time is essential to this game''s gameplay. I guess i''m going to leave it as it is for now (vertex buffer being locked/unlocked all the time) and revisit it on the optimization phase, perhaps doing the updates every other frame if that helps.

Share this post


Link to post
Share on other sites
If you really need to render all those bullets, you should only load one copy of the bullet''s mesh. Then draw that same mesh at the different positions of all the bullets in your scene.

That being said, you can use different tricks to avoid having to repostion your bullet mesh all over your scene and then render it. For example, the newest expansion packs to Mideval: Total War display hundreds of units at a time. I doubt that they go through the trouble of positioning and rendering each unit individually. Your bullet problem and the problem of displaying many instances of a single unit in a strategy game are very similar. You might want to do a search in the Game Programming forum for this topic. I''ve seen it discussed there a few times but I don''t remember what the final conclusion was.

neneboricua

Share this post


Link to post
Share on other sites
quote:
Original post by neneboricua19
If you really need to render all those bullets, you should only load one copy of the bullet''s mesh. Then draw that same mesh at the different positions of all the bullets in your scene.
That''s exactly how my engine works
Except that it does that for all objects, thus saving tons of RAM.




Share this post


Link to post
Share on other sites
Hello CircleEnix!!!

As to the topic, when you say beginner, what do you mean by that? I don''t want to type what you already know how to do (to save space on this board).

Another thing is that bullets are sooo small that the overhead of locking the vertex buffer isn''t worth it. You could use matricies (not to sound sarcastic). Or realize that you can only have so many bullets on the screen and divide them up into different buffers. Because a bullet is so small, a user probably won''t notice something as small as that.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
bullets really should hinder the RAM too much, test it out with a real mesh and see if it causes problems , if not leave it as is .

Share this post


Link to post
Share on other sites