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

Submitted by Brebion flavien, posted on March 04, 2001

Image Description, by Brebion flavien

In previous IOTDs, many people asked what algorithm Terragen is using to calculate its textures. Since i didn't dare to post YALS (Yet Another Landscape Screenshot), i prefered to send this one (which is a top view of my terrain) with a short description of how i'm texturing it (i don't know if Terragen does the same thing, but the results look quite similar).

First, before you ask:

1. It is realtime rendered, and actually quite fast (there is around 8000 triangles in this frame). I expect 150 fps on a P2-400+GeForce. Brute-force method: no LOD (yet).

2. It is not using a Terragen's texture. Terrain textures are completely procedurally generated.

3. No demo yet, but i'm working on one. Still needs a few weeks of work.

Now, some words about the technic:

I'm using a set of 3 parameters: elevation, slope and exposition/ orientation for each texel. Designers can use a script language to describe how to texture-map the terrain. It is done, as Terragen, with materials layers. To each layer is associated a texture map (grass, rock, mud), some conditions about the elevation, slope and exposition, and for each parameter, a min/max blending coefficient too.

The influence (ranging from 0.0 to 1.0) of a given layer is calculated, for a texel, by interpolating the 3 blending coefficients. Then, we get the final color of the texel with a standard n-blending function.

It is also possible to specify specific texture maps for some texels, as shown with the muddy road in the shot.

A simple script example would be:

Grass {
        Slope {
                angle_min:0             # min angle condition (degrees)
                angle_max:31            # max angle condition (degrees)
                blend_min:0.9           # blending for min angle
                blend_max:1.0           # blending for max angle

Sand {
        Slope {
                angle_min:31            # min angle condition (degrees)
                angle_max:90            # max angle condition (degrees)
                blend_min:0.8           # blending for min angle
                blend_max:1.0           # blending for max angle

        Elevation {
                height_min:0.0          # min height (in meters)
                height_max:10.0         # max height (in meters)
                blend_min:1.0           # elevation blending is identiy

Rock {
        Slope {
                angle_min:31            # note that these are the same
                angle_max:90            # parameters than for sand. Only
                blend_min:0.8           # the elevation condition
                blend_max:1.0           # changes.

        Elevation {
                height_min:10.0         # min height (in meters)
                height_max:10.0+        # max height: above 10 meters
                blend_min:1.0           # elevation blending is identiy
                blend_max:1.0           # too

I let you, as an exercise, imagine what sort of terrain this would result in :)

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.

March 04, 2001, 03:52 PM

nice one :-))

this is exactly how i do terrain-texturing in my engine. i have written an extern application to compute these texturemaps. the results are very promising. do you use an additional noise function (perelin or similar) to disturb the blending values? and how do you compute shadows?


March 04, 2001, 05:10 PM

Lookin' good... reminds me of the TA/TAK landscape...


March 04, 2001, 05:13 PM

Very nice, is that a road or a river? How was that generated?
How would you implement LOD when your engine allows for the camera to look down perpendicular to the XZ?
This is how I picture Peru, though Ive never been there.
Good one.


March 04, 2001, 05:39 PM

Heh, I was working up a similar scripting system for texture generation. :) Looks simple and powerful, always a good combination.

I was going to try to do it all procedurally, to see how it looks. I think it will look good, as landscape textures usually don't have "alot" of detail in them when you are right on top, but the detail texture adds it. So I was going to generate each texture (dirt, grass1, grass2, etc) by a base diffuse texture and some high frequency perlin noise. I would then blend them similar to how you are doing. But I will also blend a number of textures in any one layer using a low frequency perlin noise to give it a broken up appearance ( grass1 * d ) + ( grass2 * ( 1 - d ) ) type of stuff.

Sometime this week I should have it up and running. I just got the RTIN LOD stuff nailed down. Let me tell you, it can help cut the polycound HUGE. I was originally going with 32x32 patches, but now that I see the tri counts, I am going to up it to 64x64 or 128x128.


March 04, 2001, 05:56 PM

I do texturing in the same exact way for my java engine except that I pregenerate my lightmaps at lower resolutions and then scale them to the texture after the texture is generated at run time. I do this because the method I use to generate the light maps takes a good amount of time, where as generating the texture goes pretty quick. It works out great because all that needs to be downloaded to view the applet is the engine, a gray scale light map, and a few tilable textures. The light maps is based on the slope of the terrain and whether or not the sun's rays were blocked by other terrain/level features at the sampled pixel.

By the way, the scripting format you came up with is great, I think I am going to give it a try in my engine, thanks!



March 04, 2001, 07:50 PM

Wowow ! That's very cool image, nice work ! Your generated textures looks very nice as well.
I myself just programmed some kind of crap terrain, but that's just test and now it has only one texture without any blending. However, it looks much better that I've expected.
as you said:
I expect 150 fps on a P2-400+GeForce.
It seems like u have different hardware, so what's your hardware and what results you have ?
Do you apply few layers on whole terrain, or you can that layer apply only in few places? Is this layer is repeatedly applied, or it's applied without repeating(I mean tiling or smth)
And also what size is your terrain?

Brebion flavien

March 04, 2001, 08:52 PM

Thanks for the comments everybody :)

I'm using a detail texture for the above-ground view, to avoid the blurry syndrom. I'm currently playing with the idea to actually use many detail textures, of different resolutions, to improve the quality (one detail texture is common, does anybody used more than one?)..

What you see on the ground is not a river, it's a road. I quickly said a word in the description about it: it is generated from a colored-base texture map which associates colors to materials. So, i basically have a heightmap (to get the height of the texels), and a colormap, to see if the texel must be procedurally generated (with the described algorithm), or taken from a standard texture. That way i can mix procedural and standard texturing in the same terrain, without additionnal polygons.
I haven't implemeneted LOD yet, btw, so can't answer for the XZ plane thing.

There is no shadows in the shot yet. Everything is per-texel lit. I'm playing with the idea to add per-vertex shadows, and since my engine already supports ray casting, it won't be a big deal to code in i guess.

Finally, my development machine is a simple P200 + Vaudoo 2. I get 15 fps for these 8000 tris, but i do not use triangle strips yet. With triangle strips the performance will probably double.
Btw, 150 fps is only 1.2 M triangles per second, and GeForces can reach much higher rates.

The terrain in the shot is 64x64 vertices, with a 512x512 texture. Yes, you can apply only some layers on specific parts of the terrain, using the color-based texture map technic i described above.
Source textures are tiled over the terrain, but with all the per-texel blending parameters, you don't actually see tiling (look at the shot and tell me how many textures were repeated? :))

David Barrett

March 04, 2001, 09:16 PM

Nice... very nice. Great work... just one point; in the lower-right hand corner the colours look a *little* bit off, is this a problem with the image/color-map/engine?

It may not show up on a low camera, but if that was altered it would add another exclamation mark to "Woah!" :)


March 04, 2001, 09:47 PM

"It is also possible to specify specific texture maps for some texels, as shown with the muddy road in the shot. "


March 04, 2001, 11:57 PM

Shadow are very easy to calculate, and look very good even if they are calculated for every textel rather than each vertex, here is the method I use:

while (p.z < swidth && p.z > 0f && p.x < swidth && p.x > 0f && p.y < maxHeight)
if (p.y


March 06, 2001, 03:23 AM

It's late for this question but I need to know what you think about a simple idea. Despite no shadows are calculated, only per texel lightning, the texture looks pretty good.
The current light layer is included in the texture. What about have three or more shadowmap layers separated from the color texture, each one with different sun light positions, and interpolate them to have a realtime illuminated terrain? (The idea comes from the need to be on a terrain the time enough to experiment sun movement.



March 06, 2001, 03:35 PM

That is exactly how I was thinking of doing my landscape engine, and I havn't even read any articles on the subject; I thought texturing dependent on height, slope and orientation. This is just like when I fist started in 3d I thought it would be cool to make a landscape engine with the height read in from a bmp,doh. I also once thought it would be cool to have a grayscale texture blended on the wall texture to simulate lighting,doh, and to my great supprise that had already been thought of. If I had these thoughts 10 years ago I would be working with John Carmak himself.

Brebion flavien

March 07, 2001, 08:08 AM

Danthalas: i guess it could work, but there would probably be artifacts due to the interpolation of shadows when you don't use enough shadow layers. IMO, the biggest problem is that you'll have to add one pass per layer, so it will slow down everything. Would be interesting to test.

D.P.: J.Carmack does not develop landscape renderers, so i doubt you'd be working with him now :)

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