Xwad: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified)
 
(38 intermediate revisions by 9 users not shown)
Line 1: Line 1:
A copy of this program can be found in the bin folder of the sourcesdk. This tool can convert .wad and .spr files to .vtf and accompanied .vmt files.
{{LanguageBar}}
{{note|Most first-party games (including Source SDK 2013) don't have a copy of this tool; the version of the tool found in the [steam://install/211 old "SourceSDK" depot] can still be used for any branch (all 4 included versions of xwad.exe are the same).
{{l4dbranch|1}} and later first-party title do include {{code|xwad.exe}}.
}}
'''XWAD''' is a tool that convert [[WAD]], [[Wikipedia:Windows bitmap|BMP]], and [[SPR]] files to [[TGA]] and accompanied [[VMT]] files, as well as call [[vtex]] to generate associated [[VTF]] files.


Help from xwad run without any parameters:
A copy of this [[command-line]] tool can be found in following folder: {{file|common\SourceSDK\bin\<nowiki><</nowiki>branchname<nowiki>></nowiki>\bin\xwad|exe}}.
        [-AutoDir]
 
                Automatically detects -basedir and -wadfile or -bmpfile based
After running XWAD and converting the textures to VTF, use the [[Convert WAD to VMT...]] button in {{hammer4|4.1}}'s File menu {{not|{{hammer++}}}} to automatically add material paths and fix the scaling of previously non-power-of-two textures.
                on the last parameter (it must be a WAD file or a BMP file.
{{codenote|Source code is available in the [https://github.com/Source-SDK-Archives/source-sdk-2006-ep1/tree/master/utils/xwad 2006 SDK]. This is identical to newer Valve-developed versions, with the exception of being designed for older versions of Visual Studio.}}
        [-decal]
 
                Creates VMTs for decals and creates VMTs for model decals.
== Version differences ==
        [-onlytex <tex name>]
{{todo|{{jb3|4}} includes a build of xwad with several bugfixes and extra features; document these properly. They include:
        [-shader <shader name>]
* Remove resolution cap altogether
                Specify the shader to use in the VMT file (default
* Add support for WAD2 and SPR v1 formats (using {{code|-palfile}} param to provide [[palette]], defaulting to Quake 1 palette).
                is LightmappedGeneric.
* Fix processing of decals
        [-vtex]
* Extract sprite groups from SPR files
                If -vtex is specified, then it calls vtex on each newly-created
* Add [[%CompileWater]] to VMTs generated for {{code|!}} and {{code|<nowiki>*</nowiki>}}-prefixed WAD textures
                .TGA file.
::Uses [[%CompileSlime]] instead for {{code|!slime}} and {{code|<nowiki>*slime</nowiki>}}-prefixed WAD textures
        [-vmtparam <ParamName> <ParamValue>]
* Include approximate values for [[water (shader)#Fog|water fog]] in generated VMTs
                if -vtex was specified, passes the parameters to that process.
::WAD2 liquids do not have fog values generated for them, as Q1 does not use HL1's fog system.
                Used to add parameters to the generated .vmt file
* Respect {{code|-transparent}} for SPR files
        -BaseDir <basedir>
* Automatically add ConveyorScroll [[material proxy]] to WAD textures prefixed with {{code|scroll}}
        -game <basedir>
* Automatically add [[$nocull]], [[%CompileBlockLOS]], and commented-out [[%CompileNonSolid]] to WAD textures prefixed with {{code|@}}.
                Specifies where the root mod directory is.
* Rename illegal characters (like *) in output filenames
        -WadFile <wildcard>
* QPIC and Font support
                -wadfile will make (power-of-2) TGAs, VTFs, and VMTs for each
* Special handling of Q1's scrolling skies (via [[material proxies]]; shader is changed to UnlitGeneric)
                texture in the WAD. It will also place them under a directory
* Extract palette lump from WAD2, if present
                with the name of the WAD. In addition, it will create
}}
                .resizeinfo files in the materials directory if it has to
 
                resize the texture. Then Hammer's File->WAD To Material
== Caveats ==
                command will use them to rescale texture coordinates.
{{bug|hidetested=1|Xwad always outputs pixels that used index 255 as transparent, even if they aren't flagged as such{{elaborate}}. Only textures that are flagged as transparent will have the transparent pixels [[$translucent#Filtering_Borders|modified to work better with texture filtering]].{{workaround|Convert the output folder(s) to BGRA8888 using {{vtfedit|2}}, then use {{vide|2|addtext='s}} batch VTF converter to convert the textures that should be opaque to BGR565, BGR888, or DXT1.
        -bmpfile <wildcard>
}} }}
                -bmpfile acts like -WadFile but for BMP files, and it'll place
{{modernImportant|Valve's Xwad does not support textures with more than 262144 pixels (ex: 512x512 resolution).<br>This cap is removed in {{jbep3}}'s Xwad.}}
                them in the root materials directory.
 
        -sprfile <wildcard>
== Syntax ==
                Acts like -bmpfile, but ports a sprite.
{{stub}}
        -Transparent (BMP files only)
== Options ==
                If this is set, then it will treat palette index 255 as a
{{stub}}
                transparent pixel.     -SubDir <subdirectory>
=== Required ===
                -SubDir tells it what directory under materials to place the
; {{code|-basedir <path>}}
                final art. If using a WAD file, then it will automatically
: Location of [[gameinfo.txt]]. Relative paths are relative to current working directory.
                use the WAD filename if no -SubDir is specified.
: If xwad is called from the {{path|materialsrc}} directory, then {{code|..}} will suffice.
        -Quiet
 
                Don't print out anything or wait for a keypress on exit.
; {{code|-wadfile <file>.wad}}
; {{code|-bmpfile <file>.bmp}}
; {{code|-sprfile <file>.spr}}
Convert a [[WAD]], [[BMP]], or [[SPR]], respectively. Accepts preceding file paths and wildcards. Relative paths are relative to current working directory.
 
=== Optional ===
; {{code|-transparent}}
: Flag input [[BMP]] files as having alphatest transparency. For [[WAD]] files, this happens automatically for {{code|{}}-prefixed textures, and for [[SPR]] file, this happens automatically if the sprite has its transparency mode set to alphatest.
: A texture flagged as transparent will have [[texel]]s using [[palette]] index 255 (the last color) [[$translucent#Filtering_Borders|dilated]] based upon surrounding opaque texels, and {{cmd|$alphatest|1}} and {{cmd|$alphatestreference|0.5}} added to the [[VMT]].
: Palette index 255 is always transparent in the output [[TGA]], but the underlying texels' colors are kept unless the texture is flagged as transparent.
 
; {{code|-decal}}
: Works differently in Valve's Xwad vs Jabroni Brawl's:
:* {{valve}} '''Do not use'''. Creates VMTs using [[DecalModulate]] shader and [[$alphatest]] parameter.
:: As this is not faithful to how GoldSrc decals work, {{wadmaker|2}} should be used to convert [[decals (GoldSrc)|decals]] instead (if necessary, using an [[image editor]] to pad all edges to the next power of two), and the VMTs created manually as [[LightmappedGeneric]] with {{cmd|$translucent|1}}, {{cmd|$decal|1}}, and {{cmd|$decalscale|1}}.
:* {{jbep3}} Treats the input texture as an IndexAlpha texture, with the palette index being used for full 8-bit translucency, and the last index being used to determine color. Creates VMTs using {{cmd|$translucent|1}}, {{cmd|$decal|1}}, and {{cmd|$decalscale|1}}.
:: Implied when converting {{code|{}} textures if the input WAD is named decals.wad.
::{{warning|Due to how Xwad's Po2 resizing method works, non-power-of-two decals will be slightly larger when using [[infodecal]] in Source vs how it appeared in GoldSrc. If this is a noticeable issue, use {{wadmaker|2}} to convert the decals from their original format, then use an [[image editor]] to pad all edges to the next power of two.}}
: {{tip|For decals and IndexAlpha sprites, consider using A8 texture format and defining color in the VMT using [[$color]], as this retains the full original quality while being the same size as a DXT5 texture of the same resolution.}}
 
; {{code|-vmtparam <parameter> <value>}}
: Add the described material parameter to the VMTs of all converted textures.
: To add multiple parameters, use multiple {{mono|-vmtparam}} arguments.
: Despite what the readme says, this has nothing to do with {{vtex|2}}.
 
; {{code|-onlytex <texture>}}
: Only export the specified texture name.
 
; {{code|-palfile <path>\<file>.lmp}} {{jbep3|only}}
: What [[palette]] to use for WAD2 files (uses the vanilla {{quake|2}} palette by default). Relative paths are relative to {{mono|-basedir}}.
: Expects a 768-byte array of 24-bit RGB values ("pallete.lmp"); can be extracted from several formats using {{quakewiki|Fimg}}. Can also be taken from a 8-bit paletted [[PCX]] file by deleting all but the last 768 bytes in a hex editor.
: {{tip|For {{Quake|2|nt=0}} textures, it is possible to generate accurate [[$selfillummask]] textures based upon fullbrights by using palette with the last 32 indices set as white, and the rest of the indices set as black. A preconfigured palette for this purpose can be found [https://files.gamebanana.com/bitpit/q1_selfillum_palette.lmp here (direct download)].<br>This should ''not'' be done for {{hexen2|2}} textures, as Hexen II does not use fullbrights.}}
 
== Readme ==
Help from xwad run without any parameters (some information is inaccurate and/or misleading):
{{codeblock|<nowiki>
[-AutoDir]
Automatically detects -basedir and -wadfile or -bmpfile based
on the last parameter (it must be a WAD file or a BMP file.
[-decal]
Creates VMTs for decals and creates VMTs for model decals.
[-onlytex <tex name>]
[-shader <shader name>]
Specify the shader to use in the VMT file (default
is LightmappedGeneric.
[-vtex]
If -vtex is specified, then it calls vtex on each newly-created
.TGA file.
[-vmtparam <ParamName> <ParamValue>]
if -vtex was specified, passes the parameters to that process.
Used to add parameters to the generated .vmt file
-BaseDir <basedir>
-game <basedir>
Specifies where the root mod directory is.
-WadFile <wildcard>
-wadfile will make (power-of-2) TGAs, VTFs, and VMTs for each
texture in the WAD. It will also place them under a directory
with the name of the WAD. In addition, it will create
.resizeinfo files in the materials directory if it has to
resize the texture. Then Hammer's File->WAD To Material
command will use them to rescale texture coordinates.
-bmpfile <wildcard>
-bmpfile acts like -WadFile but for BMP files, and it'll place
them in the root materials directory.
-sprfile <wildcard>
Acts like -bmpfile, but ports a sprite.
-Transparent (BMP files only)
If this is set, then it will treat palette index 255 as a
transparent pixel.
-SubDir <subdirectory>
-SubDir tells it what directory under materials to place the
final art. If using a WAD file, then it will automatically
use the WAD filename if no -SubDir is specified.
-Quiet
Don't print out anything or wait for a keypress on exit.
   
   
  ex: xwad.exe -vtex -BaseDir c:\hl2\dod -WadFile c:\hl1\dod\*.wad
  ex: xwad.exe -vtex -BaseDir c:\hl2\dod -WadFile c:\hl1\dod\*.wad
  ex: xwad.exe -vtex -BaseDir c:\hl2\dod -bmpfile test.bmp -SubDir models\props
  ex: xwad.exe -vtex -BaseDir c:\hl2\dod -bmpfile test.bmp -SubDir models\props
  ex: xwad.exe -vtex -vmtparam $ignorez 1 -BaseDir c:\hl2\dod -sprfile test.spr -SubDir sprites\props
  ex: xwad.exe -vtex -vmtparam $ignorez 1 -BaseDir c:\hl2\dod -sprfile test.spr -SubDir sprites\props
</nowiki>}}
== See also ==
* [[Convert WAD to VMT...]]
* [[RESIZEINFO]]
{{SDKTools}}


[[Category:Material_System]]
[[Category:Material System]]
[[Category:Tools]]

Latest revision as of 07:08, 20 May 2025

English (en)Русский (ru)Translate (Translate)
Note.pngNote:Most first-party games (including Source SDK 2013) don't have a copy of this tool; the version of the tool found in the old "SourceSDK" depot can still be used for any branch (all 4 included versions of xwad.exe are the same).

Left 4 Dead engine branch and later first-party title do include xwad.exe.

XWAD is a tool that convert WAD, BMP, and SPR files to TGA and accompanied VMT files, as well as call vtex to generate associated VTF files.

A copy of this command-line tool can be found in following folder: 🖿common\SourceSDK\bin\<branchname>\bin\xwad.exe.

After running XWAD and converting the textures to VTF, use the Convert WAD to VMT... button in Hammer Hammer 4.x's File menu (not in Hammer++) to automatically add material paths and fix the scaling of previously non-power-of-two textures.

Cpp.pngCode:Source code is available in the 2006 SDK. This is identical to newer Valve-developed versions, with the exception of being designed for older versions of Visual Studio.

Version differences

Todo: Jabroni Brawl: Episode 3 Jabroni Brawl: Episode 3 includes a build of xwad with several bugfixes and extra features; document these properly. They include:
  • Remove resolution cap altogether
  • Add support for WAD2 and SPR v1 formats (using -palfile param to provide palette, defaulting to Quake 1 palette).
  • Fix processing of decals
  • Extract sprite groups from SPR files
  • Add %CompileWater to VMTs generated for ! and *-prefixed WAD textures
Uses %CompileSlime instead for !slime and *slime-prefixed WAD textures
  • Include approximate values for water fog in generated VMTs
WAD2 liquids do not have fog values generated for them, as Q1 does not use HL1's fog system.
  • Respect -transparent for SPR files
  • Automatically add ConveyorScroll material proxy to WAD textures prefixed with scroll
  • Automatically add $nocull, %CompileBlockLOS, and commented-out %CompileNonSolid to WAD textures prefixed with @.
  • Rename illegal characters (like *) in output filenames
  • QPIC and Font support
  • Special handling of Q1's scrolling skies (via material proxies; shader is changed to UnlitGeneric)
  • Extract palette lump from WAD2, if present

Caveats

Icon-Bug.pngBug:Xwad always outputs pixels that used index 255 as transparent, even if they aren't flagged as such[Elaborate?]. Only textures that are flagged as transparent will have the transparent pixels modified to work better with texture filtering.
PlacementTip.pngWorkaround:Convert the output folder(s) to BGRA8888 using VTFEdit VTFEdit, then use VIDE VIDE's batch VTF converter to convert the textures that should be opaque to BGR565, BGR888, or DXT1.
Icon-Important.pngImportant:Valve's Xwad does not support textures with more than 262144 pixels (ex: 512x512 resolution).
This cap is removed in Jabroni Brawl: Episode 3's Xwad.

Syntax

Stub

This article or section is a stub. You can help by expanding it.

Options

Stub

This article or section is a stub. You can help by expanding it.

Required

-basedir <path>
Location of gameinfo.txt. Relative paths are relative to current working directory.
If xwad is called from the 🖿materialsrc directory, then .. will suffice.
-wadfile <file>.wad
-bmpfile <file>.bmp
-sprfile <file>.spr

Convert a WAD, BMP, or SPR, respectively. Accepts preceding file paths and wildcards. Relative paths are relative to current working directory.

Optional

-transparent
Flag input BMP files as having alphatest transparency. For WAD files, this happens automatically for {-prefixed textures, and for SPR file, this happens automatically if the sprite has its transparency mode set to alphatest.
A texture flagged as transparent will have texels using palette index 255 (the last color) dilated based upon surrounding opaque texels, and $alphatest 1 and $alphatestreference 0.5 added to the VMT.
Palette index 255 is always transparent in the output TGA, but the underlying texels' colors are kept unless the texture is flagged as transparent.
-decal
Works differently in Valve's Xwad vs Jabroni Brawl's:
As this is not faithful to how GoldSrc decals work, WadMaker WadMaker should be used to convert decals instead (if necessary, using an image editor to pad all edges to the next power of two), and the VMTs created manually as LightmappedGeneric with $translucent 1, $decal 1, and $decalscale 1.
  • Jabroni Brawl: Episode 3 Treats the input texture as an IndexAlpha texture, with the palette index being used for full 8-bit translucency, and the last index being used to determine color. Creates VMTs using $translucent 1, $decal 1, and $decalscale 1.
Implied when converting { textures if the input WAD is named decals.wad.
Warning.pngWarning:Due to how Xwad's Po2 resizing method works, non-power-of-two decals will be slightly larger when using infodecal in Source vs how it appeared in GoldSrc. If this is a noticeable issue, use WadMaker WadMaker to convert the decals from their original format, then use an image editor to pad all edges to the next power of two.
Tip.pngTip:For decals and IndexAlpha sprites, consider using A8 texture format and defining color in the VMT using $color, as this retains the full original quality while being the same size as a DXT5 texture of the same resolution.
-vmtparam <parameter> <value>
Add the described material parameter to the VMTs of all converted textures.
To add multiple parameters, use multiple -vmtparam arguments.
Despite what the readme says, this has nothing to do with VTEX VTEX.
-onlytex <texture>
Only export the specified texture name.
-palfile <path>\<file>.lmp (only in Jabroni Brawl: Episode 3)
What palette to use for WAD2 files (uses the vanilla Quake Quake palette by default). Relative paths are relative to -basedir.
Expects a 768-byte array of 24-bit RGB values ("pallete.lmp"); can be extracted from several formats using Quake1-16px.png Fimg. Can also be taken from a 8-bit paletted PCX file by deleting all but the last 768 bytes in a hex editor.
Tip.pngTip:For Quake Quake I textures, it is possible to generate accurate $selfillummask textures based upon fullbrights by using palette with the last 32 indices set as white, and the rest of the indices set as black. A preconfigured palette for this purpose can be found here (direct download).
This should not be done for Hexen II Hexen II textures, as Hexen II does not use fullbrights.

Readme

Help from xwad run without any parameters (some information is inaccurate and/or misleading):

[-AutoDir] Automatically detects -basedir and -wadfile or -bmpfile based on the last parameter (it must be a WAD file or a BMP file. [-decal] Creates VMTs for decals and creates VMTs for model decals. [-onlytex <tex name>] [-shader <shader name>] Specify the shader to use in the VMT file (default is LightmappedGeneric. [-vtex] If -vtex is specified, then it calls vtex on each newly-created .TGA file. [-vmtparam <ParamName> <ParamValue>] if -vtex was specified, passes the parameters to that process. Used to add parameters to the generated .vmt file -BaseDir <basedir> -game <basedir> Specifies where the root mod directory is. -WadFile <wildcard> -wadfile will make (power-of-2) TGAs, VTFs, and VMTs for each texture in the WAD. It will also place them under a directory with the name of the WAD. In addition, it will create .resizeinfo files in the materials directory if it has to resize the texture. Then Hammer's File->WAD To Material command will use them to rescale texture coordinates. -bmpfile <wildcard> -bmpfile acts like -WadFile but for BMP files, and it'll place them in the root materials directory. -sprfile <wildcard> Acts like -bmpfile, but ports a sprite. -Transparent (BMP files only) If this is set, then it will treat palette index 255 as a transparent pixel. -SubDir <subdirectory> -SubDir tells it what directory under materials to place the final art. If using a WAD file, then it will automatically use the WAD filename if no -SubDir is specified. -Quiet Don't print out anything or wait for a keypress on exit. ex: xwad.exe -vtex -BaseDir c:\hl2\dod -WadFile c:\hl1\dod\*.wad ex: xwad.exe -vtex -BaseDir c:\hl2\dod -bmpfile test.bmp -SubDir models\props ex: xwad.exe -vtex -vmtparam $ignorez 1 -BaseDir c:\hl2\dod -sprfile test.spr -SubDir sprites\props

See also