Check out Half-Life Re-imagined competition results!
Check out Skewing textures in Hammer, our newest tutorial!
Welcome, sarab, our newest member!

logo

Site Stuff

Reference

Maps

Community

ShoutBOX

Poll

Feeling Blue

What's your favourite shade of blue?

Azure

15

Cobalt

32

Turquoise

10

Cyan

11

Royal

9

Teal

3

Onliners

3 mins

potatis_invalid

26 mins

Jessie

31 mins

Snehk

1 hours

JeffMOD

1 hours

twitch1

2 hours

Tetsu0

2 hours

Penguinboy

Affiliates

A gaming and technology blog by TWHL admins Penguinboy and Ant. A music blog by TWHL users Ant and Hugh.

Creating blend textures for Displacements

Page: [1]

Tutorials > Source > Intermediate > Creating blend textures for Displacements

avatar

By JeffMOD (More from this user)
16th March, 2012
Intermediate
displacement, blend, material, texture
star star star star star (3 votes)

download

example map

File Info: ZIP, 676.38KB
Contents: Example VMF used in tutorial, custom blend texture using stock VTFs.
Notes: Also contains bonus textures to be used in an upcoming map.

Creating blend textures for Displacements

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.

Tutorial Image Painting alpha with a stock HL2 Blend texture

Tutorial Image 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.

Tutorial Image 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)

Tutorial Image We don't need to change any of these values for the textures we're making.


Tutorial Image 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.

Tutorial Image 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.

Tutorial Image 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:

Tutorial Image 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.

Tutorial Image 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.

Comments

avatar Captain Terror says: star star star star star 1st April 2012, 23:52 PM
Great tutorial sir! I'll definitely be using this soon ;)
avatar RabidMonkey says: star star star star 2nd April 2012, 02:13 AM
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.
avatar JeffMOD says: 4th April 2012, 00:37 AM
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.
avatar Starkey62 says: star star star star star 31st March 2013, 04:10 AM
Awesome tutorial!
You must be logged in to comment.