Tutorial: Creating blend textures for Displacements Last edited 12 years ago2012-03-17 05:22:40 UTC

You are viewing an older revision of this wiki page. The current revision may be more detailed and up-to-date. Click here to see the current revision of this page.

This article was converted from a previous version of TWHL and may need to be reviewed

  1. The formatting may be incorrect due to differences in the WikiCode processing engine, it needs to be revised and reformatted
  2. Some information may be out of date
  3. After the article is re-formatted and updated, remove this notice and the Review Required category.
  4. Some older tutorials are no longer useful, or they duplicate information from other tutorials and entity guides. In this case, delete the page after merging any relevant information into other pages. Contact an admin to delete a page.

Download attachment

If you've played around with displacements in Source, you've likely noticed a section in the displacement tab marked Paint Alpha. For those of you unfamiliar with the tool, it allows you to take a blend texture, such as nature/blendrockgrass004a and paint on a secondary texture to it by 'painting' it over a second layer's alpha channel. This can only be done on a displacement, and is usually used to add variation to an otherwise bland landscape, or make a smooth transition from one material to another.
Painting alpha with a stock HL2 Blend texturePainting alpha with a stock HL2 Blend texture
The same blend texture with no alpha, all alpha, and some poorly painted alpha.The same blend texture with no alpha, all alpha, and some poorly painted alpha.
Surely the process of making this work with your own custom materials is some form of complicated black magic, isn't it?
Well actually, no.

First up, if you don't already have VTFEdit, you can get it here. While it's not strictly required in order to make new materials, it streamlines the process and saves a lot of headaches. If you're using your own textures, make two now, and save them as a TGA or PNG; the base, and what you want it to blend into. There is no special process needed for this to work, as long as you keep in mind the dimensions must be powers of 2 and no larger than 4096x4096, the absolute engine limit. Otherwise, locate and extract the VTF files for the base materials you want to use. I will be using wood/woodfloor006a and nature/dirtfloor006a. (More on this later.)

Use VTFedit to export the two VTFs you are using into a workable file format (PNG or TGA are recommended) or ready the textures you made, and open them in your favorite image editing program. Edit the images together with the base texture in the top left corner, the "alpha" in the bottom right, and some opacity-based blending in the middle.
It doesn't have to look perfect, since you're the only person who will actually ever see this.It doesn't have to look perfect, since you're the only person who will actually ever see this.
Save this as [Texturename]_tooltexture
Import all three of your textures into VTFedit and save them as VTFs.
(You only need to save the _tooltexture if you're using stock textures)
We don't need to change any of these values for the textures we're making.We don't need to change any of these values for the textures we're making.
As when you made this texture, the VTF has to be save as the name of your blend texture with an _tooltexture postfix.As when you made this texture, the VTF has to be save as the name of your blend texture with an _tooltexture postfix.
Now that you've gotten the three essential parts of the blend texture, it's time to make the VMT that turns them into a material. You can do most of this from VTFedit, but some editing after you save it will be required.
The values in your VMT should look something like this.The values in your VMT should look something like this.
Your VMT needs to contain the following data minimum: (values have all been filled in, you will likely want to edit some of them)
"WorldVertexTransition"
"$basetexture" "wood/woodfloor006a"
"$basetexture2" "nature/dirtfloor006a"
"%tooltexture" "wood/blendwoodmoss001a_tooltexture"
"$basetexturetransform" "center .5 .5 scale 1 1 rotate 0 translate 0 0"
"$basetexturetransform2" "center .5 .5 scale 4 4 rotate 0 translate 0 0"

"WorldVertexTransition" is the vital part of the material- without using this as the shader, the blend texture will not work.
"$basetexture" is the texture you want your blend texture to default to, while "$basetexture2" is what you want it to blend with. "%tooltexture" is the tool texture you made, which will be used as a thumbnail in Hammer's material browser. The "$basetexturetransform" values should be left as is, as all of Valve's blend texture materials use those values. Unless you want your material to be plastic, you should also have at least one "$surfaceprop" value, using the second if your other texture is a different surface type. Finally, "%keywords" simply sets one or two key words you can enter into the material browser if you want to label it as being part of a specific texture set. I generally use my name as a reminder that it's a custom texture I made.
Save your VMT, apply it in hammer, and test it out ingame.
Note how the use of two surfaceprop values allows the applied grass/moss to act like grass, while the wood still has wood decals and sounds.Note how the use of two surfaceprop values allows the applied grass/moss to act like grass, while the wood still has wood decals and sounds.
Now, you're probably wondering why I used a wood texture in this example. Allow me to show you what inspired me to experiment with making blend textures, and resulted in this tutorial:
ninja defuse's question got me thinking of ways to do what he wanted, and helped me figure out how to do much the same thing in a map I was working on.ninja defuse's question got me thinking of ways to do what he wanted, and helped me figure out how to do much the same thing in a map I was working on.
As it turns out, using blend textures, there is in fact a way to do this. You simply need to make a room with a false floor above a leak-sealing nodraw floor, and convert the false floor into a displacement. Since you don't have to make a displacement have any height variations, you can simply paint the dust/grass/moss (or whatever!) on the floor and be on your way, with a not-even noticeable impact on performance. Cheating, perhaps, but it gets results.
A very simple scene showing how blend textures can be used to help give a sense of abandonment and overgrowth.A very simple scene showing how blend textures can be used to help give a sense of abandonment and overgrowth.
There are tons of unconventional uses you could utilize blend textures for in addition to their intended use for terrain, and I look forward to seeing what you come up with.

Addendum: Shortly after writing this tutorial, I received a PM from the ever helpful Archie, who pointed out that since the Source 2009 Updates, all Source engine games can use the $blendmodulatetexture parameter, which essentially changes the smooth gradient-based alpha painting with a gradient using a mask defined with it as a form of stamping, so you can use a design instead of just a standard brush.
Besides defining the $blendmodulatetexture, you must also use the following parameters:
"$blendmasktransform" "center .5 .5 scale 1 1 rotate 0 translate 0 0"
All the numeral values can be edited, but keep in mind that rotate actually defines counter-clockwise rotation, rather than the standard clockwise. As well, the $blendmodulatetexture only reads in green and red channels, so you will want to use them as separate layers in your image with an alpha channel, and save it directly as a TGA instead of an image format that may result in losing/merging the layers. Valve uses a straight value of 99 in the red channel, and the green channel, used for the actual pattern, is biased towards $basetexture2 Additional technical information can be found here.

4 Comments

Commented 11 years ago2012-04-02 06:52:47 UTC Comment #101061
Great tutorial sir! I'll definitely be using this soon ;)
Commented 11 years ago2012-04-02 09:13:56 UTC Comment #101062
Good overview for beginners to blend textures. Might want to expand upon the texture modulation/addendum as the modulate textures are really what sells the 'blend' effect between the two materials themselves rather than just using a linear blend which happens if you omit the modulation material.
Commented 11 years ago2012-04-04 07:37:51 UTC Comment #101063
Yeah, I should, and I probably will sometime, but that'll require further testing on my part. Need to figure out exactly how it works and get some experience with it, after all.
Commented 10 years ago2013-03-31 11:10:13 UTC Comment #101064
Awesome tutorial!

You must log in to post a comment. You can login or register a new account.