Jump to content
  • Advertisement

Archived

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

jaymz

Blending Multiple Textures onto a Terrain

This topic is 6681 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

Just throwing around some ideas of the best way to do this. What approaches do you guys take? I''m thinking of this in terms of tile based terrain texturing. Here are some of my thoughts: Any more than 4 textures is probably a waste (Lightmap, tiled Detail Texture, tiled surface texture 1 and tiled surface texture 2)thoughts? Has anyone played around with random alpha values in each texture, for example, add random alpha values to a grass texture, then blend it with a rock texture onto a polygon, or is it best to just evenly blend the grass and rock texture together? What do you guys think of blending each texture based on some other value such as height? What blending options give the best performance across most cards?

Share this post


Link to post
Share on other sites
Advertisement
I build 1 large texture for the terrain (which gets broken into patches for rendering). So I blend textures at "creation" time. I use height as well as pitch to determine what textures to blend and how much to blend them. Works really well.

Share this post


Link to post
Share on other sites
What kinda numbers are you looking at though? I was trying to think of a way to keep the textures in the vid cards memory, which prob can''t happen with non-tiled terrain. Your textures would have to be kinda big to avoid making it look bad as it stretches across the terrain.

Share this post


Link to post
Share on other sites
That''s pretty simple... Say you have 3 tiles: grass, rock and water. You figure out where you want the grass where you want the rock and where you want the water. Also some places you blend them so the transition looks smooth. Say each tile is 16x16 pixels, and say your map is 20 tiles by 20 tiles. You combine all your bitmaps into a huge one. You get 16x20 by 16x20 bitmap. Now, obviously you can''t load that into the video memory. So you break it up into a couple of bitmaps, say each 256x256, and load those bitmaps to the video memory. The only annoying thing I could see coming is to figure out the correct texture coordinates for each triangle. But it''s all right, we''re all gonna have to deal with that, damn it!

Share this post


Link to post
Share on other sites
Well, I could explain how I''ve done this... but I''d rather show off my screenshot!



It''s kinda subtle, but yes I''m blending from grass to dirt. Here''s what I do: I have a 2D array of terrain textures (which correspond to my height-map). As you can see in the picture, I have an algo that generates triangles to render my height-map.

The render algo goes something like this:

for each tri:
1. If all vertices are of type "grass", then add it to my "grass" indices list. "Dirt" also has its own indices list.
2. If any of this tri''s vertices differ from each other, then...
2.1 I add the triangle to the "grass" indices list.
2.2 I also add the triangle to my "blended dirt" indices list. For this list, I have to keep track of the alpha for indices, too.

then...
1. Set texture to grass and DrawIndexedPrimitive( vertexPool, grassList )
2. Set texture to dirt and DrawIndexedPrimitive( vertexPool, dirtList )
3. Enable alpha-blending and DrawIndexedPrimitive( vertexPool, dirtBlendList )


Share this post


Link to post
Share on other sites
Not bad from your screenshot. I think you will run into some problems down the road however when you get into larger terrain sets or more than just 2/2.5 textures with this method esp. if you want your program to run on older cards that don''t support many single pass multitexturing capabilities. The best method that I have found so far is to build 1 huge texture, about 4x the size of your terrain, then chop that texture up into smaller sections.. you have to organize your terrain in blocks for this to work, but most people do that anyway so they can quickly cull the blocks that can''t be seen during that frame. Then you apply each chopped up texture to the corresponding terrain block. If you want to get cute, you can still do multipass/multitexturing by adding a detail texture to the terrain blocks nearest to you. There is a good discussion on this over in the longbow digital arts programming message board, which can be found at www.longbowdigitalarts.com

Share this post


Link to post
Share on other sites
jaymz, just had to defend my algo

Firstly, I simplified the description of how it works by only mentioning grass and dirt. The algo does support unlimited textures, and it can blend 3 textures on a single tri in the rare cases where that occurs. Also, perhaps I didn''t make it clear, but I don''t use multi-texturing, I use multi-pass.

As for culling, I can select individual 16x16 regions of the height-map to render (this issue is more related to my LOD algo). On average I expect I will be rendering about 100x100 height-map coords in a frame.

You mentioned building one huge texture and then splitting it up. That sounds like a good plan, but it definitely wouldn''t have worked in my case, for this reason:

- My height-map will be up to 2000x2000 (The screenshot is like 110x80). Currently a single 256x256 pixel texture covers a 12x12 region of the height-map -- that is the resolution I want. So with your method, for a 2000x2000 height-map, I would have to build about a 43000x43000 pixel texture, and then split it up into about 28000 256x256 textures. Big numbers. With my set-up, I just have 4-8 256x256 textures (grass, dirt, rock, snow, etc.), and then I assign one of these to each height-map coord. Actually I ren-length encode the texture types, so it really works out cheap, memory-wise.

Anyway, I guess my point is this: if you want to create a big texture for your entire terrain (and then split it up), you must either have a lot of memory, low resolution textures, or a small terrain. By the way, I just can''t stress enough how much better high-rez textures look -- I tried dropping it to 1 256x256 texture per 64x64 region, and it looked horrible.

Share this post


Link to post
Share on other sites
I was by no means trying to bash your algorithm, just give you a few suggestions that were given to me. Wow thats a lot of texturing.. mind sending me an exe to look at? Still when rendering 10k worth of terrain polys per frame, multi-pass rendering is not an option for me, as just 3 passes (lightmap and 2 textures) would be 30k tri''s per frame just for the landscape, but if it works well in your system, than I say go for it. So what kind of polygon counts are you shooting for each frame? I noticed that your terrain is mostly flat in your screenshot, is your rendering method counting on that or can you have rough terrain? What kind of frame rate are you getting?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I use 3DRAD.

It''s very limited, I can''t do any low level rendering. What I did was to tile a high detail version of the terrain with all the sandy grainy look to it and then use a 512x512 texture of the whole mountain with an alpha value af around 0.4 stretched over it.

It may sound cheap, but it works ok.



Wraiths comming soon...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

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!