Displacement Grass

From Valve Developer Community
Revision as of 17:32, 22 February 2006 by Ts2do (talk | contribs)
Jump to navigation Jump to search
Broom icon.png
This article or section should be converted to third person to conform to wiki standards.

To create grass that appears in random locations is a simple task in Source mapping.

Without going into a detailed displacement tutorial we're going to cover the basics of achieving this effect with a sample project where I have created 3 brushes to illustrate how blended textures can work for you. In this example I've created a HL2/HL2DM example and a separate CS:Source example. As always the download is at the bottom of the tutorial.

There are a few things you need to keep in mind, the most important being that displacement surfaces do not seal leaks and they don't block visibility.

The textures I've used for these examples are:
HL2 nature/blendgrassgravel001b
CS:S nature/blendgrassgravel003a

When you are looking for blend* textures for your maps use the filter word blend and you will find blended textures for grass, sand and gravel. Feel free to experiment with these.

I've applied the textures to every face of the displacement brushes but only 2 faces of the normal brush the player will start on. The reason is to show there will be no grass sprites on the normal brush but it will have the same grass texture as the other surfaces, and I've textured the one face that faces the neighboring displacement brush out of habit, this can help to eliminate those flickering lines you see in maps at the edge of brushes.

Always texture your displacement brushes on all sides, this way you won't get the nodraw on displacement surface error, and besides, the compiler is going to toss out those faces anyway, only the displaced faces will be created.

Because displacements don't seal your map you will always have another brush behind them. In this example the bottom brush is entirely textured with the nodraw texture. Thus a normal world brush textured with nodraw is sealing the map under the displacements.

WiseGrass01.jpg

To produce our grass we will first create the displacements. For this example we are going to use displacements powers 2 and 3. A displacement power of 4 is really not needed for something like this unless you are trying to create something that is extremely smooth and round.

With the face edit dialog open click on the Displacement tab (shown below) and then select the brush you want to create the displacement on, and finally click the Create button.

This is where you will enter either 2, 3 or 4 as the power of your displacement.

WiseGrass02.jpg

Notice that the brush on the left has a displacement power of 3 while the one in the center has a power of 2.

To have the blended grass all we need to do is apply the displacement power of 2, compile the map and the grass sprites will be added. You won't see these in Hammer but they will appear in the game.

That's all we're going to do for the center brush.

For the brush on the left we're going to apply a power of 3 then once the displacement is created we're going to add some noise.

Noise? Sure. Similar to the plugins for most graphics programs Hammer can add Noise for you and apply it to your displacement surfaces.

Click the Noise button and give it the settings of Min 0.5 and Max 3.0, then apply those settings and look at your displacement. It now has nice looking random bumps.

Here's an explanation of the Noise feature, from Valve: Add random noise to the selected displacement surface. The Min value sets the greatest distance in units that a point on the displacement will move downward along the face normal. Max sets the greatest distance upward along the face normal. Clicking OK will randomize the position of the points on the displacement somewhere between these two values.

WiseGrass03.jpg

Now we're going to use one more feature on the brush on the left, Paint Alpha.

WiseGrass04.jpg

With the tool we are going to bring out some of the sandy area of our left brush and in those sandy areas you won't see grass or grass sprites. You should really experiment with the settings on this tool, and the brush sizes. For this example I only used the Raise/Lower option with a brush size of either 1 or 2 and radiuses of 25.0 and 117.0.

One final note about the two displacement brushes, I did have to Sew them after applying the Noise. To do this select the displacement surfaces you want to sew and then simply click the Sew button. The Sew option connects the edges of two or more selected displacement surfaces.

Per Valve: You can sew displacement surfaces in any of the following circumstances:
Any two displacements whose base brushes surfaces share a common edge when coincident endpoints.
Displacements with different resolution settings.
A displacement surface to a non-displacement brush face, as long as the base face of the displacement shares a common edge.
A displacement surface to another displacement surface where a shared edge is exactly half the width of the other (called a T-junction).

I've also placed a few static props in the example maps to show how simple things like weeds can be added. There are lots of SDK models you can use in your maps.

The models I used are:
prop_static
models/props_foliage/cattails.mdl
models/props_foliage/Shrub_01a.mdl
Collisions: Not Solid
Disable Shadows: Yes

Notice that I've disabled shadows. You can get some pretty odd effects when you place props like these in your grass, sometimes it's best to disable shadows for your weeds.

I've also created a small rock ledge using the Noise tool but with a higher setting of Max 7.0 and the same Min of 0.5 to create a blended rock area (I only did this in the HL2 version but it's the same method for CS:S). This can be very helpful when you need to hide mating edges or anything odd, plus rocks like these are always nice in an outdoor map so they should hardly ever look out of place.

Here are a few shots of our three brushes in the game:

WiseGrass05.jpg

Notice how well the three brushes blended together.

This rock ledge may look odd to some of you but here in the Smokie Mountains where I live rock ledges like this are common. This one is only meant as an example, in an actual map I would not have made it so long.

File:WiseGrass06.jpg

Have fun.

If you need further help please contact me or use these forums.

See also

How to create a texture that automatically uses detail props
The example used in this tutorial.