[TUTORIAL] Custom Blend Materials

Cynick

L4: Comfortable Member
Feb 7, 2010
153
284
Ok lemme type this all out again and hopefully I don't accidentally close my browser this time. :cursing:

You know those cool materials that you can use on displacements to blend between two different textures? Well, I looked around for a tutorial on how to make them, but found nothing. So I looked at Valve's examples and made a tutorial. This tutorial assumes only basic mapping and VMT knowledge. Enough chatter! Tutorial time.

Custom Blend Materials

First, you will need two textures to blend. If you extracted them with GCFScape*, they should already be in VTF format, if not, I will show you how to convert them. I will be using the team colored dev textures.

*Thanks to Ravidge for pointing this out: You don't need to extract the VTFs from the GCF if you're not going to edit them at all. Simply point the $basetexture and $basetexture2 paths to the path of the texture in the GCF (relative to "root\tf\materials")

textures.png


Step 1. Converting to VTF (skip to #2 if you already have)

If you haven't already, download VTFEdit. Start by using File->Import to import your texture into VTFEdit. A dialog will open with a lot of settings, leave them at default and hit ok. Then go to File->Save and save your file as a VTF. Repeat this process for the other file.
(I saved mine as blendexample_red.vtf and blendexample_blu.vtf)
vtfeditsaveas.jpg


Step 2. Creating the VMT
Open up the folder where you saved your VTF files. Create a new text file WITH THE EXTENSION VMT. (Mine is blendexample.vmt)

vmtcreate.jpg


Open this file with a text editor (I used Notepad++, Notepad works too). Now you'll need to specify the properties of the material. Start by entering:
Code:
"WorldVertexTransition"
{
The "WorldVertexTransition" specifies the shader the engine will need to use to correctly blend the materials together. The { tells the engine that you are specifying properties for this material. Now, expand your file with:
Code:
"$basetexture"    "<texture 1 relative path>"
"$basetexture2"    "<texture 2 relative path>"
These parameters specify where the game can find your VTF files, so replace the text in between the < and > with the path (relative to "tf\materials") that you will copy the VTF files and the VMT to. (this can be anything, but make it descriptive, and remember it) For this example, I used "customblend/blendexample_red" and "customblend/blendexample_blu

DO NOT INCLUDE THE .VTF EXTENSION!

Now, some optional (but recommended) parameters
Code:
"$surfaceprop"    "dirt"
"%keywords"      "tf"

"$surfaceprop" specifies what sounds the material should make when walked on/shot. It also tells what type of bullet holes the material should show. Other common values are "concrete" "metal" and "wood".

"%keywords" simply specifies tags that one can use in the texture browser, most tf2 textures will use the tag "tf"

Here's my example VMT with all the parameters:
basicvmtparams.jpg


Step 3. Putting the files in the "tf\materials" folder

Almost there! Now you will need to copy your two VTF textures and your VMT file into the correct folder (the one you specified for "$basetexture") in your "tf\materials" folder (if any of the folders don't exist, create it). Diagram incoming:

copy.jpg


Step 4. Try it out!

Boot up hammer and search for your material in the texture browser. It will only show one material, but IT STILL WORKS.

texbrowser.jpg


Now try it out on a displacement. Here's my example texture:
testmap.jpg


Here's the final result:
finalresult.jpg


Cool, huh?

Step 5. Blend Modulate Textures

You may have noticed that the game renders the transition to texture 2 as a solid gradient. This works fine for our simple example with dev textures, but what about more natural transitions like grass to concrete? Grass doesn't evenly "fade" over concrete, so a solid transition will not achieve a realistic result. The answer? A gun. And if that don't work, use more gun. Blend Texture Modulates!


Example (Nature/blendconcretetograss001)
nomodulation.jpg

modulation.jpg


The difference is massive. Here's the BlendTextureModulate texture for the above material:
grass_blendmask.png


Now adding your own BlendModulateTexture is quite simple. The texture consists of only two color channels, green and red. The green channel controls the transition between the two materials. 255 in the green channel means that texture 2 will be fully visible, 0 means texture 1, and 128 is an even blend. The idea is to paint patterns into this channel to "mask" the edges of the blend. Valve has painted patchy star-like patterns into the green channel in the example. The red channel controls the sharpness of the falloff. The Valve Wiki has a good explanation of the red channel, so I'll use that one.
Valve Wiki said:
Sharpens [the transition effect]. 0 makes the transition binary, 255 effectively disables modulation.
Valve has painted the same star pattern into the red channel, however it's a much subtler difference between the individual "star" colors. The red value averages about 100, for a fairly sharp falloff.

Another example over at the Valve Wiki

Creating Blend Modulate Textures is pretty easy. I created an *example* blend modulate texture for our dev texture example here.
testmodulation.png


Commence laughing at it's horrible-ness.


Done? Good. I made it in 20 seconds in Paint.NET, IT'S AN EXAMPLE OK? Now that we've cleared that up, save your newly created better than mine texture, and use VTFEdit to convert it to a VTF. Move the VTF to your folder in tf\materials. Almost there! Now we just need to edit the VMT to tell it which texture to use, so add this to your VMT file:
Code:
"$blendmodulatetexture"    "relative_path_to_blendmod_texture"
That's all you need to do! This is what your tf\materials\whatever folder should look like now

newvmt.jpg


Boot up hammer again to your example map (NOTE: Blend modulate textures DO NOT DISPLAY or have any effect on the displacement in hammer, but the result will show up in-game.). I loaded up TF2 to my example texture and:
finalblendmodresult.jpg

A working blend texture. Apologies for forgetting to turn of the HUD.

More about Blend Modulate Textures

Extra Info

Remember how the texture browser only shows one texture in your transition? If you want it to display both, create a third image (in Photoshop or Paint.NET or GIMP, etc.) that shows both textures, convert to VTF, copy to the folder with your other files in "tf\materials" and add this line to your VMT:
Code:
"%tooltexture"  "path_to_preview_texture"

WorldVertexTransition supports many other parameters. You can specify a different surfaceprop for the second texture in the same way as you did the first by adding:
Code:
"$surfaceprop2"    "rock"

Here's an example Valve one (this utilizes bump mapping as well, which is outside the scope of this tutorial.)
Code:
"WorldVertexTransition"
{
	"$basetexture" "Nature/dirtground007"
	"$basetexture2" "Nature/rockground007"
	"%tooltexture" "Nature/grass_02"
	"%detailtype" "tf_granary_grass"
	"%keywords" "tf"
	"$bumpmap" "Nature/dirtground005_height-ssbump"
	"$ssbump" "1"
	"$surfaceprop" "dirt"
}

Have fun! If this was helpful, if you have a question, or if you have a critique, post a reply below. Happy mapping. :thumbup1:
 
Last edited:

Ravidge

Grand Vizier
aa
May 14, 2008
1,544
2,818
Nice! Making custom blends is something everyone should know and utilize.

You don't need to extract the textures though if you're not going to edit them. Just reference their path as they are in the gcf! No need to add custom textures that aren't really custom.
 

Cynick

L4: Comfortable Member
Feb 7, 2010
153
284
Nice! Making custom blends is something everyone should know and utilize.

You don't need to extract the textures though if you're not going to edit them. Just reference their path as they are in the gcf! No need to add custom textures that aren't really custom.

Never even thought of that. Thanks! :thumbup:
Edited the OP.
 
Last edited:

Exist

L6: Sharp Member
Oct 31, 2009
306
136
Iv'e known this

You can also do this with valves textures, without removing them from the GCF

Just use the file path from in side the gcf, most of them are found in Nature/

Also, you can edit the texture in the browser by editing the VMT with $toolstiptexture (I think thats it atlest)
 
Last edited:

Dustoxx

L6: Sharp Member
Jan 9, 2009
304
43
This is so helpfull! I never knew how this worked, thank you so much! :D
 

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
Blend textures without blend modulates might as well be a solid texture. Evidence:

Without vs With.
Blendmodulate.jpg


Please add this to your tutorial, finish the job please!!
 
Last edited:

Cynick

L4: Comfortable Member
Feb 7, 2010
153
284
I saw that and I was going to add it but it wasn't in any of the tf2 materials I looked at. I realized (later) that it would be more useful in a terrain->flat (e.g. concrete) blend. I checked out a grass->concrete blend and lo and behold, there it was. Will edit the OP momentarily.

EDIT: Am getting "500 internal server error" trying to edit the post. Will try again in a few minutes.
EDIT 2: I have concluded that the forum doesn't like copy/paste. I have to retype all the stuff from the edit. :(
EDIT 9001: I'll have to get this up tomorrow, every time I copy/paste my post out of the backup file I have, it gives me a 500 server error when I save.
 
Last edited:

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
uhhhh There are blend modulates for every blended tf2 texture I know of.. all the snow, all the dirt grounds, all the grass to dirt, all the dirt to concrete.

I can't think of any that don't have a blend modulate.
 

Cynick

L4: Comfortable Member
Feb 7, 2010
153
284
I didn't see one in the nature/blendgrassground001.vmt file, which is the one I looked at to make this tutorial in the first place. Either way, Step #5 (now up) is blend modulate textures!

I found the error BTW, whenever I typed "from" in my edit, it would throw an error. :confused:
 

Cynick

L4: Comfortable Member
Feb 7, 2010
153
284
Basically, it "stamps" a pattern on the transition between texture 1 and texture 2. This keeps the transition from looking flat. The green channel shows the pattern that is stamped on the edge, and the red channel controls the sharpness of the transition.
 

honeymustard

L9: Fashionable Member
Oct 26, 2009
698
573
uhhhh There are blend modulates for every blended tf2 texture I know of.. all the snow, all the dirt grounds, all the grass to dirt, all the dirt to concrete.

I can't think of any that don't have a blend modulate.

Blend ground to concrete (the one used on freight) doesn't have one. That's all I can think of though :p
 

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
Blend ground to concrete (the one used on freight) doesn't have one. That's all I can think of though :p

Whilst I'm not 100% sure cause I don't play freight, I'd say that isn't a valve blend since valve have a dirt to concrete used in hydro that does have a modulate
 

honeymustard

L9: Fashionable Member
Oct 26, 2009
698
573
118g9iw.jpg


It's these two I was talking about. I just found out that only the one on the left doesn't use one (the line is commented out). So that's kind of weird.

edit: just had a better look at both textures and the modulate texture one uses. Both textures use the same ground texture but different concrete textures, and the one with the modulate texture is specific to the concrete (so the ground fills the cracks of the concrete). Which is why I guess there isn't one for the other texture, as Valve probably didn't use it (they used the other in Hydro, I guess!)

edit: turns out there is a modulate texture for the other concrete, it's just not listed in the vmt for whatever reason.
 
Last edited:

Jetti

L5: Dapper Member
May 2, 2010
226
111
I'm having some problems. The blend texture works fine. Its just that I have one texture really large, and the other I would want very small. Picture gravel on a large concrete block. The gravel in the texture I am currently using is very big, where I want it to be almost 8 times smaller. The texture scale on the face is set to 0.75, but to get the gravel to look good, it has to be 0.1...

My VMT is currently:
"WorldVertexTransition"
{
"$basetexture" "custom\gravelground001"
"$basetexture2" "custom\wall030"
"$surfaceprop" "concrete"
"%keywords" "tf"
}

What would I do to make the gravel smaller, but keep the Wall030 the same size?
 

3Dnj

Ducks
aa
Dec 21, 2008
288
638
I think the two textures have to be on the same resolution but you can try $basetexturetransform to change the scale of your texture, it probably doesn't work with this shader.
 

Cynick

L4: Comfortable Member
Feb 7, 2010
153
284
Code:
$basetexturetransform "center .5 .5 [B]scale 0.1 0.1[/B] rotate 0 translate 0 0" //Decreases the scale of texture 1 to 0.1

Copy that line into your VMT and it should work ($basetexturetransform2 does the same thing to the other texture)


Also, 3dnj, i'm not sure either if the textures need to be the same size, but it's possible.
 

Jetti

L5: Dapper Member
May 2, 2010
226
111
Cynick, I think you misunderstand the basetexturetransfrom scale.

scale 0.1 0.1 makes it 10 times bigger. scale 2 2 makes it half as big.

I have set it to scale 7 7, but this makes both 7 times smaller. It isn't working! D:

EDIT:

Currently at:
"WorldVertexTransition"
{
"$basetexture" "custom\gravelground001"
"$basetexture2" "custom\wall030"
"$surfaceprop" "concrete"
"%keywords" "tf"
$basetexturetransform "center .5 .5 scale 7 7 rotate 0 translate 0 0"
$basetexturetransform2 "center .5 .5 scale 1 1 rotate 0 translate 0 0"
}
Still not working.
 
Last edited: