Garry's Mod

Garry's Mod

Not enough ratings
MW Sweps Creation Guide
By thatrtxdude and 4 collaborators
mw sweppies real
   
Award
Favorite
Favorited
Unfavorite
TODO LIST FOR THE GUIDE
Add Images
Better Formatting
silence thy voices
adding more bentley
What you need
I don't have a good introduction for this, so let's get straight to the point.

You need:
  • Blender and Blender Source Tools[steamreview.org]
  • Crowbar[github.com] for compiling, decompiling, unpacking addons, etc
  • CS:GO or SFM's StudioMDL (For CS:GO you need the Authoring tools which requires Prime)
  • Mushroom guy's MWB Material tool (look at #creator-chat pinned)
  • Some sort of Text Editor with Syntax Highlighting, like Visual Studio Code, Notepad++
  • Unpacked version of any MW SWEPS pack you want animations from
  • Optionally you can also get VTFEdit[nemstools.github.io], but it isn't necessary for this tutorial
  • Some basic Blender knowledge
Preparation
I take it that you have already found a 3D Model of the gun you want to make, but if you haven't, websites like Sketchfab and P3DM exist. You can also rip assets from games or join an asset ripping discord. (Game ready/ Assets from fps games recommended)

Locate the gun you want the animations from, and decompile it by dragging the .mdl file into Crowbar, then select "Decompile" at the bottom.

Both guns should generally match up in shape, or animations will look out of place. You can edit animations, but I wont go over that in this guide. Make sure you have Output to selected as Subfolder (of MDL input). You should see a new folder called "decompiled".

Now import the gun you want the animations from and the gun you want in Blender.
Rigging
Now that you have loaded everything in, move the gun you want to the same position of the gun you want the animations from. If your gun is one mesh, open edit mode and separate it by changing the Select mode to Surface Select and then pressing L on your keyboard to select a surface. If your mesh has Vertex Groups, you can also use those as well to separate the mesh. After you have selected something like the slide, press P on your keyboard and select "Selection." Your mesh is now split up. The separated mesh should still have Vertex Groups and a Armature Modifier, remove those.

Now we can move onto the actual rigging part of this guide.
I am going to use parenting for this guide, as it's much easier to do. You should use weight painting but this works just fine as well.

Select one of the separated objects, then select the Skeleton/Armature. Now press CTRL + P and go down to Armature Deform and select "With Empty Groups". Your mesh is now parented and should now have Vertex Groups and a Armature Modifier. Now go back into edit mode and select the separated mesh again, then go to Object Data Properties (the green icon, or click the grey icon besides the mesh name).

Now in the Vertex Groups window find the bone you want to rig the mesh onto. The names should be pretty self explanatory. You rig the slide to j_slide, etc. Once you found the Vertex Group you want to rig to, make sure you have the entire mesh selected, then click on the Vertex Group and then "Assign". Repeat this for all the other meshes. For the main body of the gun (the parts that don't move), rig the frame to tag_sling for assault rifles, shotguns, snipers, lmgs and marksman rifles. For pistols rig the frame to tag_pistol_offset.

You can now load an animation to see if everything works.

Exporting & Compiling
Now that you are done with the rigging process, put all the meshes you just rigged into one collection. Select one of the meshes and go to Material Properties and make sure that all materials have "Use Node" turned off. If not, click on it to turn it off. Repeat the process if you have multiple materials with different meshes. Now change the name of the collection to the gun. Now go to Scene Properties and open up the Source engine export menu. Change the export format to .smd and change the export path to where your decompiled .qc is.

Click on export, then Scene Export. This should give you a warning, just ignore it.
You should see a .smd file with the same name as your collection in the folder now.

Now open up the .qc with any text editor. Change the $modelname "example.mdl" to something like $modelname "v_whatever_gun.mdl". In the first $bodygroup change the studio "example.smd" to your gun .smd name. Remove the other $bodygroups if you don't need them.

Now go down to $cdmaterials and copy the line, so you have a second one. Change the copied $cdmaterials to something like $cdmaterials "models\weapons\rtx\galil\". Remember this path.


If we want to compile now, the compiling would error out. To fix that, we need to replace every instance of usesequence with usesource. Press CTRL+H and find "usesequence" and replace with "usesource", then click replace all and save. With this method you can also edit animations, without causing any errors by removing usesequence all together. I don't know of any downsides (yet).


(If you wanna know more about usesequence and usesource, go to this link.)

Now drag the .qc file into Crowbar. You should be in the Compiling tab now. Select the game you want to use, perferably CS:GO, Half-Life 2, Counter Strike: Source or Garry's Mod. Modified StudioMDL Compilers also work, such as Cra0kalo's. Now click on compile. In the folder you should now get a compiled folder.
Materials - Normal map type
Before you create a texture, please note that Source engine is using DirectX normal map.
Here is the comparison between 2 types of normal map

.jpg]
As you can see, the main difference between these 2 are that DirectX have a inverted green channel compared to OpenGL.

How to know which is which ?
As you can see, because of inverted nature of DirectX normalmap, it would looks somewhat opposite to it supposed to be on the texture.
for example, this M4 markings supposed to be engraved-in.
The OpenGL's normal map would looks like it's also engraved-in like this.

In the other hand, the DirectX's normal map would looks like it popped out.


Conclusion
As I said that source use DirectX normal map, if the texture you got have OpenGL normal map, just invert the Green Channel of the normal map using Photoshop before you putting it in source, or just check the "OpenGL normal" in the setting of MWBtex before converting the texture.
Using MWBtex to create Materials
Thanks to Mushroom guy, creating materials has never been easier than now. You no longer need to sit around in Photoshop for ages creating subpar materials. Get the lastest release here[github.com]. Place the the contents of the zip somewhere you can easily access.
(Only use this with PBR Metalness texture)

Now, navigate to where you have the textures for your gun. If the Roughness, Metalness and AO map aren't separate, use a tool like GameImageUtil[github.com] to split them up.

Now rename the textures like so:
  • nameofyourgun_rgb for Albedo/Color Map

    (This is the base color for your texture)
  • nameofyourgun_r for Roughness map or nameofyourgun_g for Glossy Map

    (This define how much each part shine)
  • nameofyourgun_alpha for Metalness Map

    (This define the metal/reflective parts on your texture)
  • nameofyourgun_o for Occlusion Map

    (This is used to create "shadow" from ambient light)
  • nameofyourgun_n for Normal Map

    (This is used to create "depth" when the texture react with incoming light)

Now start the tool. The standard settings are good enough, so we won't change them. Click on "Open Folder(s)" and find the folder where your textures are. Make sure that the folder structure where your textures are located don't have any spaces, or the tool won't know where to put the finished .vtf files. Select the folder and wait. After the tool is done, you should have a folder called output with .vtf files inside of them. You might need to rename the .vtf files, as they use the folder name where they were located in instead of the texture name. Open the .vmt file, also located in output along with the vtf files.

Now, add the $cdmaterials path to $basetexture, $bumpmap and $phongexponenttexture.
So "$basetexture" "\galilsar_rgb" becomes "$basetexture" "models\weapons\rtx\galil\galilsar_rgb" for example. Now we can move onto the folder structure. If the pathing and texture name is right, there shouldn't be any missing texture.

If all is correct, they should look somewhat believable.
here's the final product of texture above in HLMV.
.png]
if anything, you can always tweak how it looks using vmt file, play around with it.



Folder Structure & Material, Texture, Model Copy and Paste
Now find your GMod installation, and go to garrysmod/addons. Create a new folder here, the name doesn't matter. Inside of this folder create 3 or 4 folders depending if you want custom sounds.
Those are
  • lua
  • models
  • materials
  • sound

Now, in "materials" folder create the file path of your $cdmaterials. For example, I made a folder called "yourpath", then a folder called "example folder". In the end you should have something like this: materials\yourpath\examplefolder.

now put the vmt and vtf files you got into this folder just like this


After that, go into models. You can just put your mdls here, but for a cleaner and more consistent folder structure I recommend making folders that are similar to your $cdmaterials file path. It should look like this: models\weapons\rtx\galil.

In the lua folder, create a folder called weapons. You don't have to do anything yet in here.

In the sounds folder you can create any folders, as it doesn't matter.

Once you are done with the folder setup, open a separate Explorer tab or open a new tab if you are using Windows 11, navigate to where you have your compiled models, and copy them. Then paste them into your models folder. Do the same with the textures and materials, but paste them into the materials folder. (duh)
Lua
(UNFINISHED)
Bones Handling and Bonemerged Attachments
Modern Warfare Base makes use of attachment bones to place their attachments models in a weapon by merging these attachments directly in his correspondent bone also the muzzleflashes effects and shell eject needs of these bones to can be generated. Usually when we Rig a weapon model on a MW Base Set the attachments position and effects does not matches well to it, looking miss placed or clipping trought the weapon in question, so is needed manual work to place them in a correct place, thats why we need to learn how to work and handle bones in the QC to correctly do the proper work to the attachments and effects position of our weapon.



So lets start explaining what is $Definebone in the QC means and how to handle it:

Example_1.png

First of all this is the way of how existing bones in the model gets defined in the model QC it haves some strings and various sets of numbers corresponding to the next order:

Example_2.png

Bone Name: Its the name of the bone that we have in our model and we want to define in the QC.

Attach Bone: Its the name of the bone to what we want to attach our bone.

First Set of Numbers: Are the vectors and angles of a defined bone, this set of numbers can not be editable if the model that we descompilled already haves defined the bone, otherwise if we define a new one we must edit this set.

Second Set of Numbers: Are the vectors and angles of a defined bone, this set of numbers can be editable if the model that we descompilled already haves defined the bone and its the set of number that we will work in major part of the process.

Its important to take in count that the first set of numbers its the base position of the defined bone and second set of numbers its additive, this mean that the second set of numbers will adds his values to the first one, anyways we will work them with additive method correcting the position in base of the original one.

Now knowing the previous information we are able to work attachment bones in blender and translate it to QC with this way we can also fix muzzleflash and shell eject bones position. So first we need to import our model to blender, thing that all us should already know, then we can see all the bone, now proceed to select "Pose Mode", click in "Armature" select "Octahedral Bone Type" and unselect "Bone Shapes", this will help us to see better what we are doing.

EXAMPLE_1

EXAMPLE_2

After that select the bone that want to work, all what we need to do now its move that bone to the correct position, i recommend to enable this before start moving the bone:

EXAMPLE 3

You can also use the entire zoom for max accuracy:

EXAMPLE_4

EXAMPLE_5

EXAMPLE_6

Then after you fix the bone position, proceed to press 'N' to open this panel:

EXAMPLE_7

Heres all the vectors and angles values of the current position of our bones, now we will take these values and put them in the defined bone values, due this is an already existing bone i will put these values in the second set of numbers, so these new values will adds to the first set of numbers thats usually uneditable after compile.
2 Comments
Frank Blaskovich 4 Jan @ 6:46pm 
help
Frank Blaskovich 20 Jun, 2023 @ 10:39pm 
gonna do this with the mw dualies, wish me luck