Torque Terrain Procedural Texturing Tutorial
by Keith Sponburgh · 02/01/2002 (9:06 am) · 18 comments
Ok, here is the re-write since the original tutorial was lost. This was written using the latest release build of TGE (1.3) but as far as I can recall it shouldn't be any different for older versions. Depending on how the terrain blender evolves this may become useless.
Getting Started:
Before we start you'll need to have TGE installed and the original TGE mission editing tools available. I suggest using the demo as released and running the starter.fps mod as that is what I did.
The terrain textures used in the tutorial are available here (~600kb). These are optional and any suitable textures will work just as well for the tutorial.
Getting into the editor:
First step is to fire up the mission editor (F11) and switch to the terrain texturing mode (F8). I also prefer to be in "free camera" before starting the editor but it isn't required. If you're suing starter.fps and in the stronghold mission you should be looking at something like this.
1. Removing the old textures
First we're going to select our new textures. On the right side of the screen you should see a list of materials (textures) available for the blender to use. Select each of those, one at a time, and delete them. We're going to add four of our own textures instead.
2. Selecting your new textures
Now we're going to add in our new textures. Please note, the first texture you select will be applied to the entire terrain surface and all other textures will be applied on top of it. So make sure you select a texture that will work well anywhere on the map. In our case we're going to add gl_grass1 first since it is a basic grass texture, the remaining textures (gl_grass2, gl_dirt1 and gl_rock2) can be added in any order.
First, click on the Add Material button. Now add gl_grass1.jpg, followed by gl_grass2.jpg, gl_dirt1.jpg and gl_rock2.jpg. I'm not going to cover editing the materials.cs file here but you do not need it for this tutorial.
3. Configuring the terrain masks
3a. Grass 1
For the first texture, gl_grass1.jpg, we want to use a slope mask only. Highlight gl_grass1 in the material list, click on "Placement Operations" and select "Place by Slope" from the list. Do not delete fractal distortion from the list of operations. Highlight the "Place by Slope" operation in the list and you should see the mask settings in the upper right corner of the editor screen. With the slope mask the points to the left are for level surfaces and the right points are for increasing degrees of slope. For now follow my example and move the first two points all the way up and the remaining points all the way down. This means our grass texture will be most prominent when the slope is lowest and non-existent on steeper surfaces.
3b. Grass 2
Next we want to select gl_grass2 from the material list. Click on "Placement Operations" and select "Place by Height" and "Place by Slope." Highlight place by height and adjust the control points so the two leftmost points are all the way up and the remaining points are all the way down. You should also un-check "Fractal Distortion" for this mask since we are using multiple masks. Setting up the points this way will make gl_grass2 most prominent at higher altitudes and non-existent in the lower areas on the map. Now, highlight place by slope and adjust the control points so the first three are all the way up and the last three are all the way down and leave fractal distortion checked in this mask. This will cause gl_grass2 to only be use on flat and gently sloped surfaces and the fractal distortion will have the effect of mixing it up randomly with the other textures. In our tutorial this means you will have most gl_grass1 with gl_grass2 on higher ground but some patches of gl_grass1 (which has no height mask) will be present at all altitudes for some variety.
3c. Dirt 1
Now we can add some dirt to the mix, select gl_dirt1 from the list and click on "Placement Options" and select "place by height." Now, highlight place by height and move the first three point to the top, the last three points to the bottom and un-check fractal distortion. This will make dirt the most prominent texture at low altitude and ensure that it fills in every space not occupied by gl_grass1 or the rock we're going to add next.
3d. Rock 2
Now for the rock texture, we have gl_rock2 because my gl_rock1 texture is more of a gravel texture and wouldn't work well here. So, select gl_rock2 from the material list, click on "Placement Options" and select Place by Slope. Highlight place by slope and move the first three points all the way down, the last two points all the way up and the fourth point slightly down from the top. This will make the rock texture most prominent on steep slopes, non-existent on level surfaces and gentle slopes and somewhat visible on medium slopes. Make sure you un-check fractal distortion as well so our rock slopes are very rocky looking.
If you haven't done so already click on the "Apply" button to see the end result.
Now that you have the procedural textures in place you can go through and manually touch-up spots such as the dirt patch around the huts as seen in the original screen shot.
Hope this helps,
Keith
Getting Started:
Before we start you'll need to have TGE installed and the original TGE mission editing tools available. I suggest using the demo as released and running the starter.fps mod as that is what I did.
The terrain textures used in the tutorial are available here (~600kb). These are optional and any suitable textures will work just as well for the tutorial.
Getting into the editor:
First step is to fire up the mission editor (F11) and switch to the terrain texturing mode (F8). I also prefer to be in "free camera" before starting the editor but it isn't required. If you're suing starter.fps and in the stronghold mission you should be looking at something like this.
1. Removing the old textures
First we're going to select our new textures. On the right side of the screen you should see a list of materials (textures) available for the blender to use. Select each of those, one at a time, and delete them. We're going to add four of our own textures instead.
2. Selecting your new textures
Now we're going to add in our new textures. Please note, the first texture you select will be applied to the entire terrain surface and all other textures will be applied on top of it. So make sure you select a texture that will work well anywhere on the map. In our case we're going to add gl_grass1 first since it is a basic grass texture, the remaining textures (gl_grass2, gl_dirt1 and gl_rock2) can be added in any order.
First, click on the Add Material button. Now add gl_grass1.jpg, followed by gl_grass2.jpg, gl_dirt1.jpg and gl_rock2.jpg. I'm not going to cover editing the materials.cs file here but you do not need it for this tutorial.
3. Configuring the terrain masks
3a. Grass 1
For the first texture, gl_grass1.jpg, we want to use a slope mask only. Highlight gl_grass1 in the material list, click on "Placement Operations" and select "Place by Slope" from the list. Do not delete fractal distortion from the list of operations. Highlight the "Place by Slope" operation in the list and you should see the mask settings in the upper right corner of the editor screen. With the slope mask the points to the left are for level surfaces and the right points are for increasing degrees of slope. For now follow my example and move the first two points all the way up and the remaining points all the way down. This means our grass texture will be most prominent when the slope is lowest and non-existent on steeper surfaces.
3b. Grass 2
Next we want to select gl_grass2 from the material list. Click on "Placement Operations" and select "Place by Height" and "Place by Slope." Highlight place by height and adjust the control points so the two leftmost points are all the way up and the remaining points are all the way down. You should also un-check "Fractal Distortion" for this mask since we are using multiple masks. Setting up the points this way will make gl_grass2 most prominent at higher altitudes and non-existent in the lower areas on the map. Now, highlight place by slope and adjust the control points so the first three are all the way up and the last three are all the way down and leave fractal distortion checked in this mask. This will cause gl_grass2 to only be use on flat and gently sloped surfaces and the fractal distortion will have the effect of mixing it up randomly with the other textures. In our tutorial this means you will have most gl_grass1 with gl_grass2 on higher ground but some patches of gl_grass1 (which has no height mask) will be present at all altitudes for some variety.
3c. Dirt 1
Now we can add some dirt to the mix, select gl_dirt1 from the list and click on "Placement Options" and select "place by height." Now, highlight place by height and move the first three point to the top, the last three points to the bottom and un-check fractal distortion. This will make dirt the most prominent texture at low altitude and ensure that it fills in every space not occupied by gl_grass1 or the rock we're going to add next.
3d. Rock 2
Now for the rock texture, we have gl_rock2 because my gl_rock1 texture is more of a gravel texture and wouldn't work well here. So, select gl_rock2 from the material list, click on "Placement Options" and select Place by Slope. Highlight place by slope and move the first three points all the way down, the last two points all the way up and the fourth point slightly down from the top. This will make the rock texture most prominent on steep slopes, non-existent on level surfaces and gentle slopes and somewhat visible on medium slopes. Make sure you un-check fractal distortion as well so our rock slopes are very rocky looking.
If you haven't done so already click on the "Apply" button to see the end result.
Now that you have the procedural textures in place you can go through and manually touch-up spots such as the dirt patch around the huts as seen in the original screen shot.
Hope this helps,
Keith
#2
10/02/2004 (1:07 pm)
the link is dead rigth now ---
#3
11/15/2004 (10:03 pm)
UGH GG FIND AND HOST THIS TUTORIAL!
#5
04/01/2005 (1:59 pm)
404ed! :(
#6
EDIT: Just checked and it's not part of his tutorials, I'll re-write it this week.
04/19/2005 (12:07 pm)
Sorry about that guys, the original web host crashed and lost the tutorial and I haven't found a good backup of it yet. Desmond Fletcher had a copy of it at one time, if it's not still included in his tutorials I'll re-write it. It probably wouldn't hurt to re-write it anyway considering how much Torque has evolved since then. Email me if I haven't fixed this within a few days ;)EDIT: Just checked and it's not part of his tutorials, I'll re-write it this week.
#7
04/20/2005 (9:59 am)
Unfortunately, I missed out on this tutorial... a re-write/update for TGE 1.3 would be great!
#8
04/22/2005 (8:14 am)
It's almost done and as an added bonus since the Chronos V project died a while back I can throw in those texture for free, for what it's worth anyway. ;)
#9
Do you know how to use the "Terrain Terraformer" as well? It might be nice if you covered that too in your updated tutorial, unless you already know of a good one out there somewhere. The "official" docs kinda do a bit of hand-waving and say, "Just play with it and see what you can do... it's too complicated to explain". 8-)
04/22/2005 (9:04 am)
Sounds great Keith! Thanks for doing this!Do you know how to use the "Terrain Terraformer" as well? It might be nice if you covered that too in your updated tutorial, unless you already know of a good one out there somewhere. The "official" docs kinda do a bit of hand-waving and say, "Just play with it and see what you can do... it's too complicated to explain". 8-)
#10
04/22/2005 (9:04 am)
Oh... and thanks in advance for contributing the terrain textures!
#11
04/22/2005 (9:07 pm)
It will be up tomorrow, would have been up tonight but my dog ate it (ok, not exactly but we picked up a new dog today and that consumed most of my evening). I'm not going to cover the terraformer at all in this tutorial, just the procedural texturing. I don't recall ever seeing any good tutorials on it before, most of the terrain tutorials revolved around heightmaps. I haven't messed with terrain in about 6 months, we've moved onto using the TSE and our current project is a space combat sim and obviously lacking a terrain block ;)
#12
Anyway, I tried your steps and I'm a bit confused as to the results. It seems easy enough to understand, but the procedural texturing doesn't seem to work in a predictable way for me.
I tried a simplified version of your example:
gl_grass2, placement by slope, bottom 2 CPs max'd, top 4 points min'd, no fractal distortion
gl_rock2, placement by slope, top 2 CPs max'd, bottom 4 points min'd, no fractal distortion
"Canyon" fractal from the terraformer
What I'd expect is to see the plateaus and valleys covered in grass, and the cliffs in rock. What I get is pretty much a random mix of grass/rock everywhere.
04/24/2005 (9:51 pm)
Okay... second try (for some reason, occasionally, I type a long message, click Post Comment, and it shows me the thread again without my post... and my post seems to be lost completely... grrrrr).Anyway, I tried your steps and I'm a bit confused as to the results. It seems easy enough to understand, but the procedural texturing doesn't seem to work in a predictable way for me.
I tried a simplified version of your example:
gl_grass2, placement by slope, bottom 2 CPs max'd, top 4 points min'd, no fractal distortion
gl_rock2, placement by slope, top 2 CPs max'd, bottom 4 points min'd, no fractal distortion
"Canyon" fractal from the terraformer
What I'd expect is to see the plateaus and valleys covered in grass, and the cliffs in rock. What I get is pretty much a random mix of grass/rock everywhere.
#13
In any case, make sure you have some texture "assigned" for each of the six points if they all use the same masks, such as placing by slope. Or, in your case with only two textures you should be able to cheat and apply the rock as the first material, placing by slope with all six points at the max value and then placing the grass as the second material again using placement by slope with only the first two (or even three) points at max and the remainder at min. That would ensure the rock texture is everywhere but it should be completely covered by grass on lower slopes. Maybe you could try your method again using the Stronghold mission I used for the tutorial and see if you can get the desired results, if so play around with the terrain teraformer a bit.
04/25/2005 (7:01 am)
Try it again with gl_grass2 having the left two point at max the the right four at min and gl_rock2 having the left two at min and the right four at max. If I understood your explanation correctly, of the six points you were only using the left two and the right two. Also, with slopes in particular, depending on your terrain you may not have any that are steep enough to register as the two left points or any that are level enough to register as the two right points. What you are probably seeing is the blender mixing up roughly equal amounts of each texture at the points where neither of them are prominent enough to completely cover the other.In any case, make sure you have some texture "assigned" for each of the six points if they all use the same masks, such as placing by slope. Or, in your case with only two textures you should be able to cheat and apply the rock as the first material, placing by slope with all six points at the max value and then placing the grass as the second material again using placement by slope with only the first two (or even three) points at max and the remainder at min. That would ensure the rock texture is everywhere but it should be completely covered by grass on lower slopes. Maybe you could try your method again using the Stronghold mission I used for the tutorial and see if you can get the desired results, if so play around with the terrain teraformer a bit.
#14
copland.udel.edu/~ed/tge/terrain.html
04/25/2005 (12:05 pm)
Okay, I did some more tests and put the results here:copland.udel.edu/~ed/tge/terrain.html
#15
04/25/2005 (5:08 pm)
Ah, I see the problem, the terrain map (lower left corner) hasn't updated to the new terrain you have defined. It's a bug in the editor that I was able to work around by going back to each mask and moving one point to a new location and then back again. When you do this watch the mini map in the corner, if the image changes it should be updated for the new terrain.
#16
As far as I understand it, the mini-map show the "contribution" of the current "Place by" operation on the texture placement (basically, just a heightmap of the settings you've chosen, and it changes each time you move a control point). The problem appears to be that the placement algorithm is not reading the actual terrain heights and slopes to compute the "map" for each operation. You can see this behavior very well if you take the "Flatten" brush and flatten a large section of the terrain, and then try to get the procedures to "recompute" the texture pattern... which for some reason, doesn't work... you get the exact same texture placement on the new terrain shape.
04/26/2005 (6:42 am)
I don't think that's the problem with my simple example... I've moved a control point in each of the Place by Slope panels and then pressed Apply and it has no effect on the rendered terrain. :-(As far as I understand it, the mini-map show the "contribution" of the current "Place by" operation on the texture placement (basically, just a heightmap of the settings you've chosen, and it changes each time you move a control point). The problem appears to be that the placement algorithm is not reading the actual terrain heights and slopes to compute the "map" for each operation. You can see this behavior very well if you take the "Flatten" brush and flatten a large section of the terrain, and then try to get the procedures to "recompute" the texture pattern... which for some reason, doesn't work... you get the exact same texture placement on the new terrain shape.
#17
So the problem seems to be that the texture placement code is not evaluating the terrain for changes, and thus it's not using the correct height/slope for it's calculations...
Is there a console command I can type in that will cause the texture placement code to "refresh" it's internal structures or whatever with the current state of the terrain?
Thanks,
Ed
04/26/2005 (6:52 am)
I added another shot to the page linked above that shows what happens if I alter the terrain, then move the control points a bit and click Apply...So the problem seems to be that the texture placement code is not evaluating the terrain for changes, and thus it's not using the correct height/slope for it's calculations...
Is there a console command I can type in that will cause the texture placement code to "refresh" it's internal structures or whatever with the current state of the terrain?
Thanks,
Ed
#18
Ahhhhhh... and if I save and reload the original mission I was working on in the screenshots, then go into the texture placement GUI and move a control point and click Apply, it's all magically fixed! Yay!
Okay... so the key tidbit of info. we need is... how do we get the terrain texture placement code to "refresh" itself with the "actual" terrain shape after we sculpt it with the terrain brush and want to see how the texture placement is looking? I've looked through some of the editor script files and nothing obvious pops out at me (no special key binding called "RefreshTerrainToTexturePlacer" or such)...
If nothing else, we're going to get a better tutorial out of all this... LOL
Thanks again Keith!
Ed
04/26/2005 (7:12 am)
Ah... here's a little tidbit... if I go back to the terraformer and regenerate the canyon (just click Apply without changing anything)... and then go back to the texture placement GUI... and slightly move a control point, the mini-map refreshes immediately to be the correct image based on the new canyon terrain.Ahhhhhh... and if I save and reload the original mission I was working on in the screenshots, then go into the texture placement GUI and move a control point and click Apply, it's all magically fixed! Yay!
Okay... so the key tidbit of info. we need is... how do we get the terrain texture placement code to "refresh" itself with the "actual" terrain shape after we sculpt it with the terrain brush and want to see how the texture placement is looking? I've looked through some of the editor script files and nothing obvious pops out at me (no special key binding called "RefreshTerrainToTexturePlacer" or such)...
If nothing else, we're going to get a better tutorial out of all this... LOL
Thanks again Keith!
Ed

Torque Owner Keith Sponburgh
The control points vertical position will determined the transparency of the texture at that point with the bottom being minimal and the top being the maximum. I'm pretty sure it's a 0-100% setup, but don't quote me on that.
The six points, from left to right represent the various stages. In the height filter these are each equal to 1/6 of the total terrain height (from the lowest point to the highest point) with the left being the lowest and the right being the highest. In the slope filter each of the six points are varying degrees of the slope with the left side being flat (0 degree) and the right side being vertical (90 degree). It doesn't seem to change anything if you adjust the number of control points, at least it didn't last time I checked. However, 6 should be plenty and I don't think there is a need for any less than that either since it's not used for any "real-time" purpose in the game.
I haven't used the water level filter (no maps with water for me yet) and the fractal settings will be easy to figure out if you play with them a bit.
Hope that helps,
Keith