Not logged in, Join Here! or Log In Below:  
News Articles Search    

Submitted by Ohad Eder Pressman, posted on October 14, 2000

Image Description, by Ohad Eder Pressman

I decided to get going with OpenGL, it's about time. I started playing with height maps and this is what came out after a few hours. Apart from taking documents like "Continuous LOD Terrain Meshing Using Adaptive Quadtrees", "siggraph96 - Real-Time, Continuous Level of Detail Rendering of Height Fields" and printing them at work so that I can learn something new., I'm thinking of the whole Texturing mechanism. Should my terrain contain more than 1 texture, how do I blend the textures ? I'm investigating into this at the moment.


Ohad Eder Pressman

Image of the Day Gallery


Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

October 14, 2000, 11:45 AM

It may be called experimenting, but it looks fantastic!

Good work!

Ohad Eder Pressman

October 14, 2000, 11:52 AM


If anybody is wondering, this shot was taken 'under' the terrain, yet above 'sea-level'.


October 14, 2000, 12:20 PM

And I thought my monitor was upside-down :)

Looks cool, although a view from above would have been less confusing, but maybe that's what's making it unique :)

- MK42


October 14, 2000, 12:31 PM

It reminds me of the 'cavern' levels from Magic Carpet 2...

Where are you with the texturing? I've been playing with one big one, but it really doesn't seem like the Right Thing, especially if you're limited to 256x256 textures.

Dynamic generation looks interesting, and the last IOTD from Kurt sparked some ideas about shaders on heightmaps... anyone done anything in that direction?

Ohad Eder Pressman

October 14, 2000, 01:39 PM

Regarding texturing...

I'm currently doing something very lame, i.e. drawing the entire terrain twice each time with different texture/blending. This is ofcourse not a solution.

I thought of doing this using multi-texturing, is it possible to specify that the combination between various texture layers be the alpha specified for the vertices or something alike (in OpenGL), if yes can someone point me to something about this ?

If I recall correctly the GeForce can handle up to 4 textures in a multi-texturing environment, this can be quite an adequate solution.

Too many questions :)

Ohad Eder Pressman

October 14, 2000, 01:40 PM

My connection (experimental ADSL) can't send out more than 512-bytes, so I need to divide my comments :)


What interested me too was the water section. Is it worth clipping the floor to the terrain and finding the n-gons that constitute the floor, or is it sufficient to just draw a large quad over the terrain at water-level (which is what I do now). And how do I get a smooth transition from water to terrain ?


October 14, 2000, 02:13 PM

1. GeForce can only handle 2 textures in a single pass.
2. You can probably combine them by letting the first texture stage use (alpha) and the second use (1-alpha) of the source texture. Have never done this, though.
3. Check out this page:

or the beginning of this series:

it covers a basic approach for your problem.

- MK42

Douglas Cox

October 14, 2000, 02:30 PM

Regarding texturing: Since hardware is starting to come out that supports it, and DX8 will make it easy to use, why not think about using volumetric textures for terrain.

Assuming I understand it correctly, you basically combine say N layered textures (sand, grass, rock, etc) into a single volumetric texture. Then you specify a third texture coordinate that determines which texture to use at that vertex.

Doing this means you could precalc the 3rd texture coords based on the terrain height/slope and not have to worry about blending/combining textures at runtime. Plus it's easy to deform the terrain (make craters) and change the xyz + 3rd txr coord around the crater.

Now if only nVidia will release a card that supports them..

Ed Fear

October 14, 2000, 03:26 PM

I'd heard the term volumetric textures before never understood what it meant. If you're right (and I have no reason to doubt you) they sound great, and an easy way to merge textures.

Sorry... this post is a bit pointless isn't it? :)



October 14, 2000, 05:07 PM

Most cards which do multitexture will also allow you to specify the blending among them using vertex alpha. The trouble is, you will also want vertex shading on top of the multitexture; most cards will not do this. :(

I think both GeForce and Radeon will do it, but not Voodoos or TNTs.

Check out the nVidia website for their docs on OpenGL extensions.

Ohad Eder Pressman

October 14, 2000, 05:25 PM

Is there a solution then ? Other than having a huge pre-belnded texture, or a set of smaller pre-blended tileable textures as in the egreter tutorial ?

Multitexturing allows only two levels, and disables lighting (according to what's written above).

The 'escape' landscape demo looks nice and it has just 1 texture + lighting + fog, but you can tell that it lacks something...

Is there something else totoally different ?

I just looked again at the latest Unreal technology demo, their terrain looks like it consists of at least 2-3 textures blending together all over the place...


October 14, 2000, 05:39 PM

I think Sweeney said in an interview, that they have a layered texture system with alpha channels controlling the combination of these. This data is probably combined to create one HUGE texture, from which the visible parts are cached in memory ... kinda hard to explain, but it might be an idea.

Of course, I don't have a clue what they do, but this might be an option.


John van der Burg

October 14, 2000, 06:27 PM

Yes, terrain textures are combined.
It works like photoshop where you at the end flatten the layers into one final layer.
And ofcourse you can also project decals on the terrain to make it look even cooler.

- John


October 14, 2000, 11:07 PM

You mean vertex lighting? Yes, Voodoo and TnT will let you do that with multitexture. The lighting calcs may not be accelerated but it will certainly let you do it.


October 14, 2000, 11:14 PM

One of the discussions on the 3dgamedev algorithms list of late has been about terrain texture splatting. The idea being you have a set of tileable textures that you alpha on (with a low res alpha texture). You also check which tiles have references to which textures, to reduce the number of passes.

zed zeek

October 15, 2000, 12:56 AM

i recently stuck code on me site that blends 2 textures together based on a third textures greyness values under the env_combine extension NOTE this doesnt work with lighting , ill be doing a version soon that does

Phil Carlisle

October 15, 2000, 01:14 PM

I'll have some info on texture synthesis for landscapes in an up coming article (either here or on gamasutra or wherver).

Basically right now I do pre-computed alpha blending of multiple textures based on height and slope, this produces a texture per
landscape "patch", I also pre-calculate the lighting into the texture on a per-texel basis. Its kind of slow, but its a pre-processing step so it doesnt matter.
The thing thats most important is that the alpha has "noise" introduced into it so that you dont get a definite transition, perlin type noise is good for this
sort of thing.

There are many many other things I am adding, but right now I have to work on more idea's for the geometry (tried ROAM, doing LOD and CLOD, also working on some more idea's).

Ive also been looking at REAL landscapes to get some idea's. So we'll see how they turn out.

Its going to be a bit of a tradeoff though, I'll basically have a few switchable solutions that can be turned on and off so that I can scale the solution to suit
the available texture ram and processor etc.

Its fun to try though! dont ya think?



October 16, 2000, 12:15 AM

Texturing: Here is what I've done in the past, and what is used a bit, I believe:

I generate 1 unique texture for the entire landscape. How this is done is by programmatically blending n number of textures based on such things as height of the point, the slope of the point, etc. So if a point is on a 45 degree slope, you would blend equally .50 grass and .50 rock. Of coruse there is alot of room to improve this. Since you may end up with a rather large texture ( 2048x2048 ), I break it up to go along with my landscape patches (128x128, for example). Then this smaller patch gets loaded when I draw a landscape patch. Alot of people use detail textures over the main landscape to give ground up close more detail ("texture" for the texture). MW4 does this well. To not have terrain far away use the detail texture, several techniques are used. An easy one is to generate mip-maps that alpha fade the texture to nothing.

Hope this helps.


October 16, 2000, 12:21 AM

I should have read Phil's post first :) I forgot lighting also. I baked the lighting in to, but I thought about using a lower sampled lightmap as a seperate pass, so you could do real-time light transitions (day/night). Just generate part of the lightmap during each frame.

I messed with ROAM, etc. But from what I've heard is that today's cards are STARVING for triangles, so using the CPU to remove triangles in ROAM is stalling the pipeline. I did a static type of ROAM thing, so it removes detail from areas that dont need it (flats, etc), but leaves detail in where it does. On a terrain mesh that would have over 2 million tris (1024x1024), I could get it down to 8000 tris while it still looked very good. This is all done at the same time the texture is generated. Then I save off the optimized mesh and texture and I am ready to go.

Phil Carlisle

October 16, 2000, 05:29 AM

Its definitely been my experience that ROAM isnt an optimal way to deal with landscapes. My current plan is to use either discreet levels of detail
on a grid patch basis, or use CLOD on the same basis, using strips/fans as much as possible and creating CVA's etc as well. Basically this is
static geometry so make it as efficient as possible and as near to the card as possible.

Texture wise I still have a way to go. I need to try vertex colouring over the landscape too. But i dislike doing things per vertex because you always
get a patchwork quilt type of effect.



October 16, 2000, 11:07 AM

Is it my imagination or does half-life do something with random textures? You specify a texture set or something, and it randomly tiles in a few. I thought I read that somewhere, anyway.

Ohad Eder Pressman

October 16, 2000, 05:25 PM

After you generate yourself a huge texture and cut it up to many small textures, do you simply upload them all ? doesn't this take up too much space ? and doesn't it annoy the card that you switch between textures every 'patch'.

Another question, do you "glBegin(GL_TRIANLGE_FAN); glEnd();" for each 'patch', is this slow ? or is it meaningless to the card ? I compare this to the fact that calling DrawIndexedPrimitive() in DX is slow if you do it too often in a frame, and you'd have to call glBegin() quite a large amount of times...

Ohad Eder Pressman

October 16, 2000, 06:33 PM

I'm trying to put in multi-texturing

here's what I do :






Ohad Eder Pressman

October 16, 2000, 06:34 PM

512 byte limit, sorry, message continues...

Terrain::Render() uses :

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, p->s, p->t);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, p->s*10, p->t*10);
glColor4f(1.f, 1.f, 1.f, p->blendFactor);
glVertex3f(p->pos.x, p->pos.y, p->pos.z);

it's not working, what am I doing wrong ?

This thread contains 24 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.