Counter-Strike 2

Counter-Strike 2

Not enough ratings
VTF Helper - Automate VTF for Skins and Stickers
By Thurnip
On this guide, I'll show how I set up some tools and scripts to aid you on the process of creating VTF files. This solution idea is to prevent (my) common human mistakes on the VTFedit, moving files around, etc.

I use VTEX, Image Magick, Photoshop and an Photoshop Script to export layer groups as files.
   
Award
Favorite
Favorited
Unfavorite
Intro
Short Version
My goal was to reduce the number of steps from Photoshop to final VTF texture.

Detailed Version
When working stickers or skins I felt a gap on the pipeline. Between the photoshop workfile and final VTF.

In the past I use to save a TGA file with alpha channel, import it on VTFedit and then save on my skins folder, inside CS:GO Folder.
Other option was to use , Photoshop VTF plugin[www.nemesis.thewavelength.net]but doesn't support 64-bit photoshop...

Editing Alpha channel on photoshop is limited. You can't have smart objects, multiple layers or effects applied to a alpha channel... because it's a channel, after all.

Several steps of loading stuff, naming files and placing them on correct folder, dealing with alpha channels on photoshop.... those were my motivation to try to streamline the process, from PSD into the final VTF, inside the correct folder.

So, here's an overall how it works:

And a quick demonstration
Tools needed
PSD File organization
also, it's necessary authoring your PSD properly, keeping a good organization on it :)

Batch file
Will tie all the process together and trigger Image Magick and VTEX. Moves files to final destination and delete temporary files.

JSX
Used to export group layers as files.

ImageMagick
Will combine wannabe alpha channel image into an actual channel, inside final TGA.

VTEX
Used to convert images to VTF format. Provided by Valve when installing CS:GO SDK

Setting things up will be explained next.

PSD File organization
Skins



A Layer Group for diffuse, other for Alpha channel (can contain linked smart objects, vector elements, etc.). Ungrouped layers will not be exported.

Stckers



For Stickers, similar structure but with additional Layer Groups for other sticker styles, like foil, holographic etc.

the Batch will keep checking for skinExport.tga or stickerExport.tga, so it can go on and trigger next part of the pipeline
Batch File
Warning
messing with batch files could destroy your system and demagnetize all your floppy disks. Don't proceed if you don't have idea what you're doing

This batch will
  1. Trigger the JSX script file, and wait for all the layers groups to be exported...
  2. Trigger imagemagick, to combine the alpha channel into the final TGA file.
  3. Trigger VTEX , creating vtf files into final destination folder.
  4. Move TGA files to final destination folder. We'll need them to submit to workshop, along the VTF files.

You need to set the tools folders on this part of batch file. My configs are like this:
set csGoPath= "C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive" set imPath= "C:\tools\ImageMagick\" set jsxPath= "C:\tools"

And the final destination for Stickers will be
Steam\steamapps\common\Counter-Strike Global Offensive\myStickers

for Skins will be CSGO Folder:
Steam\steamapps\common\Counter-Strike Global Offensive
(I keep them on the csgo root folder, to be easier to upload to workshop)

(Of course you can change those folders to fit your needs.)

So, copy all this code,
past inside Notepad and save it as vtf_helper.bat

@echo off :: Set paths below set csGoPath= "C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive" set imPath= "C:\tools\ImageMagick\" set jsxPath= "C:\tools" ::verify ImageMagick title Generate CS:GO Skins or Maps if exist %imPath%\convert.exe ( goto verifyDrag ) else ( color 0C echo %imPath% folder not found or executable is missing. echo  echo  echo  timeout /t 6 exit ) :verifyDrag :: verify if user have drag and dropped a file or is running from a this folder. if [%~n1]==[] ( :: user didn't drag and dropped any file. color 0A ::search for the first PSD and set var set psdPath=%CD% FOR %%f IN (%CD%\*.psd) DO ( set myTarget=%%~nf goto openPsd ) ) ) else ( ::User drag and dropped a file into the batch color 0B set myTarget=%~n1 set psdPath=%~dp1 goto openPsd ) :openPsd %psdPath%\%myTarget%.psd %jsxPath%\_vtf_helperExporter.jsx ::verify if the last layerset is already exported :verifyExport cls if exist %myTarget%_stickerExport_temp.tga ( GOTO goMagickSticker ) else ( goto verifyIfSkin ) :verifyIfSkin if exist %myTarget%_skinExport_temp.tga ( GOTO goMagickSkin ) else ( echo  echo %myTarget%_stickerExport_temp or %myTarget%_skinExport_temp not found. timeout /t 2 GOTO verifyExport ) :goMagickSticker echo %imPath%\convert.exe :: imageMagick section echo Composing Alpha and TGA files. ::paper processing %imPath%\convert.exe %psdPath%\%myTarget%_paper_temp.tga -background none -layers merge -channel RGB -separate %psdPath%\%myTarget%_paperChannels.tga %imPath%\convert.exe %psdPath%\%myTarget%_paperChannels-0.tga %psdPath%\%myTarget%_paperChannels-1.tga %psdPath%\%myTarget%_paperChannels-2.tga %psdPath%\%myTarget%_paper_alpha_temp.tga -channel RGBA -combine %psdPath%\%myTarget%_paper.tga %imPath%\convert.exe %psdPath%\%myTarget%_paper_normal_temp.tga %psdPath%\%myTarget%_paper_normal.tga ::holographic processing %imPath%\convert.exe %psdPath%\%myTarget%_holo_temp.tga -background none -layers merge -channel RGB -separate %psdPath%\%myTarget%_holoChannels.tga %imPath%\convert.exe %psdPath%\%myTarget%_holoChannels-0.tga %psdPath%\%myTarget%_holoChannels-1.tga %psdPath%\%myTarget%_holoChannels-2.tga %psdPath%\%myTarget%_holo_alpha_temp.tga -channel RGBA -combine %psdPath%\%myTarget%_holo.tga :: add holomask code here %imPath%\convert.exe %psdPath%\%myTarget%_holographic_holomask_temp.tga -background none -layers merge %psdPath%\%myTarget%_holographic_holomask.tga :: add gradient map code here. ::foil Processing %imPath%\convert.exe %psdPath%\%myTarget%_foil_temp.tga -background none -layers merge -channel RGB -separate %psdPath%\%myTarget%_foilChannels.tga %imPath%\convert.exe %psdPath%\%myTarget%_foilChannels-0.tga %psdPath%\%myTarget%_foilChannels-1.tga %psdPath%\%myTarget%_foilChannels-2.tga %psdPath%\%myTarget%_foil_alpha_temp.tga -channel RGBA -combine %psdPath%\%myTarget%_foil.tga %imPath%\convert.exe %psdPath%\%myTarget%_foil_normal_temp.tga %psdPath%\%myTarget%_foil_normal.tga ::clean up temp files, before converting all TGA to VTF del %psdPath%\*_temp.tga del %psdPath%\*-0.tga del %psdPath%\*-1.tga del %psdPath%\*-2.tga goto vtexSticker :goMagickSkin %imPath%\convert.exe %psdPath%\%myTarget%_diffuse_temp.tga -background none -layers merge -channel RGB -separate %psdPath%\%myTarget%_skinChannels.tga %imPath%\convert.exe %psdPath%\%myTarget%_skinChannels-0.tga %psdPath%\%myTarget%_skinChannels-1.tga %psdPath%\%myTarget%_skinChannels-2.tga %psdPath%\%myTarget%_alpha_temp.tga -channel RGBA -combine %psdPath%\%myTarget%.tga ::clean up temp files, before converting all TGA to VTF del %psdPath%\*_temp.tga del %psdPath%\*-0.tga del %psdPath%\*-1.tga del %psdPath%\*-2.tga goto vtexSkin ::vtex stickers. VTF on CSGO\myStickers subfolder :vtexSticker %csGoPath%\bin\vtex.exe -nopause -quiet -game %csGoPath%\csgo -outdir %csGoPath%\myStickers %psdPath%\*.tga ::move TGA to move *.tga %csGoPath%\myStickers :: vtex creates pwf.vtf files with a slightly different colors (color corrected, maybe?). Deleting them since I have no idea what they're used for. del %csGoPath%\myStickers\*.pwl.vtf goto end ::vtex skins. VTF on CSGO Root folder :vtexSkin %csGoPath%\bin\vtex.exe -nopause -quiet -game %csGoPath%\csgo -outdir %csGoPath% %psdPath%\*.tga ::move TGA to move *.tga %csGoPath%\ del %csGoPath%\%myTarget%.pwl.vtf goto end :end cls echo Done. echo. echo Stickers files were moved to echo %csGoPath%\myStickers\ echo. echo Skins files were moved to echo %csGoPath%\myStickers\ echo. timeout /t 6 exit
JSX Script
JSX file is script file, executed by Adobe ExtendScript Toolkit, and works with several Adobe applications. Photoshop in this case.

This script will export Layer Groups as Temporary TGA files, later to be combined into a final TGA file.

Copy all the code
Paste it on Notepad and save as _vtf_helperExporter.jsx
I have it on my tools folder, c:\tools. Later on the batch will look for this file.

#target Photoshop /* to be used with Sticker Exporter. Feel free to copy and change.*/ /* visit http://www.ps-scripts.com for great reference and learning */ /* this script will save layersets (aka layer groups) as TGA files. Adds original PSD filename as prefix, and "temp" as sufix */ var docRef = app.activeDocument; function main(){ if(!documents.length) return; var doc = activeDocument; var oldPath = activeDocument.path; var masterName = app.activeDocument.name.match(/(.*)/.[^\.]+$/)[1]; for(var a=0;a<doc.layerSets.length;a++){ activeDocument.activeLayer = activeDocument.layers.getByName(doc.layerSets[a].name); dupLayers(); activeDocument.mergeVisibleLayers(); activeDocument.trim(TrimType.TRANSPARENT,true,true,true,true); //this line below will save the export name with the Master PSD name as a prefix, and Temp as a sufix var saveFile= File(oldPath +"/"+masterName+"_"+doc.layerSets[a].name +"_temp.tga"); SaveTGA(saveFile); app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); } } main(); function dupLayers() { var desc143 = new ActionDescriptor(); var ref73 = new ActionReference(); ref73.putClass( charIDToTypeID('Dcmn') ); desc143.putReference( charIDToTypeID('null'), ref73 ); desc143.putString( charIDToTypeID('Nm '), activeDocument.activeLayer.name ); var ref74 = new ActionReference(); ref74.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); desc143.putReference( charIDToTypeID('Usng'), ref74 ); executeAction( charIDToTypeID('Mk '), desc143, DialogModes.NO ); }; function SaveTGA(saveFile){ var tgaOpts = new TargaSaveOptions(); tgaOpts.alphaChannels = false; tgaOpts.resolution = TargaBitsPerPixels.TWENTYFOUR; tgaOpts.rleCompression = false; app.activeDocument.flatten(); app.activeDocument.saveAs (saveFile, tgaOpts, false, Extension.LOWERCASE); }
ImageMagick
It's a rad tool to convert and edit images. Here we'll be using it to combine temporary TGA textures as a final TGA texture - Which will be converted to VTF by VTEX.

Download it here:
http://imagemagick.org/script/binary-releases.php

I'm using the portable 64bit version. It's easier to install and update.
Extract the content to a folder you feel comfortable.
I'm using c:\tools\imageMagick\
VTEX
Short version:

Please, check if VTEX is installed on your CSGO folder:
Steam\SteamApps\common\Counter-Strike Global Offensive\bin\VTEX.EXE
If you have CSGO SDK installed, this should be correct :)

Detailed:
VTEX is a official Valve tool to convert PSD or TGA files to Valve Texture Format.
On my pipeline, VTEX will be called by the batch to convert convert TGA file into final VTF on the final destination folder.
Running
All Set!!
You defined the folders for tools:
  • JSX
  • Image Magick
  • VTEX

Move the batch file to the same folder where the PSD is. Double click the bat and you'll get a warning. Click ok to continue.




From here, everything should go smoothly and the VTF files will be on the correct folder after a few seconds.
Appendix
We can adapt this pipeline to other scenarios
Like converting several PSD files directly to VTF, when doing some texture work for levels, for instance.

VTEX is versatile, and can easily replace VTFedit. For more information about it, take a look on valve dev wiki:
https://developer.valvesoftware.com/wiki/Vtex_CLI_use

That's all folks. Let me know if some information is confusing or need to be improved.
I hope this can help iterating faster when developing skins and stickers for CS GO.

Comments and critics are welcome.
6 Comments
[UA/SK] Divine Lotus Jul 1, 2019 @ 10:14am 
For anyone that use GIMP (pasting my info to relative guides):

I recommend looking into the official Valve SDK Doc for insight on how materials work in CSGO's Source engine, linked below:
GIMP alpha channel
https://developer.valvesoftware.com/wiki/GIMP

GIMP Alpha channel: https://m.youtube.com/watch?v=LQCziSTNJgQ
https://www.youtube.com/watch?v=A9aZdPqs17M

Using GIMP VTF plugin?
Be sure you're using GIMP 2.8.0

Not using it? Follow this: https://developer.valvesoftware.com/wiki/Creating_a_Material

More info in this wiki with related info https://steamcommunity.com/sharedfiles/filedetails/?id=1501754039&searchtext=Wiki

Always try to read the manuals in anything, because they often give you some insight

Use .tga or .tiff image types instead of .jpg or .PNG since they're lossless and supports alpha. More info in the Valve Source SDK Doc

3D = Use Blender with GIMP
Digi Jan 2, 2016 @ 12:02pm 
well it takes me less than 15 seconds so xD its not for me but others could benefit. ty for your help :)
Thurnip  [author] Jan 2, 2016 @ 12:00pm 
Hei, Halloween! i agree looks complex, but it isn't :)
and once it's setup, its just click the batch and your VTF will be correctly created. Thanks for your visit mate :csdsmile:
Digi Jan 2, 2016 @ 11:43am 
this would just complicate things for me lol. but nice work
Quzga Jan 2, 2016 @ 11:41am 
Wow, thanks man! This should come in handy, this entire process seem faster than the loading times for importing in vtfedit itself! :D
Xilick Jan 2, 2016 @ 11:35am 
seems cool