Can you think of any design-based optimisations?

Member
Posts: 351
Joined: 2002.04
Post: #1
What do I mean by design-based optimisations? Well in the game engine I'm currently working on I've just put in four enemies on screen and this has slowed things down quite a bit primarily because of all the animation going on at once. I plan to go into my animation code and see if I can optimise but because I'm not too confident about my ability to do this I've been trying to think laterally on the issue. I've come up with ideas like, if the engine detects the frame-rate dropping too low, then some of the enemies would go into a 'guarding' pose and stop animating. If the pose was appropriate they could look like they are concentrating and waiting without having to animate them.

So what other kinds of optimisiations like this have you seen or can you think of?

Just interested to get some discussion going.
Quote this message in a reply
Founder
Posts: 1,138
Joined: 2002.04
Post: #2
What you said makes sense. Watch those Chinese/Japanese movies where a bunch of bad guys surround the hero. They don't all attack as once because they would get in each other's way. So one goes in while the others look for an opening.

Can you explain your game better? Hard to say general advice.

Carlos A. Camacho,
Founder
iDevGames
Quote this message in a reply
Member
Posts: 351
Joined: 2002.04
Post: #3
I'm not only looking for advice on my game, also where people may have seen similar techniques. But anyway, my game is a 3D third-person action-adventure with vampires. Although combat is a crucial part of the game, it won't have thousands of vampires chasing you - it will have exploration and puzzle solving broken up with battles with between 1 and 5 enemies. So I will be keeping the number of animations on screen at once down because of the nature of the game, but I'd still like to have the ability to include more should the need arise.
Quote this message in a reply
Member
Posts: 79
Joined: 2002.08
Post: #4
Do you need to update the animations for every enemy every frame? Only doing it every other frame would cut it in half. 50% of the enemies one frame and the other 50 the next frame and then alternating.

But in any case you should profile it with Shark and see what's taking up the time, then you know what to focus your optimization efforts on. Trying to optimize without knowing exactly where the time is spent is usually a waste of time.

KenD

CodeBlender Software - http://www.codeblender.com
Quote this message in a reply
Moderator
Posts: 434
Joined: 2002.09
Post: #5
I've been dealing with optimization on my uDG game. Things I am trying or about to try:

1) OpenGL optimizations (vertext arrays, display lists)
2) level of detail (draw things less detailed or in 2 dimensions when they are far away)
3) adjustable fog, and don't draw things at all when they are too far away (fogged out)
4) frustum culling
5) pre-scaling models so that I don't have to turn on OpenGL's normal rescaling
6) give player option to run in a lower resolution (640x480 runs faster on some machine configurations)
7) global object sorting to avoid drawing things that aren't in the immediate vicinity of the camera

Without knowing what you've done already it's hard to comment further, but maybe you'll get a new idea from the above list.

Measure twice, cut once, curse three or four times.
Quote this message in a reply
Member
Posts: 92
Joined: 2002.04
Post: #6
Quote:Originally posted by KenD
Do you need to update the animations for every enemy every frame? Only doing it every other frame would cut it in half. 50% of the enemies one frame and the other 50 the next frame and then alternating.
KenD

You could expand on KenDs idea. drop 1 in 4 then , 1 in 3, 1 in 2 depending on distance from the character/camera, sorta like a fog of war. I'd imagine if you are going to be having 4 to 5 enemies on the screen at once they won't all be going flat out in the players face. It might be easy to drop frames?
Also are you doing animation behind the cameras POV? I imagine you are doing some sort of bounds checking but at what point if the animation being handled.

Justin "LordFire" Baldock
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
Trying to take this back on-topic...

Reputedly, in Jak and Daxter, if you're running so fast towards a new area that the background loader won't finish before you get there, the game causes you to trip.

I thought that was pretty cool Grin

Ratchet & Clank masks level loading by showing an animation of the spaceship flying to the new planet, then once it's got the immediate surrounds loaded it shows an animation of Ratchet & Clank disembarking.

And of course, though slightly less on-topic, Myth I & II only use nearest-neighbor filtering for the terrain texture while the camera is in motion, but use bilinear filtering while the camera is stationary.
Quote this message in a reply
Member
Posts: 351
Joined: 2002.04
Post: #8
Yes, these are all good ideas worth trying (some I had thought of already) but I'm actually just thinking generally about creative ways to get past such issues. Similar to a discussion once started here about loading levels while a player is playing, and if the level isn't fully loaded by the time they reach it the game could stop them with some minor animation where they stop to look around, or fall over or something.

The input so far is great, but let's start branching out!
Quote this message in a reply
Member
Posts: 351
Joined: 2002.04
Post: #9
Quote:Originally posted by OneSadCookie
Reputedly, in Jak and Daxter, if you're running so fast towards a new area that the background loader won't finish before you get there, the game causes you to trip.

I thought that was pretty cool Grin


Right, that's what I was thinking of when I mentioned the level-loading discussion. More ideas like this are cool!
Quote this message in a reply
Member
Posts: 177
Joined: 2002.08
Post: #10
Quote:Originally posted by OneSadCookie

And of course, though slightly less on-topic, Myth I & II only use nearest-neighbor filtering for the terrain texture while the camera is in motion, but use bilinear filtering while the camera is stationary.


For the record, it only does that in software rendering mode.
Quote this message in a reply
Member
Posts: 92
Joined: 2002.04
Post: #11
How about instead of the vampires standing about looking stunned, maybe let them 'phase shift' make them transparent/fog like. When they detect the player get them to shift to normal to start fighting.

On level loading, how about if the character stops running to
a) check / clean weapn.
b) sharpen wooden stake.
c) pray to whatever god / demi-god they support.

while that is going on the level is being loaded.

Take those ideas with a pinch of salt, since I've not finished anything before.

Justin "LordFire" Baldock
Quote this message in a reply
Member
Posts: 164
Joined: 2002.04
Post: #12
While we're talking about 3rd-person-action-adventure game optimisation stuff...
In Lugaru I use LOD for the models and animations, so somebody who is far away will have a low-poly model with an animation that updates just a couple times a second and normals that update about every secodnd, while someone close up will have a high-poly model and update the animation a few dozen times a second and use IK to make sure their feet are on the ground etc.

And then as more people get closer you just scale down the distance at which these changes start to occur.

And then you throw a couple ragdolls on a complex object and it turns into a slideshow anyways Rasp

Oh yeah and make sure you aren't rendering the animations of actors off-camera or behind objects.
Quote this message in a reply
Member
Posts: 79
Joined: 2002.08
Post: #13
In general there are usually a bunch of things that don't need to be updated every frame. Rarely does AI need to be updated every frame. Spreading out computations over several frames works very well in many cases.

And like others have mentioned, don't render stuff you can't see. This goes for polygons in objects too. Remove polygons from objects that you will never see anyway. And don't spend 20 polygons on something that will only come out to a few pixels on screen. This of course depends on if the camera can get up close to it or not.
And rendering closer objects first will cut down on number of pixels that need to be sent to the screen.

There are many ways to optimize things. Just need to be creative. Smile

KenD

CodeBlender Software - http://www.codeblender.com
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #14
Just now I came up with an idea to optimize sound in a very nice way - not really related, but here goes anyway. (Note: I am just now implementing it, and it might actually come out extremely crappy, so YMMV)

My problem is that I really don't want to do multichanneled sound with my sound architecture, which, due to some bad planning omissions doesn't handle multiple instances of a sound. So, if I want to let two explosions go off, I would need to load the same file twice and keep it in memory twice at all times. So, I tried to work around it, and I came up with something - what if playing a sound twice just increases the volume? The way I see it, each sound will have a base volume (at which it is usually played) and a technical max volume. Now, each time a request for a sound comes in for a sound that is already playing, I just restart the sound, and increases the volume by (maxVolume - currVolume). This means that playing three explosions at with short delays will sound something like it should (the right duration, at least), but will also increase the volume as each new explosion goes off! I think it might be cool, and it will definitely not bog down the CPU. Grin
Quote this message in a reply
Moderator
Posts: 434
Joined: 2002.09
Post: #15
Quote:Originally posted by Fenris
Just now I came up with an idea to optimize sound in a very nice way - not really related, but here goes anyway. (Note: I am just now implementing it, and it might actually come out extremely crappy, so YMMV)

My problem is that I really don't want to do multichanneled sound with my sound architecture, which, due to some bad planning omissions doesn't handle multiple instances of a sound. So, if I want to let two explosions go off, I would need to load the same file twice and keep it in memory twice at all times. So, I tried to work around it, and I came up with something - what if playing a sound twice just increases the volume? The way I see it, each sound will have a base volume (at which it is usually played) and a technical max volume. Now, each time a request for a sound comes in for a sound that is already playing, I just restart the sound, and increases the volume by (maxVolume - currVolume). This means that playing three explosions at with short delays will sound something like it should (the right duration, at least), but will also increase the volume as each new explosion goes off! I think it might be cool, and it will definitely not bog down the CPU. Grin


Let us know how that goes. I think you may get a stuttering effect, depending on the sound, because you are restarting it each time. It might sound better to let the first one fade, then play the trailing end of the follow-up explosion?

I'm a bit curious about the limitation you describe, doesn't seem like it would be hard to work around it, but that's easy for me to say, not having seen the code. For that matter, if you have to have three copies of a smallish sound in memory, then why not? One way I've implemented sound playback in the past is to fix the number of channels. If you have 3 channels, and the game tries to play a 4th sound, it picks one of the existing channels and replaces that sound. If you did something like this you'd know how many copies of the sound to keep in memory (in effect, each channel would independently own a copy of every sound. It would basically be three copies of the one-channel mechanism you already have implemented.)

Granted, it's a hack, but it sounds like you might be in the mood for a hack. :-)

Disclaimer: I probably shouldn't even comment on your problem given that I haven't even added sound to my latest uDG entry yet. :-)

Measure twice, cut once, curse three or four times.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  How to Design a Text Based MMORPG? SpireGames 3 5,425 Mar 23, 2009 01:40 AM
Last Post: Ingemar
  Tile based map design tools? mrigame 12 7,493 Feb 20, 2005 09:20 AM
Last Post: Swift