TF2 transparent viewmodels: how to add them to any HUD
The viewmodel is your weapon as you see it in first person. Transparent viewmodels make it see-through, so the weapon covers less of what is behind it. Team Fortress 2 has no setting for this. It is done with a HUD: two material files, one block in hudlayout.res and six console commands. The method is from a teamfortress.tv thread by komorebi, and it works with any HUD.
How transparent viewmodels work
The trick is a refract material. The HUD reference by JarateKing explains it: a refract material shows the world behind it, and with certain settings the game leaves viewmodels out of that picture. A transparent refract material that covers the screen therefore makes the weapon look transparent.
What you need
- DirectX 9. The thread says it does not work on DirectX 8. The launch options guide has the
-dxleveloption. - A HUD folder in tf/custom. Any installed HUD works. With the default HUD, make a folder of your own and put a copy of the default
scripts/hudlayout.resand aninfo.vdfin it: see where the default HUD files are and the folders of a HUD. - The two material files. A
.vtfand a.vmt, both namedREFRACTnormal_transparent. The download is in the thread. This site does not host them.
How to get transparent viewmodels in TF2
- Download the two material files from the thread.
- Put both files in your HUD. The folder is
tf/custom/<your HUD>/materials/vgui/replay/thumbnails. Make the folders that are missing. - Open scripts/hudlayout.res in the same HUD and add the block below, inside the outer pair of curly brackets, next to the other panels.
- Add the six commands below to your
autoexec.cfg. - Restart TF2.
The block for hudlayout.res, with the values the thread gives:
"TransparentViewmodelMask"
{
"ControlName" "ImagePanel"
"fieldName" "TransparentViewmodelMask"
"xpos" "0"
"ypos" "0"
"zpos" "-100"
"wide" "f0"
"tall" "480"
"visible" "1"
"enabled" "1"
"image" "replay/thumbnails/REFRACTnormal_transparent"
"scaleImage" "1"
}It is an image that covers the whole screen: wide f0 and tall 480 are the full width and height in HUD units. The zpos of -100 puts it under the other HUD elements. The image line names the material: it is the folder of step 2 without materials/vgui at the front, then the name of the files.
The console commands for transparent viewmodels
mat_motion_blur_enabled 1
mat_motion_blur_strength 0
mat_disable_bloom 1
mat_hdr_level 0
mat_colcorrection_disableentities 1
mat_colorcorrection 0| Command | What it does |
|---|---|
mat_motion_blur_enabled 1 | Turns motion blur on. The HUD reference says this makes the material work on the HUD at once. Without it, it works only while you are covered in Jarate, bleeding or under water. |
mat_motion_blur_strength 0 | Sets the strength of that motion blur to 0. |
mat_disable_bloom 1 | Turns bloom off. |
mat_hdr_level 0 | Turns HDR off. In the game's help text 0 is no HDR and 2 is full HDR on HDR maps. |
mat_colcorrection_disableentities 1 | Turns off the colour correction that a map sets. |
mat_colorcorrection 0 | Turns colour correction off. |
These lines change how the whole game is drawn: no bloom, no HDR and no colour correction. Put them in autoexec.cfg so they are set at every start. The TF2 config maker has a box named Your own lines for this, and the scripts guide shows where the file goes.
What the .vmt file says
The .vmt is a short text file that describes the material. mastercomfig's docs print this one as an example of a material that makes what is under it transparent:
"Refract"
{
"%keywords" "tf"
"$refractamount" "0.0"
"$refracttint" "{255 255 255}"
"$refractblur" "0.0"
"$scale" "[1 1]"
"$normalmap" "vgui/replay/thumbnails/REFRACTnormal"
}The refract amount of 0 means the picture is not warped, and the tint of 255 255 255 leaves the colours as they are. The last line names the .vtf file. In the thread's download that name ends in REFRACTnormal_transparent.
The HUD reference adds one thing to know: the alpha value of the HUD element has no effect on a refract material. How transparent the weapon looks is set by the alpha of the .vtf image itself.
If transparent viewmodels do not work
- The game runs on DirectX 8. Refract materials need DirectX 9. mastercomfig's addon file puts it as dxlevel 90 or higher.
- mat_motion_blur_enabled is not 1. The HUD reference says the material then works only while you are covered in Jarate, bleeding or under water. If you use mastercomfig, add its addon named
transparent-viewmodels. Its file says that it only allows transparent viewmodels to work and that the HUD still has to turn them on. - The files are in another folder. The thread's path is
materials/vgui/replay/thumbnails, and the block and the.vmtboth point there. - The -nops2b launch option is set. mastercomfig's docs say it causes a blurry scope and ghosting in the killcam with transparent viewmodels.
VAC and sv_pure
These are komorebi's words in the thread, which is more than ten years old: it should never result in a VAC ban, and it should work on all servers, sv_pure 2 included, until the workaround for custom materials is patched. The same post says it might be considered an exploit, because it also changes some map textures, spawn doors among them. This page has no newer source on either point.
Without a HUD: smaller or hidden viewmodels
Two game settings need no files. tf_use_min_viewmodels 1 draws the weapon so that it takes up less of the screen, and r_drawviewmodel 0 hides it. Both are in the viewmodel commands of the FOV guide.
Where this comes from
The steps, the folder, the block, the six commands and the notes on DirectX, VAC and sv_pure are from Transparent viewmodels in any HUD by komorebi on teamfortress.tv. How refract materials work, the note on mat_motion_blur_enabled and the note on alpha are from TF2-Hud-Reference by JarateKing (MIT licence). The .vmt is from mastercomfig's docs (MIT licence, © mastercoms), the note on -nops2b is from its page on launch options, and the addon is this file. The help text of mat_hdr_level and mat_colcorrection_disableentities is the game's own, as listed in mastercomfig's command list.
Next
Set viewmodel_fov to change how large the weapon is drawn, learn what else is in hudlayout.res in the HUD editing guide, or put a custom crosshair in the same HUD.