Source Filmmaker

Source Filmmaker

评价数不足
Fixing TF2 Cosmetics' Paint Textures
由 TurnTwister 制作
A complete, comprehensive, and up to date guide on fixing TF2 cosmetic paint regions using my own methods, which is slightly different from the commonly known method, that leads to better results.
As well as teaching how to set up a new game folder for your material fixes.
   
奖励
收藏
已收藏
取消收藏
Introduction
Something like 90% of TF2 cosmetics have broken textures, making their paint regions appear black. This is because SFM is running on an older version of TF2.

This guide will be a comprehensive, more up to date guide on how to fix those paint regions. I will be teaching a slightly different method I've discovered that leads to better results than the commonly known method.

In this guide I will also go over setting up a new game folder for SFM, that way you can put all your material fixes there and they wont be overwritten when you update your TF2 assets.

While there are plenty of fixes uploaded to the workshop, I recommend learning how to make them yourself. This allows you to become more knowledgeable on the technical side of SFM, as well as allowing you to easily place fixes in a separate game folder, and as to not rely on others for fixes as there will not always be a fix uploaded.

This guide may seem long and daunting, but that is only because I'm trying to be as clear and as comprehensive as possible. Once you know what you're doing, fixing a cosmetic takes no more than 5 minutes.
Heres a video of me fixing a cosmetic in less than 2 minutes:
Follow this guide and you will understand all the steps I applied here.
Step 0: Black Unpaintable Cosmetic Texture
So, you spawn in a cosmetic, and notice that the parts that should be paintable aren't, and on top of that they're almost pure black.
Time to learn how to fix this issue.
Software
For this guide I will be teaching it using GIMP, a free image editor.
There's two ways to go about fixing the texture, I will be explaining both:
  • GIMP 2.10[download.gimp.org], an older version of GIMP (an image editor) that's compatible with the following plugin.
  • GIMP VTF Plugin[github.com], allows GIMP to open and export VTFs, but needs fixing.
  • Everything[www.voidtools.com] (Optional), the fastest and easiest way of locating files.
Follow this video on how to install the plugin and how to fix it: https://www.youtube.com/watch?v=T2CofqV7GwQ
This first method really only saves you a couple steps, you can still fix textures without needing to use an old version of GIMP and a plugin that needs manual fixing.
Though it's what I personally use.

OR
  • GIMP[www.gimp.org], an image editor.
  • VTF Edit[nemstools.github.io], a program that allows you to view VTFs, export them as PNGs, and import PNGs in order to convert them to VTF, among other things.
  • Everything[www.voidtools.com] (Optional), the fastest and easiest way of locating files.

I recommend downloading VTF Edit either way, it's a good tool to have.
Terminology
Some technical terms you should know in order to follow along more easily.
-----------------------------------------------------------------------
  • Alpha Chanel
  • Alpha Mask
  • Alpha Layer
  • Layer Mask
These all describe the same thing. The black & white channel of an image that controls transparency. In image editors, the alpha channel can either be applied or show next to the thumbnail of the layer.

-----------------------------------------------------------------------
  • Alpha Mask
  • Alpha Mask Image
  • Alpha Texture
  • Alpha Image
  • Alpha Channel Image
These all describe the same thing. The black and white image that sits on the alpha channel. Whiter means less transparent, blacker means more transparent.

TF2 uses 2 methods that use the alpha channel in order to paint cosmetics, while SFM only supports 1. Most model makers tend to use the method that SFM does not support, and that leads to all the broken paint regions.
------------------------------------------------------------------------
  • Base Image
  • Base Texture
  • RGB Channels
These all describe the same thing. The colored image that sits on the respective R G B channels. It's the actual texture that you see within SFM that's applied to a model.
------------------------------------------------------------------------
  • VTF
Valve Texture File. Basically an image file. It's the image format that the Source Engine accepts.
------------------------------------------------------------------------
  • VMT
Valve Material. Basically a text file. It's what a model uses in order to determine what it should look like, which is usually more than just the VTF that's applied to it.
------------------------------------------------------------------------
  • Material
Can mean either a VTF or a VMT, interchangeable.
Step 1: Importing the VTF to GIMP
The fastest and easiest way to locate a VTF is to apply Override Materials to the model in SFM, show the model in the Element Viewer, open the materials, copy the mtlName of the material you want, and paste it into Everything.
Then right click the _color VTF and click Open Path. This will open the folder they're in with File Explorer.
------------------------------------------------------------------------
VTF Plugin Method
To import the VTF into GIMP, you can simply go to File>Open and locate the VTF.

Or you can drag the VTF into GIMP.

When opening a VTF using the plugin, the alpha channel will come already separated. No extra step needed here.
------------------------------------------------------------------------
VTF Edit Method
Open the VTF using VTF Edit. In the top left, click on File>Export, and save it as a PNG.

And then in GIMP you can simply go to File>Open and locate the PNG you saved.

Or you can drag the PNG into GIMP.

When opening a VTF thats been converted to a PNG, the alpha channel will come applied.

You will need to separate the channel from the base RGB channel by doing the following.
Right click the layer, and click on "Add Layer Mask..."

And make sure to select "Transfer Layer's Alpha Channel". This will make the textures workable.
Step 2:Copy-Pasting the Alpha Texture
If you inspect the base image texture you should see paint regions that are almost pure black, similar to how they look in SFM.

And the alpha channel will have the paint regions white with gray detailing. This alpha image needs to be transferred to the base image, and that's what you will learn to do in this step.


If your broken cosmetic's textures don't look like this, then it has other issues that are not within the scope of this guide. Cosmetics that have tinting $selfillum will still look like this, but the $selfillum will make the coloring washed out, this is also outside the scope of this guide
-----------------------------------------------------------------------
Make sure you're editing the alpha channel (showing the mask is optional really, but can help when learning) by either Right Clicking the layer and using the toggles, or you can simply Left Click on the thumbnails of the layer to enable editing either one, and Alt+Left Click the alpha channel thumbnail to switch between its visibility. White thumbnail border means that's the one currently being edited, red or green border on the alpha channel thumbnail means its visibility is disabled or enabled respectively.


Once you're editing the Alpha Channel, use Ctrl+A to select all of the pixels, and Ctrl+C to copy the selection.
Then, switch to editing the base texture image, either by using the toggles or clicking the thumbnail like I explained above. And then Ctrl+V to paste the alpha image you just copied. This will create a "Floating Selection". Right click it, and click on "To New Layer", this will put the alpha image on its own layer.


You should now have this, two layers. One of the original VTF and its alpha channel, and one of the alpha image isolated.

Step 3: Merging the two layers
This is where the new method I discovered comes in. On all the guides for fixing paints, they all say to use the color selector to select black on the alpha image, invert selection, copy the monochrome bits, and paste that onto the base texture. However this can lead to ugly dark edges, or needing to fumble around with fine tuning the thresholds/feathering.
------------------------------------------------------------------------
On the new pasted layer, change its blend mode to "Lighten Only".

And then Right Click the pasted layer, and click on "Merge Down".

On most textures, this method guarantees a much cleaner edge, with very little extra work.
Here's an example:
-----------------------------------------------------------------------
IF you merged down while the alpha channel on the original VTF layer was disabled, the alpha channel will be deleted. In which case, simply Right Click the layer, and click on "Add Layer Mask", and then just do "White (Full Opacity)"(which you select doesn't really matter, as it will be replaced). Then make sure you're editing the Alpha Channel and paste the alpha image onto it.

OR

IF you merged down while the alpha channel on the original VTF layer was enabled, the alpha channel will be applied. In which case, simply Right Click the alyer, and click on "Add Layer Mask", and then select "Transfer Layers Alpha channel".
-----------------------------------------------------------------------
By the end of this step, you should have something like this:
The segments that were black will now be white, as well as still having the original alpha channel.
Step 4: Fixing the Alpha Channel
Now its time to fix the alpha channel.
I haven't found a better method of doing this than the commonly known one. If i ever do find something better, I will update this guide.

The alpha channel controls what parts get colored and by how much. 99% of the time you'll want 100% coloring, which would be a pure white pixel.
------------------------------------------------------------------------
Make sure you're editing the alpha channel.

Equip the "Select By Color Tool", either by clicking on it in the toolbox, or using Shift+O. Then, in the "Tool Options" window, set the threshold to 15. Depending on your texture, this may need to be fine tuned more, but 15 is a goo starting point.
Then, click on a pure black section of the alpha channel. This will select everything except the parts we want. Thus, use Ctrl+I to invert the selection.

Sometimes you will get these tinny unnecessary selections, in which case use GIMPs selection tools (Box, Lasso, Polygon, etc.) while holding the Control Key to remove them from the current selection.

But also sometimes, these tiny selections are actually necessary for the paint region. You'll just need to play it by ear, experiment, and see what looks the most correct.
------------------------------------------------------------------------
Once you have a selection you're happy with, make sure one of your colors is pure white. You can click on the little black and white squares in the corner to set your Foreground Color to pure black and Background Color to pure white.

Then, Right Click the image, go to Edit, and click on either "Fill With FG Color" or "Fill With BG Color", whichever is PURE white.


Finally, you should have an alpha channel that looks like this:


Then, Right Click the layer and click on "Apply Layer Mask".
You'll have this:

Make sure there's only 1 layer to make things easier.

This is your finished texture, but before you save it, I highly recommend following the following step.
Step 5: Setting Up a New Game Folder
Technically this step is optional, though I highly recommend following it, unless you've already got a fixes game folder set up, in which case you can skip to next segment of this step.
Setting up a new game folder allows you to save your material fixes there, instead of saving them to the "tf" game folder. This way, when you update your TF2 assets,your fixes will not be overwritten. Which you should be doing manually, I advise against relying on the workshop for TF2 update assets as well.

You only ever have to create a new game folder for fixes once.
------------------------------------------------------------------------
If you have SFM open, close it now.

Go to your Source Filmmaker instillation folder in File Explorer. The easiest way to get there is by Right Clicking it in your Steam library, go to "Manage", and click on "Browse Local Files".

This will open a new File Explorer window at your SFM directory. Then open the folder named "game", and create a new folder in there. Name it something that makes sense, but avoid spaces and special characters. And then create another folder inside it named "materials" For the purposes of this guide, I will create one and name it "tf_fixes".


Then, launch the SFM SDK, if you disabled it before, you can enable it again in the SFM Steam properties.

In the SDK, click on "Edit Search Paths For Selected Mod".

Find your newly created game folder, enable it, and make sure it's above "tf". For simplicity, you can simply drag it to the very top.

------------------------------------------------------------------------
This next part is a little tedious. You will need to create the exact same file path for each material fix. And I do mean EXACT SAME.
But if you're willing to use Command Prompt, it can be much less tedious.
I will explain both methods.
------------------------------------------------------------------------
Manual Folders
Simply Right Click in the current folder and create a new folder, name it the same according to the original VTFs path. Though once you have some commonly shared folders created, you wont need to be making as many folders. Make sure there are ZERO typos, otherwise you'll be left wondering why your fixed material didn't apply.
------------------------------------------------------------------------
Using Command Prompt
You can use Command Prompt to create the folders for you, being much quicker, less tedious, and negates the possibility of typos, so long as you do it correctly.

While in your materials folder of your fixes game folder, click on your directory bar, type "cmd" (without the quotes) and press Enter.
This will open a Command Prompt window at your materials folder.
In the folder of the original broken VTF, select the file path up to "models", like so, and copy it with Ctrl+C.
Then, go to your Command Prompt window and type the following, quotes included(paste with Ctrl+V):
md "<YOUR PASTED PATH HERE>"
If youre following along and using this bonk_hoodie for reference, it would be this:
md "models\workshop\player\items\scout\bonk_hoodie"
Using Command Prompt to create directories while there's already existing folders will not cause any issues. It only creates folders as needed.
Step 6: Saving Your Fixed Texture
Now its time to actually apply your fix to your cosmetic.
------------------------------------------------------------------------
VTF Plugin Method
Back in GIMP, go to File>Export As, in the top left, or use Ctrl+Shift+E. Then navigate to the folder for the material in the Export Window that just appeared. If you followed the previous step, you'd navigate to the folder you just created in that new game folder. Do not change the name.

In the VTF settings window that pops up, disable Mipmaps, doing so saves space and increases texture quality. Compression On/Off is up to you. Just make sure that Alpha is enabled.

Press OK to export the VTF.
------------------------------------------------------------------------
VTF Edit Method
Back in GIMP, go to File>Overwrite, or File>Export As>Save it as a PNG. The location doesn't really matter. The default PNG Export settings are fine. Just make sure that "Save Color Values Of Transparent Pixels" is enabled.
Then open VTF Edit, and in the top left go to File>Import, and import your newly saved PNG.
The default VTF Options should be fine, just press OK.
Then go to File>Save As in the top left, and navigate to the folder for the material. If you followed the previous step, you'd navigate to the folder you just created in that new fixes game folder.
Make sure the name of the VTF you're saving is exactly the same as the broken original.
Step 7: Finished
Once your now fixed version of the VTF is in the correct place, you're now good to go.
If you did all this with SFM open, use
mat_reloadallmaterials
to reload the texture(s). If you also created and enabled the game folder while SFM was open, you'll need to reboot it.

Conclusion
I'm pretty sure I covered everything. If you think I somehow missed something, leave a comment. I'll make sure to update with any new information.

Practice fixing cosmetics and you'll get faster at it and you won't need this long winded guide.

Here's the video from the start of the guide, see if you can follow along: