Insurgency

Insurgency

98 ratings
How to make GGX shaders for your weapons
By phale
Have you done a little texture editing? Do you want to take the next step and make your weapons look more realistic? In this guide I'll show you how to apply new GGX shader techniques to your weapons.
   
Award
Favorite
Favorited
Unfavorite
Introduction

Hello everyone! In this guide I’m going to show you how to make GGX shader retextures for your weapons. You should already have a basic understanding of texture editing: how to extract texture files from the game, how to edit them, and how to export them back into the game. This is not a beginner texture editing tutorial.

There’s two key components behind GGX shaders: an exponent map (texture) and a .vmt file (text). To edit these, you’ll need VTFedit, a multi-channel image editor (Photoshop or Gimp), and a text editor.

The exponent map has a few components: Roughness (red channel), Metalness (green channel), and Fuzz (blue channel). Each of these should be carefully adjusted to produce the best results.
Roughness (red channel)
The roughness map (red channel) basically determines which parts of the weapon are shiny and which parts are matte. You might also call it the specular map, gloss map, phong map, or something different. Bare metal is shiny, wood and plastic are less shiny. Metal with paint or coating on it is not shiny, but scratches and wear on the coating are shiny.

If you’re confused by this, don’t worry. You can simply take the specular map from the normal map’s alpha channel. Open the normal map of the texture you want to edit in your image editor and switch to the alpha channel (not the RGB channel).


Copy and paste this into a new file. This will be your roughness map. You can edit this as you wish or leave it; I find that increasing brightness and reducing contrast tends to produce good results.

Metalness (green channel)
The metalness map (green channel) is supposed to determine reflectivity. For instance, a polished mirror would be perfectly reflective, while rough dirt would be perfectly non-reflective. However, in-game, the green channel doesn’t really work this way. It pretty much only adjusts the brightness of the color texture. Sometimes this is still useful, other times it isn’t.

Think about your color texture (diffuse map). Is it mostly uniform, such as the M16 which is all black? Or does it have varying colors, like the brighter brown wood and darker black metal of the AKM? If the texture is mostly uniform, you can ignore the rest of this section, save your texture as a new file, and move on to the .vmt. If it has varying colors, then using the green channel will be useful.

Copy the roughness map into a new file. Now, invert it. The darker parts (think: metal) should now be brighter, and the lighter parts (think: non-metal) should now be darker. The idea is to make the metal parts darker and the non-metal parts lighter, to emphasize the difference in materials.


Now, we don't want the dark parts to be too dark. Copy and paste the layer you just made to a new layer. Invert it again (so now it should be back to the same as the roughness map). Set the blend type to "lighten".


You'll want to play with the brightness and contrast settings of the two layers here so that the non-metal parts are almost full-white and the metal parts are uniformly darker (but not too much darker). I usually slightly increase the brightness of the inverted layer and reduce the brightness of the non-inverted layer.


Once you are happy with it, merge the layers together so you have 1 layer you can copy into a different file.
Fuzz (blue channel)
The fuzz map (blue channel) is used to simulate cloth and skin, and is not relevant for weapons. I use full white.

Let's combine the channels together now. Go back to the roughness map (red channel). If necessary, change the mode from grayscale to RGB.


Copy the merged metalness map into the green channel of the roughness map. Select the blue channel and fill it with white. It should look like this:


Your exponent texture is now complete. Save it as a new VTF file and put it in the same folder as the other files. I recommend saving it as (name of texture)_spec.
Editing the .vmt
Now, open the .vmt file in a text editor. Copy and paste this template into the .vmt file:

"SurfaceGGX" { "$basetexture" "models\weapons\your_weapon\your_weapon_dm" "$bumpmap" "models\weapons\your_weapon\your_weapon_nm" $phongexponenttexture "models\weapons\your_weapon\your_weapon_spec" "$color" "[1.0 1.0 1.0]" "$roughnessmultiplier" "0.7" "$metal" "1" }


Change the $basetexture and $bumpmap to match the original .vmt, and change $phongexponenttexture to the new VTF file you just created. If you skipped the green/blue channels because the weapon has a uniform color, change $metal to 0 (this will effectively be a full-white metalness map, which does not make it brighter or darker). Delete the old text that was in the original .vmt and save your file. Check the results in Half-Life Mesh Viewer. Protip: select “Enable three-point lighting” under the options menu in HLMV for better lighting.

Now, tweak the $roughnessmultiplier to your liking. A lower $roughnessmultiplier is more shiny, while a higher $roughnessmultiplier is more matte. I usually find that between 0.6 and 1.0 is best. Remember what I said in the roughness section. Weapons that have bare metal (think AKs) should use a lower roughness multiplier. Weapons that are painted or have a coating (think M16s) should use a slightly higher roughness multiplier. This number will have to be tweaked in conjunction with the brightness of your roughness map.

You can also use $color to tweak the color and brightness of your texture. If you used the green channel, your weapon will likely be a little bit dark, and you’ll want to bring $color to around [2.0 2.0 2.0] to be similar to the vanilla brightness.

Conclusion

And that's pretty much it! Try your new shaders in-game. Look at them in different lighting environments: bright sun, in the shade, inside a building, etc. Is it too shiny? Too flat? Adjust the roughness multiplier in the .vmt, or adjust the roughness and metalness maps in your image editor.

Note that if your weapon has many separate textures, you'll have to follow these steps for every texture. Also, GGX shaders don't work with $selfillum, so it won't work with night sights!

Here are the key takeaways that you need to understand to make your shaders look good:
  • How metal and non-metal parts reflect light differently
  • How to use the roughness and metalness maps to highlight the differences between metal and non-metal parts
  • How to balance the textures so that it doesn't look too reflective in the shade or too flat in the sun

Have fun experimenting, I'm excited to see what you guys can come up with!

Here are links to my GGX collections for Insurgency and Day of Infamy:
https://steamhost.cn/steamcommunity_com/workshop/filedetails/?id=1415274819
https://steamhost.cn/steamcommunity_com/workshop/filedetails/?id=1282678660
18 Comments
游侠--和平至上 12 Dec, 2021 @ 5:48pm 
can it work in INSURGENCY ?
TheBlueSalamander 2 Sep, 2021 @ 3:15pm 
what are GGX shaders?
Watermelon Farmer 2 Sep, 2021 @ 9:57am 
Absolutely amazed by the results... Very informative and useful thread. Thanks a lot for posting!
squidgame 22 Feb, 2020 @ 10:31am 
lissen m8 lissen m8 just li---
merydian 11 Jan, 2020 @ 12:54pm 
Just wow. Im really curious, how did you find this all out?
♣ Jacket ♣ 16 Oct, 2019 @ 11:05am 
Would this work for non-source games?
Zanedor 16 Oct, 2019 @ 10:29am 
<3
1v4n94 27 Aug, 2019 @ 7:30pm 
@Staedtler
By deleting the vmt file, or by removing the GGX part, from " to }
Staedtler 12 Jul, 2019 @ 11:09pm 
how to remove ggx?
yep 3 Jul, 2019 @ 9:04am 
ENG: rate my profile illustration, and I will write to you in your profile +REP:gr_serious:
RUS: оцените мой профиль иллюстрации, и я напишу вам в вашем профиле + REP:gr_serious: