Advanced Texture Editing

Dynamic Parameters

In the last part of the tutorial, we took a look at the possibility of creating multiple materials, each of which might be potentially very complex, and distributing them on our terrain using the power of the Material Gradient Driver. The resulting effect, once completed, should have looked something like this:

Lovely, I'm sure you'll agree, but the distribution of materials bears no resemblance to the terrain beneath it. This may be the effect that you are looking for (remember that you can texture other things apart from terrain with the texture editor eg: 3D objects), but in the case of terrain texturing it would be nice to be able to locate the materials by some feature of the terrain, such as elevation or slope.

Guess what? The texture editor gives us these options (and more!), so that's what we'll take a look at in this part of the tutorial.

You should have saved your finished component to disk for use in this part of the tutorial, but if you didn't then you can download my version here. Download the zip file and extract it to your WCSContent:Landcover folder. Now we're ready to begin again.

1. Run WCS and locate and load your GroundCover.proj file.

2. Select Land Cover task mode and expand the Ground Effects group in the s@g.

3. Double click on the GroundCover Ground Effect to open its editor, and select the Material tab. You should see something like this:

4. First we want to reset any changes you may have made to the ground Effect while experimenting in the last stages of the last part of the tutorial. Click the component Gallery icon on the right hand edge of the Ground Effect Editor Window. The Component Gallery will Open.

5. Locate the Ground Effect Component saved in the last part of the Tutorial (it should have been called Ground Cover Ground), and double click on it to load it.

6. Next we need to is to disable the textures that we applied to each of our materials. "But we've just spent ages assigning them, why disable them now? Have we just wasted our time?" I hear you cry. The answer goes something like this: Firstly, disabling the textures will result in faster test renders, and given the choice of images we have, will make the distribution of materials more obvious. Secondly, we are only disabling the textures, not deleting them, so our settings will be stored. If we want our textured Materials back (and we will do at some point) we need only to re-enable them. To disable the texture for our Grass material, click on the button to the left of the diffuse color well, and select "Disable Texture" from the popup menu. The button should turn into something that looks like this: . This tells us that a texture is assigned, but disabled. You can re-enable it at any time by clicking on the button again and selecting "Enable Texture" from the popup menu that appears.

7. Repeat the technique for the Mud and Rock Materials.

8. Do a quick test render. You should get something that looks like this:

Compare this to the image of our textured component (at the top of the page) and you'll see the distribution patterns are identical, but the second is a clearer representation, if a little unnatural in its coloration.

9. Select the Material Gradient & Driver tab, click on the icon and select "Edit Texture" from the popup menu. This should take you into the Texture Editor interface, a familiar sight by now. Remember that this interface is showing us a series of values represented as a pattern - there are no color controls, since we are only using this texture to "drive" the distribution of the materials in our gradient. Your Texture Editor interface should look like this:

10. Click on the texture element drop down list to select a new texture element to replace the Fractal Noise pattern we are using at present. Scroll down the list until you locate Dynamic Parameter and select it as your texture element:

You will see your Texture Editor interface change to reflect your choice:

The default setting is to use Elevation as the driving terrain parameter. You'll notice two boxes above the one marked Elevation, labeled Input Low and Input High. Before we go any further, a brief explanation of how this interface works is necessary:

11. If you remember back to when we were looking at Remap Functions in Part 4 of the tutorial, we accepted a process where one value was remapped using a formula, to another value which was used to generate a visual effect or pattern. The Terrain parameters are similar in that they take an input value, such as elevation in meters or slope in degrees from horizontal, and map them to a series of values defined by you (in this case a materials gradient from 0 to 100%). Important Note: the input values will not always range from 0 to 100, and the output values will never exceed that range in either direction, but may be smaller, should you choose to define it that way. For example: it is conceivable that you might have a range of elevations from 1000m to 2500m mapped to a range on the gradient from 13% to 89%.

12. Having probably confused everyone with that explanation, maybe we should have a go, just to see what happens. Don't change the default values, and do a quick preview render of your Overhead camera. If you don't have an Overhead Camera defined, right click in an empty matrix cell and from the menu that pops up, select View...GroundCover Overhead. You should end up with something that is all green:

13. What is happening? Well, WCS is looking at the elevation at each point on the terrain and mapping that to a point on our gradient. Our gradient runs from 0 to 100, and elevation values in our driving texture run from 0 to 1000, so elevation in this case is being directly mapped to the gradient colors - 100m elevation=10% of the gradient's length. So why have we not got any rock material showing (and virtually no mud either)? Open your database editor, select the Extent Tab, and make sure your DEM is selected:

14. You should be able to see the maximum and minimum elevations of your terrain in the boxes marked Max El and Min El. We can see that the elevation range is 45m to 99m. This is not the range we gave to the fractal landscape generator all that time ago, in Part 2 of the tutorial! In fact, we defined a range of elevations from 0 to 100, but since the texture we used to define the landscape only had values from 45 to 99, those were the values represented in our DEM. Switch back to your texture editor interface and enter 99 into the Input High textbox, and 45 into the Input Low textbox.

15. Render your overhead view again. See the difference? You should have ended up with a render that looks something like this:

16. By adjusting the positions of the material pins on our gradient, and the blending modes between them, we can change where the rendered materials appear. Our gradient is simple - elevation values over (approximately) a 50m range are being mapped to a scale from 0 to 100%. Hence, 1% on our material gradient corresponds (in this case) to 50cm of elevation change. Using a bit of simple mathematics, we can determine (in this case) that the grass material will start at 49m and have turned completely to mud material by 72m elevation. The rock material, located at 60% of our gradient, is therefore going to appear at elevations 77.4m and above. Make sure your diagnostic window is open (F4) and click several times in the rendered view - pay special attention to the relationship between our driving parameter (in this case, elevation) and the color that has been rendered.

17. Make the following changes to your gradient: Select the pin corresponding to the mud material, and change it's blending mode to sharp edge. Shift the pin corresponding to the rock material to 75% in the gradient, and change it's blending mode to Sharp edge too. Render your overhead view again and note the difference - it should look something like this:

18. Note that the Sharp Edge blending mode that we selected has hardened the boundaries between colors. We no longer see the colors produced by the Half Blend mode we previously used. Hopefully you should already be able to see applications for this technique for cartographic projects or any others where you need to render a series of images with color-coded elevation lines. All it requires is that you add and position enough material pins in your gradient to represent the range that you require and that you drive them by elevation. Here is an example that I quickly created by loading Chris Hanson's Rainbow Hypsographic elevation shader component into our project. All I had to do to get it to render correctly was to change the maximum and minimum input levels to represent our elevation range (in this case, 45m to 99m).

In the rendered output, red represents low elevations and magenta represents high elevations:

19. Let's try something different now. I have already decided that would like our materials to be distributed by a Dynamic Parameter, but I'm just not sure that elevation should be the one. None of our renderings look particularly natural so far - in fact, arguably less so than our original Fractal Noise distribution! In your Texture Editor interface, click on the drop down list for Dynamic Parameter -you should see a number of options. For now, select Relative Elevation:

20. For a more realistic effect, we should be expecting grass and mud to accumulate in areas of negative relative elevation (for a full description of relative elevation, see the online guide that ships with WCS - just press F1!), or concave areas in layman's terms. The rock material might look more appropriately placed on areas of convexity (ridges, or areas with a more positive relative elevation). So let's try that now: Having selected Relative elevation as our driving parameter, we need to determine good values for the range of input values - we can determine this by clicking in our last rendered view, and reading the relative elevation values from the diagnostic window. I found that I was seeing a range from -10 to +25, so enter -10 into the Input Min field, and 25 into the Input Max field.

21. Do another render of our overhead view and see what happens:

Not very much rock material, is there! What has happened is that we have selected a range of relative elevations that represents the extremes of that parameter - sometimes it is not always advisable to default to that - we need more rock to show, so we could move the pins on our gradient, or we can change the range of input values and make it smaller. Try changing the Input Max field to 0. Render again, and see how that has affected the resulting image:

22. Well, we've got some rock material appearing now - in fact, if anything, a bit too much since any positive relative elevations render with the rock material. However, I'm already beginning to decide that relative elevation is not the parameter I want. Go to the Dynamic Parameter dropdown list again, and this time, select Slope as the driving parameter.

23. You should see the input min and max values default to 0 and 90 degrees respectively. Render a preview and see what that gives us. All green again, isn't it? Clicking in our rendered view and observing the values for slope should show us why. I certainly can't find any slopes approaching 90 degrees on our terrain. Even though our rock material is set to render on slopes steeper than about 55 degrees, our terrain simply isn't steep enough to show any of the rock material. Try changing the Input Max value to 15 degrees. Test render your overhead view again.

24. Now we're getting somewhere! The rock material is rendering on steeper slopes and our grass is rendering on the flatter areas. Our limited band of mud is restricted to a small range of slopes that fall between the two. Try rendering your GroundCover Camera view also. This is more the look I was after, but I finally decided there just wasn't quite enough grass and mud showing, so changed my Input Max value to 20, and the position of my Mud material to 40% of the material gradient. On rendering my Ground cover camera, my view looked like this:

25. Now that we have the distribution how we want, try re-enabling your material textures by clicking on the button for each of the grass, mud and rock materials. Render another preview of your GroundCover Camera, and you should end up with something like the following image:

and at a higher Fractal Depth (FD=3):

26. I don't particularly like the banded effect we are getting due to the tiling of the grass images, but remember that this is just a ground effect. Firstly, it will rarely render, since we would normally be defining Ecosystems in an Environment, that would render with a higher priority than our Ground Effect. Always remember that a ground effect will only render if nothing else is set to render on that particular polygon. Secondly, where it does render, the banding effect should be hidden, at least in part, by the foliage that WCS will place on our terrain. If it does show up in final renders, it would be worth spending a bit more time trying to disguise the banding.

27. Save your project file and also your modified Ground Effect as a component - if you can't remember how to do that, take a quick look back at the end of Part 6.

28. Well, that's just about it. There are other terrain parameters, but I don't feel it would be worth me taking you through the behavior of each one. Feel free to select other parameters and use them to drive our gradient of materials. Before we move onto Part 8 there is just one more thing that I want to discuss which I feel may be of use.

29. How could we easily reverse our gradient? Say we were producing a map with a nice color gradient driven by elevation, and only on rendering do we realize that we have set up our entire range of material pins in reverse - black is representing high elevations rather than low elevations, for example. You may have the correct range of input values defined, and you certainly don't want to delete and recreate all your materials. What to do? Well, the secret lies in the fact that the input values for the selected terrain parameter are remapped to a set of output values on your materials gradient. Who said they have to be mapped in a direct fashion? Why not have high input value remapping to low output values and vice-versa? Try taking our gradient and reversing the output values: enter 0 into the Output Max field and 100 into the Output Min field. Render and see the effect - where we had rock before, there's now grass, and vice versa:

This can save you some time if you make a mistake in material definition early on, and in some scenarios may be the only way to accurately manage placement of materials. This concept extends to the ranges that you enter into the Input and Output fields - we've already seen an example of entering a limited range of values into our Input fields, but the same applies to the Output fields - let me give you an example: Say we were driving materials by slope (as in the last tests). Slope ranges are from 0 to 90 degrees relative to the horizontal. Our gradient ranges from 0% to 100%. This means that each percent of the gradient corresponds to 0.9 degrees. Gee - what a useful number, and definitely one we are going to want to do math within our heads! Wouldn't it be nicer if it corresponded in a logical 1:1 way. That way, we could place a pin on our gradient, and whatever % value we gave it's position, that would be the slope (in degrees) on which that material would start to appear. This would make planning our gradient and the position of materials within it, far easier. So, change your Output Max value to 90%! It's as simple as that. Once set up this way, it's as easy as selecting the slope angle at which you want a material to appear and adding a pin to your material gradient at that exact point in %. Try it and see!

30. That's enough for Dynamic Parameters for now, but we will come back to this when we create a simple example project in Part 9 and drive all sorts of aspects of it using the Texture Editor. For now, follow me to Part 8, where we are going to look at multiple material channels and how to texture them to best effect.

Copyright © 2003 N-Light Ltd All Rights Reserved