Wrath Mapping: Shadergen

Sun, Mar 10, 2024 3-minute read

Here’s a handy tool for generating shaders for Wrath’s Q3BSP.

Shadergen3 is a command line tool that takes two arguments. First is a manifest file that lists the shader name and path (see included input.txt for example or below) and the second is the name of the actual .shader file you want to generate from it. If you’re converting a WAD file for use with Q3BSP in Wrath: Aeon of Ruin, use this tool to save some time by generating a .shader file from your exported graphics which you can then add other shader parms as needed such as defining a surface type for footstep sounds needed by Q3Map2.

Download Shadergen3

Once you have placed or exported your textures in a folder like textures/mycustomtextures/.tga,.png, etc…:

C:\PATH_TO_WRATH
├── kp1
├── Yourmod
│   └── textures/mycustomtextures/*.tga,*.png, etc...
│   └── scripts
|       └── shadergen3.exe
|       └── shaderlist.txt (found in pak001.pk3)
|       └── mycustomtextures.txt
└── Wrath.exe, etc...

Inside your scripts/ folder. Drop in shadergen3.exe. Create a .txt file for shadergen3 to use. List all the textures you want to create shaders for, call it something like mycustomtextures.txt next to the Shadergen3.exe. This file is only used by shadergen3:

mycustomtextures.txt:

textures/mycustomtextures/one
textures/mycustomtextures/two
textures/mycustomtextures/three
textures/mycustomtextures/four
textures/mycustomtextures/five
textures/mycustomtextures/six
textures/mycustomtextures/seven
textures/mycustomtextures/eight

Run via powershell or a batch file with the following commands:

generate_mycustomtextures.bat:

Shadergen3.exe mycustomtextures.txt mycustomshaders

If all went well you should see mycustomshaders.shader generated and should look like this when opened in Notepad:

textures/mycustomshaders/one
{
	qer_editorimage textures/mycustomshaders/one
	{
		map $lightmap
		map textures/mycustomshaders/one
	}
}

textures/mycustomshaders/two
{
	qer_editorimage textures/mycustomshaders/two
	{
		map $lightmap
		map textures/mycustomshaders/two
	}
}

textures/mycustomshaders/three
{
	qer_editorimage textures/mycustomshaders/three
	{
		map $lightmap
		map textures/mycustomshaders/three
	}
}
etc...

If you generated your new .shader file outside of the scripts folder, drop your newly made mycustomshaders.shader file into yourmod/scripts folder (or kp1/scripts).

Open up scripts/shaderlist.txt and add the name of your .shader file to the end, in our case it should be mycustomshaders, Q3Map2 uses this to check for shaders when compiling maps.

shaderlist.txt:

...
trees
warp
weapons
weddev
surface_stone
surface_wood
...
mycoolcustomshaders

NOTE: If you don’t see a file called shaderlist.txt, you can extract it from pak001.pk3, pk3 files can be opened just like any other .zip file.

Here is a list of all the current surface types in Wrath (found in custinfoparms).

	generic 		0x00000000
	dirt 			0x00000040
	grass 			0x00008040
	gravel 			0x00018000
	grate 			0x00020000
	metal 			0x00020040
	ice  			0x00028000
	mud 			0x00028040
	puddle 			0x00040000
	soft 			0x00040040
	snow 			0x00048000
	stone 			0x00048040
	wood 			0x00060000
	flesh 			0x00068000

To use these is simple, add surfaceparm [surfacetype] to your newly created shader:

textures/mycustomshaders/three
{
	surfaceparm dirt
	qer_editorimage textures/mycustomshaders/three
	{
		map $lightmap
		map textures/mycustomshaders/three
	}
}

Just remember, if you change a surface type, you must recompile your map as this information is baked into the surfaces of the BSP file itself.

And that should be it.

Good luck and happy mapping!