Posted 29 March 2012 - 12:56 AM
Ah, good old memories. Elevation can be done by shading / lighting up the slopes, and giving an offset to the Y-pixel coordinate of the objects that stand on that tile. Just calculate that offset like you would do with a 3D heightMap. Drawing a couple different tiles for each underground (grass, grass slope facing northWest, grass slope facing southWest, grass slope corner south, ...) gives the best quality probably. Though older games also may simply used another, darker, color pallette when rendering those tiles to save some memory. But on modern hardware, that shouldn't be a factor.
Using 3D can save headaches, although the initial steps to start it are a bit more difficult. Then again, heightMap terrains are relative simple, especially if you work with a fixed window, meaning you cannot rotate or zoom out and thus always have the same amount of tiles in your screen. It means you don't have to worry much about clipping, rendering on large distances, and so on. Anyway. the benefits of 3D:
- You only have to draw 1 texture per materialType (grass, sand, rocks, beach, ...). The lighting will be done dynamically
- With some shaders, you can implement "texture splatting". Draw your terrain and let the shaders smoothly mix the sand, grass, snow, or whatsoever
- Depth sorting may get easier, though if you use blending you still have to sort yourself to prevent artefacts
- With procedural shaders you can add extra detail based on the geometry (high places get snow, slopes get different foliage than flat ones, et cetera)
- You can still keep the isometric Age of Empires view (use an orthogonal camera, on a fixed height above the terrain, view fixed angle)
- You can still draw the buildings, trees and characters still as (animated) sprites, like you would do in a 2D game
BUT.... Making the 3D terrain look as good as a handdraw 2D game isn't so easy. By default, lighting sucks, neither will it generate shadows (but nor does the terrain in AoE). With a bit shader training you can quite easily create similiar lighting than AoE, and with some small extra effort you can even make a day-night cycle, change the weather, or whatever you like. What you could do for the lighting is using a pre-rendered cubeMap / texture. That sounds difficult, but it isn't. Depending on the surface normal (facing upwards, or sloped), you can pick a color from a texture. So normals that face exactly towards the sun would get a bright color. Slopes that face away from the sun would pick a darker "ambient" value. This way you don't have to calculate anything, and you get ambient lighting for "free".
Mountains won't cast shadows then though. Their backsides will be darker, but it does not "warp" a shadow over the terrain or objects behind. But as long as you keep the terrain relative flat, like in AoE, that isn't needed anyway. For the sprites you can use a cheap, dirty, but effective trick.
- First render the terrain
- Render the exact same sprite, but with black pixels
- Render the "shadow"-sprite with multiply blending, meaning it will darken the terrain it overlaps (not the objects!)
- Render the "shadow"-sprite skewed / flattened. Imagine the sprite as a quad, the bottom will be at the "feet" of the object that casts the shadow. The top will be moved downwards and to the left for example. This makes the shadow seems to be projected on the ground.
- Render the normal object sprites on top
Those are not correct shadows, but who will notice?
Dunno what your target platform is, but I would go for the 3D approach, and then just render flat traditional sprites on top.
Rick