VERC: Detail textures in Half-Life Last edited 1 year ago2023-04-10 14:41:18 UTC

First off, what are detail textures? A detail texture is simply an extra texture that is faded in as you get closer to a surface, providing extra detail instead of the usual blur when a texture is enlarged. A picture tells a thousand words, so have a look at image one and see how much of a difference detail textures can make.
Close-up of a texture, with detail texture (right) and without (left)Close-up of a texture, with detail texture (right) and without (left)
So, how do you get detail textures into your map? Well, you'll need two things: the detail textures themselves and what I call a "detail texture list file".

The Detail Textures

The detail textures themselves are simply images, usually with 50% grey used as a base colour. Darker and lighter greys are used to make shadows and highlights. Detail textures should be a power of two in size, as 256x256 is the maximum size Half-Life will load. I found that 128x128 often works well. When you've got the detail texture looking how you want it, save it in the gfx/detail/ folder as a 24-bit uncompressed TGA. It's important you get that bit right - any other format and Half-Life won't load it properly.
The detail texture used to produce image oneThe detail texture used to produce image one

Detail Texture List File

The list file is what tells Half-Life which detail textures to use on which surfaces of your map. It is a plain text file and should be placed in the same directory as your BSP. It should have the same name as your map with "_detail.txt" appended. For example, if I was adding detail textures to ns_example.bsp, then the list file would be called ns_example_detail.txt.

The list file should contain one line for each texture you want to have a detail texture. Each line should have four items, seperated with tabs. The first item is the Half-Life texture name. The second item is the path to the detail texture, relative to the gfx directory and without the extension. The third and fourth items specify the x and y scaling for the detail texture. If that all sounded a bit confusing, here's an example: say I wanted to use the detail texture gfx/detail/ground3.tga wherever the texture out_pav3 occurs. I might use a line looking like this:
out_pav3    detail/ground3    10.0    10.0
And that's it! If you load up your map, you should see the detail texture.

Notes

This article was originally published on Valve Editing Resource Collective (VERC).
The archived page is available here.
TWHL only publishes archived articles from defunct websites, or with permission. For more information on TWHL's archiving efforts, please visit the TWHL Archiving Project page.

3 Comments

Commented 1 year ago2023-06-20 17:06:31 UTC Comment #105364
A couple things I want to note, but am not putting directly on the page (as it's an archived tutorial):
  • The TGAs used for detail textures can be RLE compressed, as long as they don't have an alpha channel (they don't use it anyway).
  • I think 512x512 detail textures are supported on modern hardware; don't quote me on that, though.
  • Users whose GPUs have blocked the GL_ARB_multitexture extension (such as for enabling overbright lighting without Xash) will not be able to enable detail texturing.
  • As of late 2019, detail textures on non-power-of-two WAD textures do not display correctly when mipmapping is enabled (unless gl_round_down is enabled, probably).
Commented 6 months ago2024-06-08 23:29:10 UTC Comment #106198
I got linked here after going on a nostalgia-binge of Half-Life modding sites and was very surprised to see this article preserved from VERC! I'm the original author and never expected it to be preserved twenty years later :)

Some of the commenters on the original VERC article were a little... suspicious... of how I managed to decipher the format of the detail texture list file given that the only software using it was the (then un-released) Counter-Strike: Condition Zero. Despite my protestations to the contrary, after twenty years I feel I can come clean: yes, I downloaded a pirate copy of CS:CZ. In my defence I was an idiot 19 year-old who was really excited to figure out a new feature for one of my best-loved games and wanted to document that for everyone to use (and get a bit of recognition myself).

It also wasn't strictly necessary -- the cvars were publicly known, and I had access to a legit copy of IDA Pro; I just didn't want to go to the effort of reversing the client DLL given Valve's import table stripping. I later did that anyway to try and figure out the function pointer table entries that were added post-Steam but not mentioned by Valve. Never documented any of that publicly though; most of them weren't useful for single-player modding which was where my interest lay. All long since lost several hard drive failures ago. The cheater community, I'm sure, figured them all out long before me and I didn't play multiplayer anyway.

I'm glad someone is still keeping the HL modding scene alive though -- it's one of the most thoroughly-documented games/engines I know of, right from the era where a tiny mod team could produce content rivalling commercial releases. My playing around with the HL SDK eventually helped me get a job as a software developer barely a year later! Not the games industry itself (too stressful!), but having the ability to play around with a 'real' piece of software's code was a massive boost for me. It helped me grow from knowing I could make a computer do whatever I wanted to knowing how to tell it to do that, and it did it in a context I knew and enjoyed.

All the best from the UK -- Philip
Commented 6 months ago2024-06-12 01:26:37 UTC Comment #106201
Glad to have you here, Philip! :D
Anyway, as I was originally typing...
X and Y scaling should be proportional to the aspect of the base texture. If the base texture is a skinny 16x196 texture then having both X and Y scales be 10 means each tile of the detail texture would be 1.6 by 19.6 pixels relative to the base. If you can't tell, this is horribly, horribly stretched.

Sadly there exists no tool today afaik that can easily plug in the aspect ratio values to you.

You must log in to post a comment. You can login or register a new account.