Jump to content


Photo

Need To Reduce Number of Objects Being Drawn


  • This topic is locked This topic is locked
2 replies to this topic

#1 nintendoeats

nintendoeats

    GMC Member

  • New Member
  • 45 posts

Posted 04 March 2012 - 02:12 AM

I'm working on project in an attempt to get an internship at GDC. In case you didn't know, that's in 3 days.

I've been developing mainly on my desktop, but I need it to run at or near 60 FPS on my laptop. I had some framerate issues earlier because I was using multiple randomized floor tiles, so I replaced them with single large tiles custom for for each room. This brought my framerate back to 60 easily.

Unfortunately now that I have a near-complete level, I have a much bigger problem. Key to the game's appeal is the organically destructible elements (well, as organic as somebody who has been coding in their spare time since September can make them), mainly glass and drywall. The amount of these things present in the level I have built is crippling my laptop once enough chaos has transpired. It's only in my last big crunch of work that this has become a problem. Previously it could handle every single object in the building, and the framerate would only drop when I had the camera pulled all the way out.

I've uploaded a video as a demonstration. It was captured using my desktop, but FRAPS lowered the framerate down to almost the same that my laptop gets. This does not include the camera scaling that is present in normal gameplay to accommodate both players, which further impacts the framerate when too many fragments are lying about.

Here is what is happening when a destructible object is destroyed: debris instances are being created (in one case 60 instances at once), they scatter around and bounce off walls, and then when each one reaches a speed of 0 it replaces itself with an object that has no events. The bouncing doesn't cause any problems, but simply rendering the "dead" objects is crippling me. I have a couple little places where I can reduce object counts (I can group together some of the walls into new custom sprites, same as with the tiles) but I think that I need a systematic solution to make this work. I doubt that this game will be nearly as fun at a sub-60 framerate, or with a reduced number of destructible elements. Does anybody have any ideas? Maybe a way to capture all of the resting objects and render them as a single sprite?

Help me GMC, your my only hope!

Thanks
Nintendoeats

Edited by nintendoeats, 04 March 2012 - 04:09 AM.

  • 0

#2 Docopoper

Docopoper

    You are observant!

  • GMC Member
  • 1287 posts
  • Version:GM:Studio

Posted 04 March 2012 - 04:43 AM

Depending on how large your map is and whether the debris being rotated matters to you to a high degree - I have 3 solutions:

1) The map is relatively small (2048 * 2048 or less, 4096 * 4096 might be fine - you could test it) - Rotations possible:
Use a large surface, or subdivided surfaces - depending on how much time you are willing to spend implementing this. The flaw is the memory usage, for compatibility - assume the surface will be rounded up to powers of 2, as some graphics cards do this.


2) The map is arbitrary in size - Rotations not possible:
Use tiles - the problem with using blank objects is that the runner still has to go through every object every step and check to see if it has any events - tiles can't have events, so they are faster. Tiles however cannot be rotated, this may mean they are using a faster drawing function - I don't know, but irrespective, they are much faster if you are willing to overlook this.



3) The map is arbitrary in size - Rotations possible:
Use the particle system - you would simply create a particle type with a extremely long life, these could have rotations and will be faster than objects - I have never used them to represent static objects - but I don't see any reason why it wouldn't work.
  • 0

#3 nintendoeats

nintendoeats

    GMC Member

  • New Member
  • 45 posts

Posted 04 March 2012 - 05:11 AM

My map is 5000 by 5000, rotations would be preferable. I will take a look at it in the morning, but I have a feeling that particle effects are my best bet. I was really hoping that I wouldn't have to mess with those, but if it's what I have to do then there we are.

Thanks
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users