Blending Terrain Materials

From Blue Mars Developer Guidebook

Jump to: navigation, search
There are security restrictions on this article

back to Tutorials

Because there are so many different settings it can be difficult to get your terrain materials to blend properly, which often creates jagged edges between materials. This tutorial will show a way to get your materials to blend well enough that you can paint using different colors and still maintain a smooth look.

File:TerrainBlendingSetup.jpg

First a little setup, I always work with HDR turned off to begin with (open console, type r_hdrrendering 0, hit enter). This will allow you to see whether your materials are too bright or too dark. You want to try to keep them somewhere in the middle. If you have a time of day file you plan to use, this is a good time to import it so that you won't have to tweak your materials later when you do.

Materials

1. Set up your materials, for this example I just created 2 materials named terrain1 and terrain2, using the terrain.layer shader.

2. Colors

  • Make sure your Diffuse Color is 127,127,127. This is best practice for all materials since it means this material will not brighten or darken the scene when HDR is turned on. You'll notice that I use a lot of gray in this example. I almost always start with gray and then add color to taste when the technical aspects are set up.
  • Next set specular color to black. This is the best place to start so that you aren't fighting lighting settings when trying to tweak your materials.

3. Texture Maps

  • You want a diffuse texture, usually to start I just use a small gray texture, this one is 8x8 and filled with color 127,127,127, no alpha. You can replace this later when your settings are close to final so you will know how to adjust your texture.
  • You'll want to have a normal map, this is used to give more detail to your terrain when you are at a distance. You should plan on this map being displayed with minimal tiling, so it should just be giving basic geometry information. This normal map is 256x256, you can go higher depending on your needs.
  • Last you need a detail map. A detail map is another normal map that will give you more information when the camera gets close. This can tile and should contain more detailed information that the normal map. This detail map is 256x256, you can go higher on this map as well.

4. Go to Shader Generation Params and turn on Detail Bump Mapping. This will give you some shader params to work with to effect how your detail map displays.

5. Shader Params

  • Detail Texture Strength is part of all terrain.layer materials. This determines how much of layer texture will be blended with your material. You'll want to tweak this later, but for now leave it at 1.
  • Detail Tiling U and Detail Tiling V, allows you to tile your detail bump map up to 32 times in each direction.
  • Detail Bump Scale determines how strong the detail bump map will be when it is visible.
  • Detail Blend Amount, this is where the magic happens for terrain. This allows you to multiply the color of your material by the color of the Detail map. We'll get back to this later.

Layers

6. Now that you have your materials ready to go it's time to set up your layers. I do my materials first for the reason that the layer editor is a bit touchy. If you create a layer that has the same material as an existing layer your layers can get corrupted (known bug, it's on the fix list). Also you should never delete the default layer. Just set it up how you want it and continue to add your own layers. For this example I added a gray 8x8 uncompressed texture to the default layer. File:Layertexture127 127 127.zip

7. Assign material "Terrain1" to the default Layer. Remember to do this before creating the second layer.

8. Create a new layer, assign a layer texture (here I used gray again) Note: You can rename this layer now if you want.

9. Add your second material (terrain2 in this case) to NewLayer.

10/11. You may or may not want to set your detail scale yet but I'll point it out anyway. The terrain.layer shader DOES NOT take into account UV settings for diffuse and normal map that are set in the material editor. Detail scale is the only place you can tell your material how many times to tile across the terrain. Note this IS NOT how you tile the detail map. Detail map tiling was set up in step 5. This setting is number of times the whole material is tiled per meter. So 1 will give 1 tile per meter, .01 will give one tile per 100 meters.

12. Time to test. Got to Terrain>Layer Painter and choose a smallish brush. As a note here, larger brushes will generally result in blockier painting, smaller brushes are better to test with.

13. Make sure that Paint LayerID is selected.

14. Now paint a test area with your different layers. Note the Red box here, you can change your paint color using this. The paint color will reset each time you change layers unless you chose "to Layer" which will save that color for each time that layer is selected. I usually start with gray (as usual) so that I can reduce the number of variables to tweak. I chose yellow and red here just as an example of how it will blend when set up.

Tweaking

At this point you most likely have some seams between your terrain layers creating a light gray or white jagged line. We need to get rid of that. Go back to Shader Params in the material editor(see number 5). We're interested primarily in DetailTextureStrength, Detail Bump Scale, and Detail Blend Amount.

File:TerrainBlendingBad.jpg

So to begin with, adjust your detail bump scale on both textures so that it has the look and feel you want for your terrain. The higher you set it the darker your overall material will feel (because it's getting more shadow info from the detail bump map). Generally I go with a scale between 3 and 4. For this example I set both materials' detail bump scale to 5.

File:TerrainBlendingDBScale5.jpg

Now you adjust your Detail Blend Amount until the 2 materials blend properly. In this example I have Terrain1 at .525 and terrain2 at .545.

File:TerrainBlendingFinalGray.jpg

Finally start adding in color. I usually start by adding in a terrain layer texture (See step 6), paint a little. Note you want to paint with terrain color set to gray like in #14. Make adjustments to Detail Blend Amount. Then add terrain layer texture to the next layer, paint, adjust. Usually by now everything is working fine so I'll move on to adding a diffuse texture to the material if you want one. Remember that your diffuse texture should be fairly neutral so it doesn't throw off the color profile of the scene. Mostly you don't want any extremely bright or extremely dark textures. . Then adjust as needed.

File:TerrainBlendingLayerTextures.jpg

Now the technical stuff is set up, you can set your specularity and turn back on HDR (~ r_hdrrendering 1) to see how it all turned out.

Problems with this wiki page? Contact us either by: Support Email or Support Ticket System

Blue Mars Guidebook Privacy Policy
Blue Mars Guidebook Community Guidelines

Personal tools