WAL
WAL is a texture file format used by Quake II to store brush textures. It is a modified version of Quake I's miptex format, containing four mipmaps, two strings (used for animation), as well as three metadata values. The first two metadata values are bitfields, indicating information about a brush's face (surface flags) and a brush's contents (content flags). The third metadata value is an integer value, traditionally used for determining the brightness of texlights (although some compilers use it for other purposes on non-emissive surfaces, such as for smoothing groups in Arghrad).
The surface flags and contents flags used by Quake II would serve the basis for those used by Source.
Contents
Technical
This work is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License; version 2 as published by the Free Software Foundation. This work is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See version 2 of the GNU General Public License for more details.
The header of a WAL file can be represented by the following C struct (from qcommon/qfiles.h
in the Quake II source code release):
#define MIPLEVELS 4
typedef struct miptex_s
{
char name[32]; // 31 chars plus null terminator
unsigned width, height;
unsigned offsets[MIPLEVELS]; // four mip maps stored
char animname[32]; // next frame in animation chain
int flags;
int contents;
int value;
} miptex_t;
It is then followed by raw 8-bit image data for each mipmap, at the offsets relative to the start of the file.
Texture flags
These sections list and describe the various standard surface and content flags used in Quake II, as well as the equivalent VMT parameters to achieve the same or similar result in Source 1.
Surface flags
Surface flags on different faces of a brush generally do not need to match. If two or more conflicting flags are assigned, then the flag with the lowest bit value will take priority.
Bit | Flag name | VMT equivalent | Description |
---|---|---|---|
0x00000001 | SURF_LIGHT | N/A | Treats this face as a texlight, with brightness dependent upon the surface value. |
0x00000002 | SURF_SLICK | N/A | Makes this face slippery. |
0x00000004 | SURF_SKY | %Compile2DSky 1
|
Face is is not drawn, and the skybox is drawn behind all visible faces when this face is in the PVS. |
0x00000008 | SURF_WARP | Potentially simulatable using material proxies | "Warp" the texture on this face, like water. |
0x00000010 | SURF_TRANS33 | $alpha "0.33"
|
Render the face as translucent, at 33% or 66% opacity, respectively.
Most source ports, including the remaster, will render any texels using palette index 255 (or true color images with an alpha of less than 127) as fully transparent. While these flags can technically be combined, the behavior for such is not standardized. Some engines (such as Yamagi) will prioritize one or the other, others (such as Q2EX) will render the face at 50% opacity, and a small few will instead render the face with binary transparency. |
0x00000020 | SURF_TRANS66 | $alpha "0.66"
| |
0x00000040 | SURF_FLOWING | TextureScroll material proxy | Texture scrolls from top to bottom.
Note that this is different from scroll textures in GoldSrc, which scroll from left to right (and require a func_conveyor, which this does not). |
0x00000080 | SURF_NODRAW | %CompileNoDraw 1
|
Do not render this face in-game. |
0x00000100 | SURF_HINT | %CompileHint 1
|
Used on hint brushes. |
0x00000200 | SURF_SKIP | %CompileSkip 1
|
Completely ignore. Causes unexpected results when applied to anything other than hint brushes; use SURF_NODRAW for other brushes. |
0x02000000 | SURF_ALPHATEST | $alphatest 1
|
(not in Vanilla) Use binary transparency, using either palette index 255 of an 8-bit texture or the alpha channel of 32-bit texture as a transparency mask. |
0x10000000 | SURF_N64_UV | $basetexturetransform "center .5 .5 scale 0.5 0.5 rotate 0 translate 0 0"
|
(not in Vanilla) Halves texture sizes, without requiring setting texture scale in the editor to 2.0. |
0x20000000 | SURF_N64_SCROLL_X | TextureScroll material proxy | (not in Vanilla) Scrolls the texture on the X axis. Slower than SURF_FLOWING. |
0x40000000 | SURF_N64_SCROLL_Y | TextureScroll material proxy | (not in Vanilla) Scrolls the texture on the Y axis. Slower than SURF_FLOWING. |
0x80000000 | SURF_N64_SCROLL_FLIP | TextureScroll material proxy | (not in Vanilla) Inverts the scroll direction. |
Content flags
Content flags on different faces of a brush almost always need to match. Mismatched contents will result in Compiler errors, and leaves it up to the Compiler to decide what contents a brush should have. If two or more conflicting flags are assigned, then the flag with the lowest bit value will take priority.
Bit | Flag name | VMT equivalent | Description |
---|---|---|---|
0x00000000 | N/A | N/A | No contents, sometimes known as "CONTENTS_EMPTY".
This cannot be assigned to a texture or surface via normal means, as brush faces with the contents field set to zero in the WAL and MAP file will be treated as solid. |
0x00000001 | CONTENTS_SOLID | N/A | Default contents. Generally no need to set manually. |
0x00000002 | CONTENTS_WINDOW | N/A | Prevents the renderer from drawing the backfaces of a brush. |
0x00000004 | CONTENTS_AUX | N/A | No effect (unused).
Some compilers, such as ericw-tools, treat it as an alias for a combination of CONTENTS_MIST and CONTENTS_WINDOW. |
0x00000008 | CONTENTS_LAVA | %CompileWater 1 , along with a trigger_hurt brush
|
Makes brush swimmable. CONTENTS_LAVA and CONTENTS_SLIME also deal periodic damage to the anyone or anything in them, with lava dealing more damage than slime. |
0x00000010 | CONTENTS_SLIME | %CompileSlime 1 , along with a trigger_hurt brush
| |
0x00000020 | CONTENTS_WATER | %CompileWater 1
| |
0x00000040 | CONTENTS_MIST | Disables collision, and sometimes disables backface culling. | |
0x00004000 | CONTENTS_PROJECTILECLIP | N/A | (not in Vanilla) Blocks moving entities using CONTENTS_PROJECTILE. No effect on hitscan weapons. |
0x00008000 | CONTENTS_AREAPORTAL | N/A | Used on areaportals. |
0x00010000 | CONTENTS_PLAYERCLIP | %PlayerClip 1
|
Blocks player and bot movement. |
0x00020000 | CONTENTS_MONSTERCLIP | %CompileNPCClip 1
|
Blocks monster (NPC) movement. |
0x00040000 | CONTENTS_CURRENT_0 | N/A | Pushes stuff inside it in the specified direction. These flags can be stacked to go in diagonal directions. Effectively acts like trigger_push .
ZHLT and derivatives have tool textures that serve a similar purpose. |
0x00080000 | CONTENTS_CURRENT_90 | N/A | |
0x00100000 | CONTENTS_CURRENT_180 | N/A | |
0x00200000 | CONTENTS_CURRENT_270 | N/A | |
0x00400000 | CONTENTS_CURRENT_UP | N/A | |
0x00800000 | CONTENTS_CURRENT_DOWN | N/A | |
0x1000000 | CONTENTS_ORIGIN | %CompileOrigin 1
|
Sets the origin of brush entities. |
0x2000000 | CONTENTS_MONSTER | N/A | Internal flag, do not set. |
0x4000000 | CONTENTS_DEADMONSTER | N/A | Internal flag, do not set. |
0x8000000 | CONTENTS_DETAIL | %CompileDetail 1
|
Brush does not chop structural brushes, and does not affect VIS. It may, however, still affect visibility. |
0x10000000 | CONTENTS_TRANSLUCENT | N/A | Marks brush as able to be seen through.
Automatically set by SURF_TRANS33 and SURF_TRANS66, and in some compilers, SURF_ALPHATEST. |
0x20000000 | CONTENTS_LADDER | %CompileLadder 1
|
Makes climbable. |
0x40000000 | CONTENTS_PLAYER | N/A | (not in Vanilla) Internal flag, do not set. |
0x10000000 | CONTENTS_PROJECTILE | N/A | (not in Vanilla) Internal flag, do not set. |
Variants
- Daikatana WALs are mostly identical to Quake 2 WALs, but have 8 mipmaps instead of 4. This makes them more suitable for hardware renderers than Quake 2's format.
- SWL files are used by SiN.[Elaborate?]
- M8 is a variation of Quake 2 WALs that stores its own palette. Like WAD3, this adds 768 bytes to the file size.
- M32 is a variation of Quake 2 WALs that stores its mipmaps in an uncompressed 32-bit RGBA format, best suited for textures with translucency.
- WAL_JSON is a JSON file used by ericw-tools which can store the metadata found in a WAL, allowing compiling maps with textures that use other texture formats (TGA, PNG, or JPG) without also creating an associated WAL file. It also adds a color value to override the color of texlights.