README.md

wal

Tools to work with Quake game assets in R. Useful for messing with Quake and Quake II game textures. Can read, write, create and export bitmap images in WAL file format and related texture formats. Includes tools to extract WAD and PAK files. Can read Quake and Quake II models in MDL and MD2 formats and allows for exporting to standard mesh formats.

Vis

About

The WAL file format is an old format for storing indexed bitmap images, used as textures in idtech1 and idtech2 games. A single WAL file contains four mipmaps of the same image. WAL format files are indexed but do not contain the palette needed to reconstruct the image. You can use your own palette, or use the Q1 or Q2 palettes that come with this package.

Note that whe WAL textures are stored inside Quake pak file archives (baseq2/pak0.pak), so you will not see any WAL files in your Quake 2 directory unless you extracted them for mapping or modding. For Quake I, textures in a very similar format that is also supported are stored directly in the BSP level files (which are inside Id1/PAK0.PAK), or in WAD files.

Package features

Managing WAL images:

Related Formats and Features:

Installation

I recommend to install the stable wal version from CRAN. In your R session:

install.packages("wal");

To install the development version (no complaints or bug reports, please):

install.packages("devtools");
devtools::install_github('dfsp-spirit/wal')

Package API

Reading and displaying WAL textures in R

wal_file = "~/path/to/q2_pak0_extracted/textures/e1u2/basic1_7.wal";
wal = wal::read.wal(wal_file);

plot(wal);  # S3 plot method for 'wal' instances, uses preview palette. Alternatively:
wal::plotwal.mipmap(wal, mip_level = 1L, apply_palette = wal::pal_q2());  # Plot with full control.

Exporting WAL textures to other formats

wal::wal.export.to.jpeg(wal, "~/mytex.jpg", palette = wal::pal_q1(), quality = 0.95);
wal::wal.export.to.png(wal, "~/mytex.png");          # palette defaults to pal_q2().

Convert a JPEG or PNG image to WAL format

jpeg_file = "~/mytextures/bricks_256x256.jpg";
wal = img.to.wal(jpeg::readJPEG(jpeg_file));
wal::writeWAL("~/myfile.wal", wal);

For more information, read the detailed vignette that comes with the package. Examples for working with models and archives can be found in the unit tests.

References

Documentation on the WAL format seems sparse. I did not find any official spec so I used the Quake 2 source code to learn about the format. Relevant files are:

Unit tests and CI

R-CMD-check

AppVeyor build status AppVeyor CI under Windows



dfsp-spirit/wal documentation built on Feb. 5, 2024, 1:59 p.m.