Jump to content
  • Advertisement
Sign in to follow this  
JasonBradley

Optimizing Procedural 2D Cloud Generation using Pre-drawn Cloud Particles, Any Suggestions?

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

Its not that big of an issue right now, because I don't plan on having 30 clouds on the screen at once but it bothers me that it only takes 30 or so clouds to make my fps drop by about half. There are no more than 20 particles in each cloud, so that's a max of only 600 particles on the screen. Is it just the fact that they are Texture2D objects and these aren't really processed all that fast.
Should I try to combine all of the particles in the cloud into a single image representing the cloud before drawing, would that help at all. And even farther, would I just have an image that would hold all of the particles of all the clouds at once and update that every frame that more clouds are added in order to minimize the number of Texture2D objects that have to be drawn? I've also tried doing this with all of the transparency in the images taken out except for the edges because I want them to stay circles, but with no luck. The game ran just as slowly. I've already tried to minimize the number of new objects being created every frame but there are probably still a couple of places that could still be fixed.

Here's a recording of what I mean so that you can visualize it correctly:
Video


And here's a link to the source if it helps:
http://dl.dropbox.co...udsQuestion.zip

Thanks in advance to anyone that can help me out! Most of the cloud generation code is in the cloud.cs file and there are a few other lines in the TerraCraft.cs file, you can find them easily by using the find tool to search for "cloud generation" as I've put a comment right above those lines with that in it so that they are easy to find. I don't want anyone to feel like I'm asking them to go scouring through my code for the next couple hours to fix this for me, so there it is, that's all that pertains to the clouds.

Share this post


Link to post
Share on other sites
Advertisement
You're almost certainly bottlenecking on fillrate for starters, there's quite a bit of overdraw in that scene and lots of alpha-blended layers like you're using will drag performance down.

Another thing that could (potentially, depending on your hardware and what version of D3D you're using) cause slowdown is number of draw calls. If each cloud needs it's own draw call that can be fairly heavy in terms of CPU time (only 600 shouldn't be that big an issue so count this one as dubious speculation - it's definitely something to be aware of when you start adding more stuff to your scene though).

Share this post


Link to post
Share on other sites
I haven't messed around much with modifying textures in game so I'm pretty clueless when it comes to that. What would be the most cost efficient way to go about combining multiple Texture2D objects into one while still keeping the positions of the original textures? I've seen the GetData and SetData commands used somewhat but I don't really understand how to use them myself.

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!