Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Terrain tile texturing

This topic is 5528 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What is the fastest way of drawing textured tiles? Do I need to draw the tiles in a order in which they are textured? I mean: first draw all the tiles with a grass texture and then th ones with water, or doesn''t it matter in which way they are drawn? thanx anyway, TriloByte

Share this post

Link to post
Share on other sites
Thanx Raduprv,

But what do you mean by insane? I have a terrain of 128*128 and I swith the texture for every tile.

Share this post

Link to post
Share on other sites
You can draw them all at once (i.e. minimal texture switch) if you are going to use multitexturing (which you should, since its become pretty much a standard on gfx hardware). The trick is weighing each texture unit. There are a number of ways to do this, tell me and I'll give you the technical details. Here is an example of a crude implementation. I'm not sure if this is what you're asking though. If not, ignore me.

[edited by - GreatOne on May 27, 2003 4:21:53 PM]

Share this post

Link to post
Share on other sites
Okay, its a bit involved (especially towards the end), so here we go.

First, what you do is divide you terrain into topographical regions. Think of your terrain in elevation, say from height 0 to height 100, there's going to be sand, from height 100 to height 200 there's going to be grass, from height x to height y, there is going to be whatever. Example:

Now, you generate a vertex weight, from 0 - 1, for each texture (grass, snow, rock, sand, etc) where 0 is not visible and 1 is fully visible. So, for example, when you are at the top of a mountain, you would have snow at 0.9, rock at 0.1, grass at 0, and sand at 0. Or if you were at where the grass meets rock, a sample set of vertex weights might look like this, snow 0, rock 0.5, grass 0.5, sand 0. Example using (2 vertex weights) of blending (yes, those black blob things are vertexs). Imagine the green is a grass texture, and brown is a rock texture (or dirt).

How you generate you vertex weights and how you blend them is up to you, just make sure that your weights never add up to more or less than 1. This is a simplified version of the method Yann L described in this thread.

Now that you've got your weights, you can render a number of ways:
1) Multipass. You render the terrain multiple times, each time using a different texture and different set of weights (as the color) and blend the results together. However, if you terrain has a lot of polys, this turns out to be rather slow. That shot I posted was rendered using multiple passes (and it was slow!).

2)Register Combiners (for nvidia cards only). Here it will only take one pass, but its much more tricky to set up. You can't blend to many textures together in this method. I've never actually gotten it work with register combiners, but I know it can be done. You can store one set of weights in the R,G,B portion of the vertex color, and the other set of weights in the A portion of the vertex color, the third weight is implied (1-((r,g,b)+a). I found this too confusing to actually implement.

3)Fragment programs. I found this one of the simplest and fastest ways to render the terrain (hooray for Cg!). However, this method requires a Geforce3 ti or better, or a Radeon8500 or better. What you do here is send each set of vertex weights on each portion of the primary color channel. For example, for each vertex color (RGBA), your snow weight would be stored in R, your mountain weight in G, etc. Then you write a fragment shader (trust me, its a lot easier than it sounds) to weight each texture unit by its corresponding weight and add them all together for the final vertex color. I used Cg to do this and it took me about 2 days to learn Cg and implement the fragment shader. If ever get to this point, give me a ring, and I"ll help you with the fragment shader if you need it.

I understand all this might be a little overwhelming. But its really not to hard. Start first with just getting the vertex weight system setup and rendering in multiple passes, then move on to fragment shaders or register combiners.

Hope that helps, post a screenshot if you ever get it up and running.

Realm Games Company

[edited by - GreatOne on May 28, 2003 9:33:46 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!