Fast tile rendering
Hi, I've been programming a 3D tile-based engine in my spare time and would like some suggestions on efficiently rendering terrain tiles without multiple passes. Right now, I have a way to algorithmically create a texture based on a number of materials and use the composite texture to render all the tiles on the map. Painting is also algorithmic, something like warcraft3's painting tool but I believe they use multiple passes or multiple texture stages for rendering terrain, which achieve a more natural feel to their terrain. I use one pass, one texture but I would like to get a more natural feel to the terrain without compromising that much efficiency. Any suggestions?
Here's what my engine looks like right now:
[Edited by - Wicked Ewok on November 16, 2004 1:04:40 AM]
Quote:Original post by Wicked Ewok
I use one pass, one texture but I would like to get a more natural feel to the terrain without compromising that much efficiency. Any suggestions?
Here are a few shots of what I was doing before putting my project on hold:
My maps were simple 2D heightmaps. map[0][0] would be the top left corner of the map, drawing left to right, top to bottom. Each "tile" would have a value associated with a texture (i.e., grass, dirt, rock, snow, etc.) The tile was drawn using the current heightmap point plus map[x+1][y+1] as the bottom right corner. 2 tris per tile. I would draw a 3x3 set of vertices with alpha values set like this:
0 0 0
0 1 0
0 0 0
then step over 2 vertices to the right and draw the next tile. When I get to the end of the current row, I step down 2 verts and repeat. This produced the linear transitions between tiles, and I think it worked pretty well visually.
A big bottleneck was no doubt the fact that at this point it's still brute force. I do a texture change every tile, even if it's the same as the last. Heh. But it's still just one pass. I simply load the texture unit with the current tile's texture and draw the 3x3 verts with it, with appropriate alpha values at each vert.
With all that said, it looks like you're doing something similar with your "materials". You seem to be doing the same kind of linear type fade between tiles, and it looks good.
Empire Earth is the kind of look I was shooting for, in any case, which I prefer over a more segmented one. Like War 3, they seem to use different tiles for their transitions instead of just alpha blending the edges. Seems less natural.
Take care.
Thanks for the reply.I see what you're doing. But in the way I had in mind, I am really doing one pass, one texture and one draw primitive call for the whole terrain(well sectorized so that I can cull parts of the terrain out). I definately don't want to switch a texture per tile, and although linear interpolation has a style of its own when it comes to terrain, that's not the style I'm shooting for. My terrain actually has borders between every two materials but it's just hard to see because of the art:P
War3 does still look cut out because of the tile system, but it's more realistic than mine because I'm using squarish borders. I think it also has to do with their art being so saturated, if they had used less saturated colors( like when they were still in the initial rpg-ish stages before going completely rts ), they would look very nice indeed. I like to be able to show the boundaries between different materials clearly, without fading.
Your engine looks nice though, do you calculate lighting with it? Thanks again.
-Marv
War3 does still look cut out because of the tile system, but it's more realistic than mine because I'm using squarish borders. I think it also has to do with their art being so saturated, if they had used less saturated colors( like when they were still in the initial rpg-ish stages before going completely rts ), they would look very nice indeed. I like to be able to show the boundaries between different materials clearly, without fading.
Your engine looks nice though, do you calculate lighting with it? Thanks again.
-Marv
Quote:Original post by Wicked Ewok
Your engine looks nice though, do you calculate lighting with it?
Negative. Originally, yeah, and I think some of the ancient pics I still have up show some terrain shadowing going on. Using normals based on a single point light (the sun). I think I precalc'd them at runtime.
Good luck with your efforts! Looking nice so far. I'd like to see something other than animated cacti walking around though! LOL!
Take care.
Yes, the animated cacti are the only models I have that don't have so many bones. But they do pathfinding and have AI!:) Engine doesn't yet support splitting bones into groups to send off for hardware rendering, it probably won't because the game intended should only use a limited number of bones anyway. More efficient that way.
btw, here's how my composite tileset is set up right now:
right now I am using a binary edge labeling system consisting of four subsquares per tile. So you only have corners and up and down sides. Warcraft uses a 3x3 subtile grid for their edges, making maybe 16 different edges possible for each material. I think I will also use a 3x3 subtile grid, though it might result in a lot more texture combinations. That will also mean that I will not allow some materials to combine with each other to save texture space. In my experience, more than a few passes of terrain just really slow down the system, especially with so much overdraw when you layer edges on top of another.
btw, here's how my composite tileset is set up right now:
right now I am using a binary edge labeling system consisting of four subsquares per tile. So you only have corners and up and down sides. Warcraft uses a 3x3 subtile grid for their edges, making maybe 16 different edges possible for each material. I think I will also use a 3x3 subtile grid, though it might result in a lot more texture combinations. That will also mean that I will not allow some materials to combine with each other to save texture space. In my experience, more than a few passes of terrain just really slow down the system, especially with so much overdraw when you layer edges on top of another.
I still don't see why you don't just use linear transitions.
I mean, it takes you 32 different texture types to do what you could be doing by just overlaying the way I illustrated above. On top of that you don't have to worry about creating new transitions, only new base textures. With linear transitions, you get the transitions for free!
Instead of your 4 base tiles + transition tiles, you could have 32 different base tiles to work with. Also, I used one texture per tile in my engine because I didn't think to combine them into one and use u/v coords. In other words, you could fit your 4 base tiles into one texture and not have any texture swapping at all while drawing the ground! You could even conceivably fit a large number of base tile textures into one texture, so all 32 could just use one big texture. I personally would keep 'em fitting into 256x256 textures by say, limiting them to 64x64 pixels each or something, but thinking about it now it'd sure be a lot better than swapping textures every single tile.
Anyway, I'd be interested in knowing why you wouldn't want to use linear transitions and instead prefer your manual transitions. What advantages does it have?
Thanks, and take care.
I mean, it takes you 32 different texture types to do what you could be doing by just overlaying the way I illustrated above. On top of that you don't have to worry about creating new transitions, only new base textures. With linear transitions, you get the transitions for free!
Instead of your 4 base tiles + transition tiles, you could have 32 different base tiles to work with. Also, I used one texture per tile in my engine because I didn't think to combine them into one and use u/v coords. In other words, you could fit your 4 base tiles into one texture and not have any texture swapping at all while drawing the ground! You could even conceivably fit a large number of base tile textures into one texture, so all 32 could just use one big texture. I personally would keep 'em fitting into 256x256 textures by say, limiting them to 64x64 pixels each or something, but thinking about it now it'd sure be a lot better than swapping textures every single tile.
Anyway, I'd be interested in knowing why you wouldn't want to use linear transitions and instead prefer your manual transitions. What advantages does it have?
Thanks, and take care.
The reason why I want to use manual transitions is because you can make custom borders that look different from one material to another. Although the tileset you see look like linear transitions, an artist can go use the template and modify it to have good unique borders. Pictures show best so here's what I'm going for:
Linear transitions can't show snow overlapping rock, or the border of rocks that make up a path or grass ending. That's the sort of thing I want to portray. With the composite tileset I have, I can achieve that effect as long as the artist does a good job creating the transitions, but right now, it doesn't look like much.
It's really an art/style preference. But you're right on the texture combining, I'm having doubts whether it's really worth it. The way warcraft does it is they have for each material an edge set texture with different edges and an alpha channel. Their algorithm is as follows( I think, at least this is how they usually do tile rendering ):
- Draw all base textures without edges, so you have no transitions between tiles
- Draw and alphablend all the edges for the texture who should be layered on the bottom
- Draw and alphablend the next material's texture edges
- Keep layering the edges until you get to the top texture.
What I dislike about that method is that I'll have to do X + 1 passes where X is the number of materials since each material needs it's own seperate edge pass. Overdraw will be significant if there is a lot of material bordering.
Some potential solutions that come to mind are:
1) limit edge overlaps to just a pair of materials. This way you're gauranteed not to have so much overdraw( the above method can overlap 4 materials joining together ).
2) Precombine these material pairs( similar to what I did except I had only 3 possible edges(vs 16 or so) which I flipped around uv-wise. And although you have bigger textures, you don't have any overdraw this way.
and that's all I can really think of. :/
Linear transitions can't show snow overlapping rock, or the border of rocks that make up a path or grass ending. That's the sort of thing I want to portray. With the composite tileset I have, I can achieve that effect as long as the artist does a good job creating the transitions, but right now, it doesn't look like much.
It's really an art/style preference. But you're right on the texture combining, I'm having doubts whether it's really worth it. The way warcraft does it is they have for each material an edge set texture with different edges and an alpha channel. Their algorithm is as follows( I think, at least this is how they usually do tile rendering ):
- Draw all base textures without edges, so you have no transitions between tiles
- Draw and alphablend all the edges for the texture who should be layered on the bottom
- Draw and alphablend the next material's texture edges
- Keep layering the edges until you get to the top texture.
What I dislike about that method is that I'll have to do X + 1 passes where X is the number of materials since each material needs it's own seperate edge pass. Overdraw will be significant if there is a lot of material bordering.
Some potential solutions that come to mind are:
1) limit edge overlaps to just a pair of materials. This way you're gauranteed not to have so much overdraw( the above method can overlap 4 materials joining together ).
2) Precombine these material pairs( similar to what I did except I had only 3 possible edges(vs 16 or so) which I flipped around uv-wise. And although you have bigger textures, you don't have any overdraw this way.
and that's all I can really think of. :/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement