Destinations

Destinations

Rectus Jun 19, 2016 @ 10:46am
Simple .vmat batch converter
I wrote a Python script to automate part of converting materials to Source 2. It takes .vmt files and outputs them as .vmat files into the same directory. It doesn't support that many material parameters, but it should work on most simple materials that don't masks or fancy shading, and you can use it as a starting point for importing more complicated materials.

Note that the converter only works on material scripts, it doesn't export the actual textures, instead it sets the texture path to look for .tga files with the same names as the original .vtf files. VTFEdit has a batch converter from .vtf to .tga that can be used to bring the textures over.

WARNING: This may overwrite any alerady exisisting .vmat file, so use with caution. I've tested it but cannot guarantee that it won't wreck your files, so use with cauton and always backup your files.

https://github.com/Rectus/source2utils/blob/master/utils/vmt_to_vmat.py

Newer fork here:
https://github.com/AlpyneDreams/source2utils
Last edited by Rectus; Sep 9, 2020 @ 7:26am
< >
Showing 1-15 of 17 comments
joewint Jan 8, 2017 @ 5:49pm 
Thanks for this! I've been looking for any way at all to import a folder full of textures to Source 2. Seems ridiculous that it should come to this, but hey, Valve.

One issue with your thing: If you have a .vmt ended with the letter T, the T gets stripped out of the filename of the resulting .vmat. At the suggestion of a friend I fixed it thus:

#vmatFileName = fileName.strip('.vmt') + '.vmat'
vmatFileName = fileName[:-4] + '.vmat'
Last edited by joewint; Jan 9, 2017 @ 10:02pm
Rectus Jan 9, 2017 @ 12:15am 
Thanks for posting the fix.

I'm glad the script is being used.
Last edited by Rectus; Jan 9, 2017 @ 12:21am
{I-M}Taz Jan 20, 2017 @ 4:30am 
i've been looking to use this converter for a while but when i drag a folder onto the .py file nothing happens, is there any chance you could explain where i put the .py file and if i should use a script and what that script would look like ,, total newbe here :) thx
Rectus Jan 20, 2017 @ 5:29am 
First make sure you have Python 2.7 installed. If dragging the folder dosn't work, put the .py file where your folder is, open a command line, and run: python vmt_to_vmat.py folder_name
{I-M}Taz Jan 20, 2017 @ 7:46am 
I reinstalled python and it worked thanks
RealBasedSociety Mar 6, 2018 @ 1:41pm 
Sorry I dont know python at all and I know this is a somewhat old threat but could someone explain in detail for a novice that doesn't know anything about python on howto convert the vmt to a vmat?
Rectus Mar 6, 2018 @ 3:28pm 
Get Python 2.7.14 from here: https://www.python.org/downloads/ and install it.

Download the script, or copy it to a text file and change the file extension to .py

If you're lucky, you should be able to simply drag a folder structure with .vmt files, and it should convert them. Otherwise, hold down Shift and right click the directory with the script and choose Open Command window here. Then check the commnad above.

Note that this is a pretty rudimentary script, mostly useful for one of the steps needed to batch convert materials, and you still have to do a lot of steps and manual tweaking to get the proper textures.
Last edited by Rectus; Mar 6, 2018 @ 3:29pm
XDM Sep 5, 2020 @ 10:21pm 
this just doesn't work for me
Rectus Sep 6, 2020 @ 12:17am 
Does it output anything?
XDM Sep 6, 2020 @ 5:46pm 
Originally posted by Rectus:
Does it output anything?
it says

print '\nSource 2 Material Conveter\n'
Rectus Sep 7, 2020 @ 12:27am 
Are you using Python 2.7 or a newer version?
XDM Sep 7, 2020 @ 3:15pm 
Originally posted by Rectus:
Are you using Python 2.7 or a newer version?
yea, the 3.8
Rectus Sep 7, 2020 @ 11:12pm 
Unless you want to rewrite the utility to support a newer version, you'll need 2.7
XDM Sep 8, 2020 @ 3:35pm 
Originally posted by Rectus:
Unless you want to rewrite the utility to support a newer version, you'll need 2.7
oh ok
Rectus Sep 9, 2020 @ 7:24am 
Oh right, there is an improved version here, which looks like it's be upgraded to use python 3: https://github.com/AlpyneDreams/source2utils
< >
Showing 1-15 of 17 comments
Per page: 1530 50