Tutorial: How to reskin your portal gun.

Avatar
sicklebrick
876 Posts
Posted Dec 02, 2012

//--------Intro

I get asked how to do this about once a week at least but generally can't be assed explaining things properly, so here we go; a full on guide.

Let's split it into sections. I will personally slay anyone who skips Part 1. Try me.

1- Preparing folders.
2- Getting the original texture
3- Patching the original texture
4- Drawing your own stuff on top
5- Packing it all up.
6- Donesies.

//--------Part 1: Preparing folders

In previous games, you could just dump extracted loose files into whatever folder and the game would read it. Now it's not so.

I'm assuming you've installed steam to
*c:\program files\steam*

If you've installed to
c:\program files (x86)\steam
or
**c:\program files\valve\steam **
(or wherever else) use that instead. Chances are if you're on 64bit windows, it's the (x86) folder.

Let's begin:

Open up your
c:\program files\steam\steamapps\common\portal 2** folder and create a new folder called "portal2_dlc3**" (without the quotes). So:

*c:\program files\steam\steamapps\common\portal 2\portal2_dlc3*

then pak01_dir
then materials
then models
then weapons
then v_models
then v_portalgun

It'll look like this, and is clearly designed to mess with dyslexics.

C:\Program Files\Steam\steamapps\common\portal 2\portal2_dlc3\pak01_dir\materials\models\weapons\v_models

[Did you know? You can push ALT+D and paste these folders into your explorer window. Cool huh?]

//--------Part 2: Extracting the original texture.

Tools:
-- GCFScape:
-- http://nemesis.thewavelength.net/index.php?p=26
(If it doesn't run install the f**king runtimes like the forum post suggests....)

Fire up GCFScape, and open this file:
C:\Program Files\Steam\steamapps\common\portal 2\portal2\pak01_dir.vpk

Inside, follow the folder structure we created earlier:
/models/materials/weapons/v_models/v_portalgun/v_portalgun.vtf

and drag it out into the last folder you created earlier, you should now have:

C:\Program Files\Steam\steamapps\common\portal 2**...
...
\portal2_dlc3\pak01_dir\materials\models\weapons\v_models\v_portalgun.vtf**

Make a copy, call it v_portalgun_original.vtf or something.
Seriously, you'll thank me.

Close GCFScape.

//--------Part 3: Patching the file:

Tools:
-- Patcher thingie:
-- http://sicklebrick.com/hotlinks/vtf_patcher.rar

Now, there are a few programs available to edit the texture, but they generally use the same copy of "VMTLib" - the code that does the actual conversion. Since Portal 2 is much newer than these, they will throw a version error saying the file is too new. If we manually change the version number however, everything will be fine.

Download the stuff in that .rar file and extract it somewhere or other.

Make sure nothing has your texture open (i.e. You've not tired to skip a few steps and open it) and drag your v_portalgun.vtf file onto patcher.bat

If you see "1+0" records out, then it worked.
If you see "0+1" records out, then something went wrong.

But assuming you didn't skip this bit, you'll realise I included a patched copy of v_portalgun in the .rar anyway.
So uhh, use that.

//--------Part 4: Editing the texture, finally...

Tools:

--VTFEdit
--http://nemesis.thewavelength.net/index.php?c=178

OR

--VTF Plug-In for Photoshop
--http://nemesis.thewavelength.net/index.php?c=154

You can use either of these tools. VTFEdit is probably more noobie friendly and supports animations, while the photoshop plugin is awesome if you're used to photoshop. (Works in photoshop 6+)

//----VTFEdit Way:

Open your patched v_portalgun.vtf with VTFEdit

Go file->export and save your file, for example "bubble.jpg"
.JPEG should be fine here.

Note:
If saving as a .BMP (bitmap) photoshop can't read the file, open it in MSPaint and re-save.
If saving as a .PNG you may encounter an alpha bug even with "Mask" setting.
If saving as a .TGA (targa) then obviously you'll need something other than mspaint.

Draw all over your file... Draw something fancy. Have fun, but just don't change the width\height\etc

Then back in VTFEdit, go file->import , select your "bubble.jpg" again.

You'll get a settings popup - the default values should be fine in this case.
Hit OK.

(Normal Format: DXT5 , Alpha Format: DXT5, Texture Type: Animated Texture, Generate Mipmaps: Yes, Mipmap Filter: Box, Sharpen Filter: None, Resize : Yes, Resize Method: NPO2, Resize Filter: Triangle, Sharpen Filter: None, Clamp: Yes, Max Width: 4096, Max Height: 4096, and Generate Normal Map: No. incase you messed 'em up)

Now hit save, and save over your v_portalgun.vtf file again.

//----Photoshop Plugin way.

Drag file in.
Edit.
Save.
(remember to hit Ctrl+Shift+E to flatten layers first)

//--------Part 5: Creating a .pak file.

Tools:
--Portal 2 Authoring Tools Beta
--(Beta or higher) Install via steam.

Right, we're almost done here, just gotta get portal to read the file. You psyched? I'm psyched. I'm needlessy wasting your reading time right now, huh? Let's go.

You should now have:

C:\Program Files\Steam\steamapps\common\portal 2**...
...
portal2_dlc3\pak01_dir\materials\models\weapons\v_models\v_portalgun.vtf**

Go back a few folders so you're in:
*C:\Program Files\Steam\steamapps\common\portal 2\portal2_dlc3*

In a separate window, open this folder:
*C:\Program Files\Steam\steamapps\common\portal 2\bin*

Scroll down 'till you find "VPK.exe". If you don't have it, remember to install Authoring Tools Beta from your steam tools menu. (Alternatively you can use the vpk.exe from Left4Dead or Alien Swarm - they're compatible)

Drag your "pak01_dir" folder onto "vpk.exe" in the other window.
It'll take a second and create a file for you : "pak01_dir.vpk"

You should now have a folder:

*C:\Program Files\Steam\steamapps\common\portal 2\portal2_dlc3*

which contains:

pak01_dir.vpk and a folder called pak01_dir

(For future purposes, you can deag a shortcut to VPK.exe into your dlc3 folder, then drag your pak01_dir folder onto the shortcut, so you don't need to open more folders)

//--------Part6: Run the game.

Wow right? Fiddle with it till you get it right.

//--------Alternative/Advanced Methods

//----Patching the .vtf

Hex the 8th byte from 0x05 to 0x03.

//----Avoid creating a .VPK

This is the method I used at first before realising it's pretty impossible to keep track of.
The .VPK format stores the first kilobyte or so of data for each file in the actual index...
Now as we know, .VTF files are read from the .VMTs ...which are only a couple of hundred bytes tops.

Thus, the bulk of the .VMT files are stored entirely in the pak01_dir.vpk file itsself.

Find the entry for v_portalgun.VMT by doing a string search of byte for byte search:

VertexLitGeneric..{..$baseTexture "models\weapons\v_models\v_portalgun/v_portalgun"....$bumpmap "models\weapons\v_models\v_portalgun\v_portalgun_normal"..

And just change the $basetexture to point at like v_portalBUN or something.
Rename your v_portalgun.VTF to vportalBUN.VTF and put it in a folder like

...common\portal 2\portal2\materials\models\weapons\v_models\v_portalgun\vportalBUN.VTF

I'm lazy and this is generally the method I'd use, but once you've gone through the full tutorial once and you're familliar with it it's generally much faster just to use that method.

For example, by using a shortcut or .BAT file you can update it all with a click or two, with no need to back up the index all the time and you can switch out as many folders as you like with much bigger contents.

//--------Troubleshooting:

-Restart the game between attempts
-Be a doll and write back if I missed something
-You should not have a \portal 2\portal2\portal3_dlc3\ folder portal2_dlc3 should be in the same folder as dlc_2,etc
-This doesn't change the view of the gun you get looking at yourself in a portal. Do that yourself.
-This doesn't work for multiplayer (either for yourself or others).
-Portal will create a bunch of extra folders and stuff when it runs.

Still struggling?
Here's my entire DLC3 folder with trademark shitty pink gun:

http://sicklebrick.com/hotlinks/portal2_dlc3.rar

Enjoy,
Sickle.

Edit:
Changed post title to be easier to google, since I'm still having to look this up about once a week :\

Advertisement
Registered users don't see ads! Register now!
Avatar
FelixGriffin
2,680 Posts
Posted Dec 02, 2012
Replied 43 minutes later
Nice tut!
Avatar
josepezdj
2,386 Posts
Posted Dec 03, 2012
Replied 2 hours later
Great tuto Sickle!

However, since this tutorial is for having your custom skin shown permanently while you play in your computer only, in addition, I'd suggest to include here the how-to make your portalgun and also other models show a customized skin for your maps and how to pack them into the bsp so the rest of players can also watch the same

I was about to make a tuto about that indeed!

Avatar
sicklebrick
876 Posts
Posted Dec 03, 2012
Replied 27 minutes later

josepezdj wrote:
Great tuto Sickle!

However, since this tutorial is for having your custom skin shown permanently while you play in your computer only, in addition, I'd suggest to include here the how-to make your portalgun and also other models show a customized skin for your maps and how to pack them into the bsp so the rest of players can also watch the same

I was about to make a tuto about that indeed!

Heh, could do.. but that's enough writing for one day

Avatar
josepezdj
2,386 Posts
Posted Dec 03, 2012
Replied 2 hours later

sicklebrick wrote:
Heh, could do.. but that's enough writing for one day

INDEED!

Avatar
Askie
7 Posts
Posted Apr 27, 2013
Replied 4 months later
Awesome tutorial! I tried following these steps to change Wheatley's eye color as a test, and it worked perfectly! Except that, when applied, the game's sounds (music, effects, etc.) can't be heard. Did I maybe skipped a step or something, or do you have an idea of what may have caused this?
Avatar
FelixGriffin
2,680 Posts
Posted Apr 27, 2013
Replied 5 hours later
It's an annoying bug in Portal 2 that the sound cache isn't updated automatically unless you run in Tools mode. Open the console and type "snd_updateaudiocache". Then restart the game. See if that fixes it.

If it doesn't, try "snd_rebuildaudiocache". This takes longer but may be what you need.

Avatar
AD_79p2
103 Posts
Posted May 08, 2013
Replied 10 days later
VTFEdit won't open.
Avatar
josepezdj
2,386 Posts
Posted May 08, 2013
Replied 3 hours later

AD_79p2 wrote:
VTFEdit won't open.

Try downloading and installing this.

Avatar
sicklebrick
876 Posts
Posted May 08, 2013
Replied 11 hours later
Thanks jose. Could you tell me if that particular servicepack/update helped you AD?
Avatar
AD_79p2
103 Posts
Posted Jun 25, 2013
Replied 1 month later
Here's the error I get:

"The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command line sxstrace.exe tool for more information".

And that was after I installed that thing Josepezdj said might work.

Avatar
josepezdj
2,386 Posts
Posted Jun 26, 2013
Replied 12 hours later
If you already installed that package and that error is popping up, that should be because you are on a x64-bits system, are you? If so, you'll need both packages, the x86 and the x64 installed in your computer for VTFEdit to work out.

Attached

You can also visit Nem's forums if it keeps failing

Avatar
AD_79p2
103 Posts
Posted Jun 26, 2013
Replied 15 hours later
I tried that, and VTFEdit still won't open. Is there something I am missing?
Avatar
FelixGriffin
2,680 Posts
Posted Jun 26, 2013
Replied 2 hours later
Check for other versions of VS under "Programs and Features" on the control panel.
Avatar
sicklebrick
876 Posts
Posted Jun 27, 2013
Replied 5 hours later

Might also be worth checking that you have the VS2008 and 2010 runtimes both installed.
I'm not sure which it uses, but here's a wee linkie:

http://answers.microsoft.com/en-us/wind ... 5e18e3f3ef

So, all 4 packages I guess. Chances are you'll have the 32 bit for at least one of them already as steam often installs\updates the VS runtimes when you get a new game, but those are normally 32bit.
I'd just grab all 4 to be sure

Avatar
AD_79p2
103 Posts
Posted Jul 14, 2013
Replied 17 days later
FINALLY got it to work. Thanks for all your help!
Avatar
patti2
1 Posts
Posted Oct 06, 2013
Replied 2 months later
How to reskin the portal gun for Atlas?
Avatar
sicklebrick
876 Posts
Posted Oct 06, 2013
Replied 1 hour later
If you follow the tutorial, you'll see the required files.
Same process, but it will only show up for you during coop; the other person sees their own gun skins.
Avatar
JoeyGuy917
146 Posts
Posted Nov 05, 2013
Replied 30 days later

Quote:
-Portal will create a bunch of extra folders and stuff when it runs.

Is this why Portal 2 is taking forever to launch?

Advertisement
Registered users don't see ads! Register now!
Avatar
sicklebrick
876 Posts
Posted Nov 06, 2013
Replied 6 hours later
That will probably be the audio cache being rebuilt if it's taking a really long time.
Wait for the orange dots to finish then close portal. It'll run like normal from now on, and it won't do that again unless you delete dlc3 folder, run portal, create new dlc folder and run portal again. (In that order)