MDL to VMDL Conversion

edited June 2015 in Tutorials

This guide will go through the process of making a .vmdl file (Source 2 Model) from a .mdl file and other model-related files from Source 1. The Wyvern Hatchling courier will be used as example, but the same process applies to heroes, buildings and any Valve Dota model.

Required Tools

1. Acquire the model and material files from the main game VPK (pak01_dir.vpk) using GCFScape.

The following file types are required:

  • .mdl
  • .vvd
  • .dx90.vtx
  • .vtf

Model files will be in a subfolder of the /models/ folder:

img

Right-click extract into a folder of your choice.

img

Color Material files are located in the the materials/models/ folder. In this example this courier has 3 associated color files, one for each skin, so we'll get

img

Finally we should have these:

img

2. Use Crowbar to decompile the model files into meshes (.smd)

img

img

Result on the output folder:

img

3. Use VTFEdit to generate color TGAs out of the VTF files acquired in step 1.

img

img

Do File-> Export.

Result (IrfanView is an oldschool image viewer that can open TGAs just fine):

img

4. Move the generated files to your addons /content/ folder.

  • Move the decompiled files generated in step 2 to /content/models/

img

  • Move the TGA files generated in step 3 to /content/materials/

img

Create new folders on each or just drop the files over the respective directories. Make sure to use the content folder (not the /game/).
The location of the reference mesh in /content/models/ will determine the location where the .vmdl file will be saved.

5. Generate a .vmat file from the TGA files.

  • Open the Material Editor
  • File -> New Material
  • Without doing anything yet, Save the empty material with the name of the TGA you want to make a .vmat for. img
  • Browse and find the TGA to use img
  • The file should be visible by default with the _color. extension img
  • Save the final material. img

6. Make a New VMDL from the Mesh file (.smd)

  • Open the Model Editor
  • New VMDL from Mesh File (Ctrl+M) img
  • Select the reference .smd file generated in step 2. img
  • If everything went well you should get a red error mesh: img

7. Add a Material Remap for the missing textures, using the .vmat file from step 5.

  • On the menus, Model -> Add Material Remap img
  • Select the Material Remap List and collapse the properties on the Property Editor img
  • Search Material, select on from the drop down list. These are missing materials which have to be remaped to the the .vmat made earlier.
  • Ctrl+S to save the model, now the model comes together with the texture to take shape:

img

  • IF the model shows as Error, something went wrong. Make sure to delete the auto-compiled models and materials of the same name on the /game/ folders, which are now corrupted. Make sure everything is using the proper names and directories, sometimes the Model/Material editor feel like not working and doing Volvo things.

8. Add the Animations on the _anims folder and make Activities for them.

img

Select all of them.

img

The Animations will now preview when you click over them, the model will move, but for game to use the animations it needs an Activity (the ACT_DOTA_name strings).

On the Sequences window (Do Tools-> View Sequences if it doesn't show up), make sure Activity is selected. It will show an empty list between brackets []

img

Now, select each animation you want to have a activity for.

img

On the Property Editor, there is a an Activities element which will have 0 items by default. Click on the + to add one.

img

Add a Name to it, try to use the ACT_DOTA_name that better adjusts to the activity description

img

Finally, we have usable animations:

img

Note: This is also useful to be able to have access to some of the ACT_DOTA_ACTIVITY+string activities that some of the Taunt and Alternative animations use which currently can't be used for abilities and other purposes (as it just ignores the +string part).
Knowing this, it's possible to assign some unused activity string like "ACT_DOTA_MINI_TAUNT" and force its usage trough the OverrideAnimation KV.

9. Add the Hitboxes

Go to Model->Hitboxes->Auto Populate and accept the list of all bones.

img

If you enable Display-> Hitboxes and Hitbox Names you should see something like these:

img


Final result is the finished model with all its animations (hopefully):


The concept of Modding Community doesn't go well together with Competitive Business
My Project Page || My GitHub Profile ||

Comments

  • edited May 2015 Posts: 45

    Excellent guide Noya!

    Been trying to go through and recolour Rubick, which I seem to have succeeded in doing thanks to the guide, but I'm at a loss as to how to force the game to use his new model instead of the default without causing his animations to break.

    The first case I tried using "model" and setting it to "rubick_reference.vmdl". This worked, but only for one part (expected, but annoying nonetheless) and the animations broke.

    So I decided I would instead replace the content by putting it on the same path ("models/heroes/rubick") and renaming them to match. This worked... but the animations are still broken. He just slides around.

    Would there be any reason this is happening? Am I missing something?

    UPDATE: He can't be targeted as well, which makes me think the model isn't being loaded properly, but it looks fine (no ERROR blocks or anything). Precaching the model folder does nothing.

  • edited May 2015 Posts: 1,670

    Yeah there's 2 things I missed that I have now added, thanks for pointing it out :)

    1. On Step 8, for the game to use the animations it needs an Activity (the ACT_DOTA_something strings). Check the edited step 8

    2. For the Hitboxes, go to Model->Hitboxes->Auto Populate and accept the list of all bones. Added a 9th step for this.

    There's also 2 things missing:

    1. Particle Attachment Points. Refer to kritth's brilliant tutorial for it: Importing custom model without any cosmetics, Step 8. His guide also mentions most of the steps explained in this guide but also has a ton more information about non-valve models.

    2. Material Shader Masks. If you check the original wyvern courier gif, you'll see that the golden version is way more shiny than the basic end result. This is because when doing the material, some extra .tga textures can be applied to it for better effects. Follow the instructions on the next post by @Toyoka to understand the magic of texture effects.

    The concept of Modding Community doesn't go well together with Competitive Business
    My Project Page || My GitHub Profile ||

  • edited May 2015 Posts: 13

    Hey Noya, thanks for this guide, it'll be really helpful for a lot of people (including me)!

    As requested, I will provide instructions on how to utilize the 2 texture masks (masks1 and masks2) as part of the .vmat to give the model it's fully realized quality. Instructions below (note, I will be using Photoshop. If you do not have Photoshop, you can use Gimp or other free alternatives which support RGBA [yes, all 4] channels and the TGA texture format):

    Shader Type

    In order to utilize the masks1 and masks2 textures, you will need to change the shader type from the default Global Lit Simple (GLS) to the Hero shader. This is because the Hero shader is used not only by hero character models, but also by couriers which use the same types of textures.

    Getting all the required texture files

    Fortunately (or unfortunately, depending on how you look at it), Source 2 overhauled the way materials and textures work. In Source 1, the effects of a texture were split into the 2 masks textures. In Source 2, each of the effects these 2 masks represented now have their own image file. This allows for a greater control of each effect, allowing one to tweak each individual one to their liking without having to go back and forth between programs to do so. But it also requires more time to create them (especially if you are converting models from Source 1).

    Notice that each channel stores a separate function of the hero shader. You will need to recognize which channel corresponds with which effect within the Source 2 Material Editor. If the channel is pure black, that means it does not have an effect on the model (in which case you don't need the texture in the material editor, leave it as a black color) http://i.imgur.com/HROZkK9.png

    You will need to open the masks1 and masks2 .TGAs in photoshop (or an RGBA channel and .TGA compatible editor) and go over to the "channels" tab.

    http://i.imgur.com/tIVRFJO.png This is the Masks1 .TGA that the golden baby wyvern courier uses. As you can see, Red and Green are both pure black, and thus do not have effects on the model/texture and do not require a texture in the material editor. The blue and alpha channels however do have texture information. Refer to the shader guide image from before; the blue texture is Metalness (Metalnessmask as referred to in the Source 2 material editor); the alpha texture is self-illumination (Selfillummask as referred to in the Source 2 material editor)

    In order to split these channel effects into their own images, you can do so simply by creating new blank image files with the same size (in this case, 256 x 256), naming them accordingly and then copying the corresponding channel into the new image as a layer. The metalness (blue) mask will be named baby_winter_wyvern_gold_metalnessmask and the self-illumination (alpha) mask will be named baby_winter_wyvern_gold_selfillummask. Once all the effects are named properly and have been split up, save them as Targa (TGA) images in the appropriate directory (they should be stored in the same folder as the _color and _normal textures you extracted earlier in the tutorial).

    Finally, you can start to input each texture to its proper place within the masks1/masks2 properties. http://i.imgur.com/tLJzYhN.png You will also likely notice that the texture becomes darker. This is a result of the self-illum mask taking over the majority of the texture's lighting (the black in the self-illum is darkening the rest of the texture) which will require some manual tweaking to lighten-up the texture. You may also find that the specular (shine) on the material is not the right color. This will also result in some manual tweaking to find the right tint of shine to your liking. You may also note that the cubemap provided in the files for the golden baby winter wyvern is not supported by the material editor. You will have to make due with the default cube map or convert the one given into a proper cube map on your own.

    http://i.imgur.com/T4EDBhg.png

    From here on out (if you're following this tutorial to mimic the golden wyvern courier, as an example) the texture tweaking is yours to control. Experiment with the different settings (and save often! the material editor is prone to crashing often) and see what you can come up with

    http://i.imgur.com/vVVzoKO.png

    Tada!

  • Posts: 22

    The link provided for VTFEdit (1.2.5) is outdated, and can only open VTF files with version 7.0->7.4, whereas (most?) DotA textures use version 7.5!

    VTFEdit Version 1.3.3 solves this: http://nemesis.thewavelength.net/index.php?c=238#p238

    No idea why this isn't on the frontpage of Nem's Tools, but it might be worth making a note of this and updating the link. :highfive:

  • Posts: 1,670

    Weird, I had no issues opening any of the VTFs. Updated the main post with the newest link regardless, thank you.

    The concept of Modding Community doesn't go well together with Competitive Business
    My Project Page || My GitHub Profile ||

  • Posts: 22

    I've used this guide for a few reskins on an SFM2 project I am working on and I've noticed that after I recompile a model, all the bones are there but non-bone variables (ie, face-posing sliders) dissappear.

    Does anyone know how to keep these when I recompile, or failing that, does anyone know a good doctor to restore facial muscles?

    I ask because at the moment I am stuck with THIS for my animation...

  • Posts: 71

    Is there a tutorial for creating the portrait, or how to make the portrait? I've successfully imported the tf2 player models, medic, heavy, etc, but have yet to figure a way to create the portraits. I've looked into the attachements for attach_origin, and the activity of act_dota_capture. None of which seem to work. Any thoughts?

  • Posts: 1,670

    google dota portrait http://imgur.com/a/gUWhL#0

    The concept of Modding Community doesn't go well together with Competitive Business
    My Project Page || My GitHub Profile ||

  • edited August 2015 Posts: 71

    Ok thank you. Edit - I looked over a few tutorials, all of which say the same thing, but none have worked for a "custom" model. The portrait debug doesn't want to work for me in the reborn tools. I'll continue looking into it tomorrow.

  • are you talking about the ingame portrait or the portrait in the hero selection @Sidearms

  • Posts: 71

    In game portrait

  • edited September 2015 Posts: 4

    How to attatched particle?

    this courier's gold style has twinkle effect. how to attatch it?

  • So does this no longer work anymore? Since source 1 dota 2 is gone...

  • Posts: 858

    It still works fine... all of the default dota stuff has been converted for us so theres no need. CSGO/TF2/etc still work fine

    MAKE CUSTOM GAMES GREAT AGAIN

    Finished-
    kv checker - https://arhowk.github.io
    panorama video series - https://moddota.com/forums/discussion/2021/inclusive-panorama-tutorial-quest-box

    My pet project This Cursed World/Crestfallen (name pending)
    https://moddota.com/forums/discussion/986/this-cursed-world-rpg#latest

  • Posts: 1,670

    We still have no easy access to decompiled VMDL so if you can get your hands on the source1 files I think this is the most reliable way to get it working.

    The concept of Modding Community doesn't go well together with Competitive Business
    My Project Page || My GitHub Profile ||

  • Posts: 4

    crowbar can't see my files

    enter image description here

    crowbar version decompiled 0.34 :blink: Why does this happen ?

  • edited April 2016 Posts: 1,670

    It expects mdl and you just have .vmdl_c, this guide is for source1 files and step 1 isn't valid anymore if you use the reborn vpk

    The concept of Modding Community doesn't go well together with Competitive Business
    My Project Page || My GitHub Profile ||

  • Posts: 4

    need to do ?

  • edited April 2016 Posts: 127

    You need Dota 2 on old Source 1 Engine! Until someone or :valve: release something like Crowbar Decompiler! But for Source 2.