Regulating how much to draw based on how much was drawn last frame.

Posted by Mike Howard on Game Development See other posts from Game Development or by Mike Howard
Published on 2011-06-25T14:11:08Z Indexed on 2011/06/25 16:31 UTC
Read the original article Hit count: 307

Filed under:
|
|
|
|

I have a 3D game world on an iPhone (limited graphics speed), and I'm already regulating whether I draw each shape on the screen based on it's size and distance from the camera. Something like...

if (how_big_it_looks_from_the_camera > constant) then draw

What I want to do now is also take into account how many shapes are being drawn, so that in busier areas of the game world I can draw less than I otherwise would.

I tried to do this by dividing how_big_it_looks by the number of shapes that were drawn last frame (well, the square root of this but I'm simplifying - the problem is the same).

if (how_big_it_looks / shapes_drawn > constant2) then draw

But the check happens at the level of objects which represent many drawn shapes, and if an object containing many shapes is switched on, it increases shapes_drawn lots and switches itself back off the next frame. It flickers on and off.

I tried keeping a kind of weighted average of previous values, by each frame doing something like shapes_drawn_recently = 0.9 * shapes_drawn_recently + 0.1 * shapes_just_drawn, but of course it only slows the flickering down because of the nature of the feedback loop.

Is there a good way of solving this?

My project is in Objective-C, but a general algorithm or pseudo-code is good too.

Thanks.

© Game Development or respective owner

Related posts about 3d

Related posts about math