WiseQuickDecal: Quick HL2 decals

From Valve Developer Community
Jump to: navigation, search


This tutorial was originally created by wisemx. It was originally posted on SDKnuts.net.

(Porter's note: The method that wisemx describes here is odd, out of the way, and doesn't work well for all situations. For those reasons, I've pasted the text here but it isn't VDC formatted.)

This tutorial is not about how to create custom materials.

Instead it’s about how to create decals quickly.

What’s the difference?
Other AKG tutorials will cover the more advanced topics.
This is for those who simply want a quick method that works.

What’s required?
1) HL2DM, CS:S or DOD:S
2) Any valid image.

Valid images are:
BMP, JPG, TGA and VTF.

As you probably know materials in the HL2 Source engine have to be created to the power of 2.
In other words, keep it even.
16x16, 32x32, 64x128, 128x128, 128x256, 512x512, etc

We’re going to use the Player Spray Import option in HL2DM.
This will create a decal that’s 256x256.
Don’t worry too much about the size right now, HL2DM will actually resize your image.
If however you’re creating it yourself 256x256 or 512x512 will do nicely.

If you are going to use a TGA with an Alpha channel for transparency it must be a 32-bit TGA.
Supported TGA formats are 24-bit RGB and 32-bit RGBA. (Alpha)
If not you will see an error message when you try to import the TGA.



PNG format isn’t an option, but it sure would be nice.

If you can’t create the proper TGA format just stick with the JPG image format.
This is handy because you can use Google Images to locate just about any JPG you need.
I’m only going to use common JPG images, and we’ll see what we can do with them.

For this tutorial we’ll use HL2DM, because it should already be on your HL2 system.
The methods are the same in CS:S and DOD:S.

For the first example we’ll create a decal that can be used to give credit in your map.
This is a common request; I get a lot of questions about how to create a Credits decal for custom maps.
It’s a lot easier than you may have expected, not simple but definitely easy.

First we need the background for our image then we’ll add the text, which you can add with any decent graphics program that can edit JPG images, Paint Shop Pro is great for this.

Note: Corel Paint Shop Pro v10 is what I’ll be using.

You can skip this step entirely if you already have your JPG.

As you can see in the image below there’s nothing difficult about the image I’m creating.



Your image will be scaled by the engine, you can alter that scaling but by default it will be 25%.
The first thing I’ll do is create a test image so illustrate this scaling.
On our 512x512 image I’ve placed letters and numbers with a normal font setting of Arial and a size of 48 pixels, on a white background.
The X is centered in the canvas, the others were placed freehand.
I’ll name this new image quicknumbers.jpg
And this is the way it looks in HL2DM after importing it as the Player Spray image.



Notice the Arial fonts started out very large, 48 pixels, but as you can see they were scaled down to 12 HL2 units. Compare the letter A to the Light prop.

Now let’s use the same 512x512 image and create the decal we need.
In the image below you can see the Credits decal I created.



To import your image into HL2DM go to the Player Options menu then use the Spray Import feature.
If you can see your image in the small window it was successfully imported.

Now that we’ve created the decal in HL2DM we can copy the files that were created and use them in our map.

For this example we’ll be creating the decal in HL2DM and using it in a HL2 map.

Follow these steps to create the necessary folders.
1) Browse to this HL2DM folder on your system:
\half-life 2 deathmatch\hl2mp\materials\VGUI\logos\

2) You should see a *.vtf and *.vmt with the name of your image.
quickthanks.vtf and quickthanks.vmt
(vft=Valve Texture File, vmt=Valve Material)
Our first images are there also, quicknumbers.vtf and quicknumbers.vmt.

3) Now that you have verified the files exist browse to this HL2 folder:
\half-life 2\hl2\materials\

4) Create a new folder for your custom files, give this folder a name that can help to brand your images, for this example I’ll create a folder named akg:
\half-life 2\hl2\materials\akg\

5) Copy the two files, quickthanks.vtf and quickthanks.vmt, to this new folder.

6) Now we need to open quickthanks.vmt in a text editor.
Any text editor will work for this; a good free editor is EditPad.

7) Once open edit the line:
"$basetexture" "vgui\logos\quickthanks"
So it looks like this:
"$basetexture" "akg/quickthanks"

8) In the example above akg/ is the name of the custom folder you created.

9) Your new vmt now looks like this:
LightmappedGeneric
{
"$basetexture" "akg/quickthanks"
"$translucent" "1"
"$decal" "1"
"$decalscale" "0.250"
}

You are now ready to use the new material in Hammer.
Notice three things about these default settings.
1) Translucent is 1, True. (0, Zero, is used for False.)
If your image contains an alpha layer your transparencies will function.

2) Decal is 1, True.
This image is to be used with the decal or overlay tools in Hammer.

3) The scale is 0.25, the HL2 default material scale.
You can change this number.

Something that’s missing from our decal is the Material Surface Property.
We’re not going to add a material surface property because this is a decal, which will be placed over materials with surface properties of their own.


To illustrate how we can create a material surface property for this new image lets create a copy of the file quickthanks.vmt and name it quickthanksbrick.vmt.

We don’t have to change anything about quickthanksbrick.vtf but open quickthanksbrick.vmt in your text editor and change it so the result looks like this:
LightmappedGeneric
{
   "$basetexture" "akg/quickthanks"
   "$translucent" "0"
   "$surfaceprop" "brick"
   "$decalscale" "0.250"
}

Notice it uses the same VTF, we’re only creating a new VMT.

That’s it.
Now load Hammer with the HL2 parameter and create a small project that uses quickthanks as a decal and quickthanksbrick as a material.
To locate these materials/decals in the browser you can filter with the name of your custom folder, i.e. akg.
In the images below the short walls are both created with a HL2 wood wall material applied except for the brick face on the right.
The brick face on the left is our quickthanks decal.
On the right I’ve applied quickthanksbrick as the material on that entire face.

If you shoot both faces with the shotgun the face on the left will react like wood.
The face on the right will react like brick.

As you can see this method can be used to create materials very quickly.
You could for example create all the custom materials needed for a rocket in about 15 minutes.

The project file below contains the example materials, JPG images and the project VMF.

Once you’ve created your HL2 map with custom materials you can use Bspzip or Pakrat to embed these materials into the bsp file.


I’ve also included a Linoleum floor material that I created using these same methods.
This image was created in Corel PSP 10 by using one of the default tiles and the Seamless Tile adjustment feature.
I gave this the Material Surface Property of tile.
   "$surfaceprop" "tile"

See also