• Advertisement

Archived

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

Blending Multiple Textures onto a Terrain

This topic is 6440 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
Here's a little demo of my project (397 KB):

[update] There was a problem with the first demo I posted here, which is discussed below. I've fixed the issue with the stencil-buff, and I've also added a dialog box that lets you pick the screen mode for the demo.[/update]

hoverdemo_fixed.zip (313 KB):


Instructions for demo:

(1) Just extract everything and run the exe
(2) Pick a 3D device & screen mode -- my HAL was faster than my T&L HAL, btw
(3) arrows control yaw & pitch
(4) 'b' is go
(5) 'n' & 'm' control roll (rolling does nothing, though)

I would have made the map bigger except the culling isn't working yet: this map is about 110x80, which is roughly the size I hope to be able to render each frame.

You may get horrible frame rates... I've only tested this on my P733 + GeForce2 (~120fps fullscreen). In any case I went a little overboard on this terrain -- it's too 'busy' and so the LOD is forced too high everywhere.

Edited by - Eric on June 30, 2000 8:44:17 PM

Share this post


Link to post
Share on other sites
I couldn''t get it to run, I got the following errors:
RenderTerrain()>DrawIndexedPrimitiveVB and
Render3dEnvironment Render failed

Do you have HWT&L flags only set? Thats about the quickest thing I can think of, since I tried it on a TnT2.

Share this post


Link to post
Share on other sites
Sorry, I did a pretty half-ass job on the demo. I noticed this morning that I still have the stencil-buff requirement in my enumeration, because previously I was going to use that for shadows. Compounded with this is the fact that I request 16-bit color for full-screen... Stencil-buffs require 32-bit z-buffers, and I don''t think that combination is really supported.

By the way, jaymz, the RGB device should be able to run this thing... if you wanna seem some sweet 2 fps terrain, try disabling your video acceleration before running the exe

Share this post


Link to post
Share on other sites
Tried that, same errors It might be me though, as I am using Dx8 beta...

Share this post


Link to post
Share on other sites
I uploaded a new, fixed demo. The stencil-buff thing may not have been the problem in your case, jaymz, though at least the fixed version will now give the actual system error code for DrawIndexedPrimitiveVB() & other funcs. See my previous post for the download.

I hate to jump to the conclusion that the error you''re getting is due to your Dx8 Beta. On the other hand, others and I have been able to run the demo w/ the RGB device... it does kinda seem like the dx version is the only "variable" here. Anyway, I didn''t want this thread to get sidetracked on debugging my demo;
I started a
thread in "Announcements" about this, so if you, jaymz, or anyone else wants comment on it, that would be the more appropriate forum

Share this post


Link to post
Share on other sites
I tried your new demo ....
i get 5 fps with my system:

PIII-450 ... Riva TNT2 ... desktop-reso ... 1024x768 32bit color ...

it ran in a window of 450x??? pixel ... i forgot ...

when i start it again now i dont see the landscape any more ... dont know why ... it just worked first time i started it

Share this post


Link to post
Share on other sites

  • Advertisement