tutorial:alpha-textures

Alpha is the fourth channel of an image, it acts as a mask and is usually used for transparency. In Source engine it can be used for multiple things such as transparency, colorable textures, and different kind of masks, e.g. phong mask.

This tutorial will cover the creation of transparent and colorable textures using Blender.


I'm using Blender because it allows you to paint directly on the model and preview how it's gonna look in-game. If you know how to apply this tutorial to your own software then feel free to do so.


Tools that you will need:

Blender + Blender Source Tools

Crowbar - Decompiling

VTFEdit or Paint.NET + .VTF plugin - Converting textures


Getting files

First you have to get the model and texture that you want to edit. See Extracting game content for information on how to extract those from the game.

For this tutorial I'll be using Alyx, and my goal is to make part of her pants invisible, the required files are:

Model (all model files are required):

  • alyx.mdl
  • alyx.dx80.vtx
  • alyx.dx90.vtx
  • alyx.phy
  • alyx.vvd

Texture (only get the textures you want to edit):

  • plyr_sheet.vtf

Material files are not needed but you can extract and open them if you don't know which textures you should get.


Decompiling Models

To actually do something with the extracted model you have to decompile it first.

To decompile your model open Crowbar and go to the Decompile tab. Select your model by clicking Browse in the MDL input line, then select the output folder and click Decompile.

From all the decompiled files only one is actually needed, in this case alyx_reference.smd. The name will be different depending on the model you're using but for most GMod models its <character_name>_reference.smd.


Converting Textures

Before you can edit the textures you'll have to convert them to a different format. This step is pretty simple, all you have to do is open the .vtf file in VTFEdit or Paint.NET and save it as a .png file.


At this point you should have:

  • Blender and Blender Source Tools installed
  • .SMD model file (alyx_reference.smd)
  • .PNG texture file (plyr_sheet.png)

Importing

First you have to import your model to Blender.

  1. Open Blender and go to File > Import > Source Engine.
  2. In the window that appears, go to where you extracted your files.
  3. Select your .smd file and click Import SMD… at the bottom.

Basic controls

Here are some very basic controls if you're new to Blender:

  • RMB - Select objects
  • MMB - Rotate view
  • Shift + MMB - Pan view
  • Mouse Wheel - Zoom
  • . Numpad - View selected

Material Setup

Before you paint the texture you need to set up the material so that you get a preview of how it's gonna look in the game.

  1. Right Click on the skeleton (one of the spheres) and press H to hide it.
  2. Switch to the Shading workspace (at the top).
  3. Go to the Material Properties panel.
  4. Select the material that you want to work on. The material name is always the same as the in-game material (.VMT file). In my case it is plyr_sheet.
  5. Click on Use Nodes.
  6. Scroll down to Settings and change Blend Mode to Alpha Clip.

Node Controls
  • RMB - Select Node
  • X - Delete Node
  • Shift + A - Add Node
  • G - Move

Node Setup
  1. Delete the Principled BSDF node.
  2. Add Mix Shader node, connect the Shader output to the Surface input on Material Output.
  3. Add Diffuse BSDF node, connect the BSDF output to the bottom Shader input on Mix Shader.
  4. Add Transparent BSDF node, connect the BSDF output to the top Shader input on Mix Shader.
  5. Add Image Texture node, connect the Color output to the Color input on Diffuse BSDF and the Alpha output to the Fac input on Mix Shader, then click Open and select your texture.

Texture Painting

Switch to the Texture Paint workspace (at the top). The left panel shows your texture, the right one shows the model, you can paint on any of them. That's it, now you can paint on your texture. There isn't much to say about it, just remember:

  • To decrease the alpha value change the blending mode to Erase Alpha.
  • To increase the alpha value change the blending mode to Add Alpha.

Saving

  1. Once you're done painting, hover over the texture and press Shift + Alt + S.
  2. In the window that pops up select the save location.
  3. Set File Format to .PNG and Color to RGBA.
  4. Click Save As Image.

Replacing the texture in PAC

If you don't know how to use it in PAC follow Replacing materials/textures.


If you have any questions ask in the #help channel of the Official PAC Discord

  • Last modified: 2 years ago
  • (external edit)