VTFLib is a LGPL open source programming library, written by Neil Jedrzejewski and I. VTFLib provides a C and C++ API that, with a few simple functions, can open and save .vtf and .vmt files, providing access to all known features. The library functions independent of Steam, allowing third party applications to use the library without Steam present or runningi on the target system.
VTFLib includes two GPL example applications, VTFCmd and VTFEdit. VTFCmd is a C command line frontend for VTFLib that can create .vtf and .vmt files from various source formats. It is similar in functionality to Valve's vtex Source SDK utility, but offers a lot more control. VTFEdit is a C++ .NET graphical frontend for VTFLib with viewing and creation capabilities. Both VTFCmd and VTFEdit support several source image formats, including, but not limited to .bmp, .dds, .gif, .jpg, .png and .tga.
Screenshots: Documentation: Features:- Convert .bmp, .dds, .gif, .jpg, .png and .tga files to .vtf and .vmt files with easy access to all .vtf options.
- Convert .vtf files to .bmp, .jpg, .png and .tga files.
- Convert entire folders to and from .vtf and .vmt files.
- Convert .wad files to .vtf and .vmt files.
- Explore .bsp, .gcf, .pak, .wad and .xzp packages.
- Preview .vtf files.
- Recent file menu.
- 100% Free.
Is there any way to create VTFs and VMTs on a linux computer, short of running VTFEdit through wine+mono? I'd really like to keep making my own textures and not asking my friends to convert them for me.
And I can confirm that TGAs with an alpha channel created in Gimp do not import correctly.
VTFCmb may, however, run under Wine (I haven't tested it, but HLLib used to before I ported it).
How do I turn this off in the auto-vmt creation? The older version of VTFEdit worked fine, maybe I will use that for now.
If you want I can upload a video of this strange problem.
Could you please impliment batch VMT modification? I require a tool that will take a line out of 800+ VMT's, but they are in 30 separate folders. Using Notepad++ would take some time.
You have right, because bsptwomap for Quake 3. Map File doesn't support for Half-Life, because map was problematic on the Valve Hammer Edition. I see bad decompiler, because we need bsptwormf like bsptwovmf. Because Rmf was correct file for correct blocks and showing clip, null, orgin, skip and hill blocks support working. In the decompilrd map files do not show special textures (null, clip and more...) blocks. That problem of bsptwomap deleted special texture-blocks.. .
I know that bsptwormf, because it will to support with special texture-blocks.
Thanks Bye SnakeMedia
My problem is that if I allow vtf edit to create mipmaps the texture in hammer and in game looks really crap and basically degrades the further away you are from the wall or texture. If i turn off the mip maps the texture will look great in hammer and in the game BUT the thumbnail in hammer where you select your texture basically gets mixed up with other thumbnails and gets distorted making it harder to make your texture choice when you have allot of them. also I cant find an option to reduce the number of mip maps from 9.
I had thought that if I reduced the mipmaps to say 1 that the thumb nail would return to its proper look and the in game texture would also still look good.
Do you have any help please or sujestion.... Also is there a tutorial on how to use vtf edit for texture creation please.
I suggest you play around with the mipmap settings in VTFEdit. For general textures I recommend the Sine Cardinal mipmap filter (as it is closest to the filter vtex uses); however, the Box mipmap filter may work better in some situations. If you find your mipmaps are too blurry, you may try a sharpen filter (otherwise set the sharpen filter to None). Of the sharpen filters, Unsharpen Mask is probably the best. There are additional options for this filter under the advanced tab. Decrease the amount to decrease the amount of sharpening.
The same settings don't always work best for all types of textures, but you should find ones that work. It can be a good idea to generate your texture multiple times with different settings and examine the resulting mipmaps in VTFEdit.
Lastly, if you have a somewhat recent video card, you may want to make sure you're using a good filter in game. Typically this will be the highest anisotropic setting your video card supports.
once in game with mip maps on the patern looks ok if you are close to it but as you look further down the length of the wall it looks more and more blurd.
A friend of mine has had this problem and went over to using photo shop to make his textures but I dont have photo shop and that meathod seems much more complicated.
Per haps if the mipmaps were reduced from the 9 that it creates to say 1 2 or 3 it might look different.
PS .. my understanding of mipmaps was to use a lower resolution texture as you moved further away from the textured object so as to use les computer rescources and aid FPS ????
Resizing images is not only an expensive task, but it is a very difficult task to do with good results. The purpose of mipmaps is to provide the rendering engine with a series of high quality resized versions of the original. This way, when the engine gos to fill a polygon, it is more likely to have a high quality texture of roughly the same size as the polygon.
Mipmaps don't stop the engine from resizing, however. The engine will typically choose the two textures closest in size then interpolate to get the best approximation. There are different types of interpolation methods, but the best are very expensive (so you're not really saving anything by having smaller textures far away because (1) you're using more than one texture and (2) your doing several interpolations instead of just one).
An excellent description of the different ways mipmaps are used is described here.
Perhaps if you could provide me with some screenshots of the problems you are having I can provide more assistance...
here is a pic with mip maps
http://www.rtype.com/TSF-Clan/forum/uploads/20081129_233945_mipmap.jpg
and here is a pic with out mip maps
http://www.rtype.com/TSF-Clan/forum/uploads/20081129_232721_no_mip.jpg
alternativly you can see my post on this with the pics and description of my problem here on my clansweb site.
http://www.rtype.com/TSF-Clan/forum/forum_posts.asp?TID=863&PN=1
I am not the only one to see this problem as now that I have pointed it out to him, SADIST (another well known mapper for Hl2 Death-Match ) can also see this problem.
I will see if I van get sadist to try this out tonight as well .
Ps my wifes pc has the same game on it and her setting is only at trilinear but looks great on the screen but she is using an old ati 1950 pro GPU and i know that there are quite allot of differences between ATI and Nvidia.
EDIT..... Just spent a bit of time testing this and yes you are definatly right it is the Anisotropic filtering but it only fixes it if i change the gpu setting for this to 16x...
Many thanks for your time on this for me .....
Most recent mid-range video cards should be able to handle 16x anisotropic texture filtering with virtually no performance loss, so I do recommend forcing it on if you have a decent card.
And putting the gpu on 16 times also fixes the image in hammer as well as in the game.My friend sadist has an old AGP slot card and he also notices no drop in fps when he turned on 16x as well so I think the problem is solved.
Thanks for your help on this nem... much apreciated...
I cannot for the life of me figure out what is wrong...If I go into photoshop and resave the vtf using the photoshop vtf plugin, all is well so it has to be something I am not doing with your tool...I really would like to use the VTFCmd tool for batch operations.
For the below I just simply dragged and dropped a file brick004b.PNG onto the VTFCmd.exe file:
Just for the the technical info, here is my materials path
...hl2mp\materials\asclan\pack1
Contents of the pack1 folder:
brick004b.vtf
brick004b.vmt
Here is the contents of my brick004b.vmt file:
"LightmappedGeneric"
{
"$basetexture" "asclan/pack1/brick004b"
}
As you can see from the above, everything is correct, but here is what I see when using my texture:
http://www.asclan247.com/images/error.jpg
What would be the CORRECT command line syntax for VTFCmd to do:
1. Texture (VTF)
2. Normal Texture (Bumpmap VTF)
Please Help!! :)
I need to add the same attributes to 800+ material files.
Keep up the good work nemesis.
To create new vmt files you must first delete the old ones if there are any. Then in in your base materials directory create these two files master.bat and function.bat.
Open master.bat and insert this code
for /r %%f in (*.vtf) do call function.bat %%~nf
then inside function.bat insert this code
@echo off&setlocal enableextensions
for %%* in (.) do set MyDir=%%~n*
if not defined MyDir set MyDir=%CD:\=%
echo "LightmappedGeneric" >> %1
echo { >> %1
echo "$basetexture" "%MYDIR%\%1" >> %1
echo } >> %1
ren *. *.vmt
the bits of code that start echo and end >> %1 are the lines where you decide what gets added into the vmt. The format is straight forward
echo codetobeinserted >> %1
If it requires "" just add them, no special parsing stuff, it adds literally whatever you type.
Master.bat looks for any vtf file in the directory where you run the batch then sends each one's name to the function.bat file. Function takes the name and creates a file with the same name. It then inserts the code you told it to and finally renames all the files to .vmt. After it finishes the directory its in it goes through every sub-directory until it can't find any more vtf files.
These bat files will keep the directory structure for all vtf in all sub directories but you may have to edit the ones in the base directory because it sometimes puts in /material/texture instead of just texture...
Hope this is helpful! I had the problem of having my copy of vtfedit add in translucent on all my vmt when i converted a folder. I also needed to add in comments to certain folders' vmt files for my own purposes.
I searched for infos but could not find anything about it.
My Vtex compile parameters checked.
Eight Bit Alpha
Clamp S ("clamps" "0")
Clamp T ("clampt" "0")
No Mipmap ("nomip" "0")
I've tested with vtex.dll and VTFEdit and I'm getting the same results.
And this only happens to one side of the in-game radar map.
http://v4servers.com/overview_ss/top.jpg <= incorrect
http://v4servers.com/overview_ss/bottom.jpg <= correct
--
FIXED: My .tga file wasn't correct! FIXED!
Thanks Anyways Great Tool!
I desperately need to compile one
you must have gotten it from somewhere else :/
Of course, you DO have to find the overlays first... ._.
Microsoft.VC80.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195"
D:\Program Files\Nem's Tools\VTFEdit\VTFEdit.exe
I think Microsoft is no longer supporting 2005 on Vista and 7...
Install
http://www.microsoft.com/download/en/details.aspx?id=26347
This will fix both "The application has failed to start because the application configuration is incorrect." and "The application has failed to start because its side-by-side configuration is incorrect." messages on Windows 7 and Windows XP. If you're running 64 bit, Install both 86 and 64. Don't worry about IA64.
sorry for my bad english.
https://github.com/panzi/VTFLib
I just got it to compile. It's completely untested. I hope I did not break binary compatibility when compiled under Windows. I had to change some types for IO (offset type, size type etc.), but I did this with #ifdefs in stdafx.h so that it should be the same under Windows as it was before (I replaced the seek mode vlUInt with an enum, but that should be compatible).
VTFLib was not designed to be thread safe (there were no multicore CPUs 10 years ago). After a quick look, as long as you instantiate your own CVTFFile instances, and don't set some of the obscure settings outside of initialization, the only thing that is not thread safe is probably VTFLib::LastError. You could possibly declare it with thread local storage (not sure what the TLS restrictions are in Linux) or throw a Mutex into it.
Anyway it now works fine under Linux. I also fixed const correctness in some functions (where source data pointers where not const):
https://github.com/panzi/VTFLib
I also wrote a gdk pixbuf loader so that any Gtk+ application can now view VTF files (only one frame, might add animation support when there are >1 frames later):
https://github.com/panzi/pixbufloader-vtf
It would be cool if this could be merged again with the official VTFLib.
Ah I see. I think one can do C bindings without global variables: Cast all object pointers to incomplete struct types and wrap all methods like "vlVTFFileLoadPath(struct c_CVTFFile*, const char *)" and "vlVTFFileLoadBuffer(struct c_CVTFFile*, void*, size_t)" etc. It sure is a lot of wrapping work.
See:
https://github.com/panzi/VTFLib/commit/b0d81c3a16df1213355b6c5ac997e65ddc4cc817#diff-3
https://github.com/panzi/VTFLib/commit/b0d81c3a16df1213355b6c5ac997e65ddc4cc817#diff-41
https://github.com/panzi/VTFLib/commit/51ff65212d2332cfc7fc3c98e3e2eec611897161#diff-2
https://github.com/panzi/VTFLib/commit/5cc8aec5113476116422bdd4eb4ad73cd6d18ac9
If it ever gets refactored, it might be to remove its dependency on the old deprecated NXDXT library. I doubt I'll ever get around to it though.
Thanks for reporting those bugs, I will integrate them back.
http://people.freedesktop.org/~cbrill/libtxc_dxtn/
Under Fedora I can install that with "sudo yum install libtxc_dxtn". :)
I tried to keep binary compatibility when compiled for Windows, but I haven't even tried to compile it for Windows. I would only cross-compile it with MinGW anyway. My Linux port theoretically supports Files > 4 GB (-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE make off_t 64bit and bring fseeko and ftello into existence, even under 32bit Linux), if the VTF format would support that. I replaced vlUInt and vlLong with vlSSize ("stream size"), vlSize and vlOffset. Under Windows it should typdef to the same as before, under Linux vlSSize = off_t (signed 64bit), vlSize = size_t (unsigned 32bit or 64bit) and vlOffset = off_t. This means under Windows vlSSize is unsigned and under Linux it is signed. Maybe that is not such a good idea. vlSSize has to be off_t (or something that is at least as big) because that is the type of the st_size field in the stat struct. If functions that return vlSSize fail they return -1 in Linux and 0 in Windows. I think THAT cannot be and I have to change it to 0 everywhere, even though 0 could be a valid value. Or maybe make it vlUInt64 under Windows and also return -1 there (which would break compatibility)? (I just now changed it to 0 everywhere and pushed to github.)
Btw. I also wrote a Qt4 QImageIO plugin based on this:
https://github.com/panzi/qvtf
Next: A KDE plugin, because apparently some (the most important) KDE applications ignore the Qt QImageIO plugin infrastructure and use their own. GIMP also ignores the GDK PixBuf loader infrastructure. Bah.
https://github.com/panzi/VTFLib/commit/84e19ecd715ac3428118753c888f52929a7bd95f
Image converted to RGBA (Gdk PixBuf):
Image converted to RGB (Qt):
Image converted to ARGB (Qt):
Image converted to RGBA but I told Qt it is ARGB:
Looks pretty broken but it IS orange.
qformat = QImage::Format_ARGB32;
dstformat = IMAGE_FORMAT_RGBA8888;
const vlByte* frame = vtf.GetData(currentFrame, 0, 0, 0);
vlByte* temp = new vlByte[width*height*4];
if (!VTFLib::CVTFFile::Convert(frame, temp, width, height, srcformat, dstformat)) {
qDebug("%s", VTFLib::LastError.Get());
delete[] temp;
return false;
}
*image = QImage(width, height, qformat);
uchar *dest = image->bits();
for (vlUInt y = 0; y < height; ++ y) {
for (vlUInt x = 0; x < width; ++ x) {
dest[y * width * 4 + x * 4 + 0] = temp[y * width * 4 + x * 4 + 2];
dest[y * width * 4 + x * 4 + 1] = temp[y * width * 4 + x * 4 + 1];
dest[y * width * 4 + x * 4 + 2] = temp[y * width * 4 + x * 4 + 0];
dest[y * width * 4 + x * 4 + 3] = temp[y * width * 4 + x * 4 + 3];
}
}
delete[] temp;
Hmm, what does this mean? What is wrong/what is happening?
dstformat = IMAGE_FORMAT_BGRA8888;
As QImage::Format_ARGB32 is:
0xAARRGGBB
Which is the opposite order on little endian.
dstformat = IMAGE_FORMAT_BGRA8888;
As QImage::Format_ARGB32 is:
0xAARRGGBB
Which is the opposite order on little endian.
I figured so already myself, but when I use this I get the last image I posted. (http://i.imgur.com/GL2GsjB.png) It's orange but looks broken.
nvidia-texture-tools look like a promising replacement (MIT licensed, used by Unreal Engine 3, blender etc.). It supports mipmap generation, image scaling and S3TC compression, but only supports a fraction of the mipmap filters and no sharpening filters etc. (except I'm missing something). So it's probably ok for basic mipmap generation. But then, the last update is from May 14, 2010. :/
Great VTFEdit tool. I'm just wondering if you are willing to add a few extra options like adding or removing frames and custom mipmaps after the fact?
When multiselecting images to be included for animation, I have to be a little extra careful in which order I select them. It would be nice if I could add one at the time if I so pleased, or insert inbetween if I forgot anything.
Also, created a Dot Matrix Display texture, and the automated mipmapping just doesn't look good. Thinking of creating custom mipmaps so that the DMD picture shows up clearer.
/Edward