Texture preview tool

Posted by unknownworlds 15 years ago

In the latest podcast we talked a bit about hot loading and a tool we’re developing to make texture creation a bit easier and quicker. Hot loading is when you reload something while the application is running.

The tool we’ve developed is a level viewer that loads Half-Life 2 BSP files. It monitors disk activity and when it detects that a texture file has been modified it automatically performs that hot loading. That makes it easy to quickly preview what a texture file will look like in-game without having to manually reload anything.

In addition to this hot loading, the viewer can also load texture files in the Photoshop (PSD) format. Artists like to work with PSD files because they can store information – like layers, effects, etc. – that other formats discard. However, to get textures in-engine with Source, you have to export to TGA files and then run the command-line tools to convert them to Valve’s VTF texture format. Since our viewer can use PSD files directly, artists can bypass those steps until they’ve finished creating the texture and are ready for it to be used to levels.

This pipeline allows you to have Photoshop open in one window, the viewer in another, and immediately see changes in a 3D environment as you make them. The viewer is really lightweight application, so it starts up immediately and having it open with Photoshop and other memory-intensive programs is no problem.

Here’s a video of what the tool looks like in action. The environment you is just a texture test level (the blue and cyan checkerboards are missing files) and the capture quality is not the best, but it should convey the idea.



The viewer application is built on top of our own technology and doesn’t utilize any part of the Source engine. This engine is something I’ve been working on for years and I use it whenever I want to prototype something in 3D. Since I’ve designed it to be really easy-to-use, it’s generally much faster for me to do prototyping (which requires a lot of iteration) using it rather than a big complex engine like Source. I originally added Half-Life 2 BSP rendering to prototype the dynamic infestation ideas shown in this blog entry.

(In an odd coincidence, when I was writing the BSP loading code, I referenced this article which in turn references an article I wrote many years ago on loading Quake 2 BSP files).

I’ve also experimented with how to render Half-Life 2 BSPs with Phong illumination in this engine. Those who follow these types of things may know that the Source engine includes Phong on models in the Episode 2 code base, but highlights on the environment are still handled with environment maps. The challenge with Phong comes from how the light maps are used in Source, but I found that using the light maps to approximate actual lights in the Phong calculations worked well.

I mention this business with Phong because this is the reason that the level in the video looks so shiny. Before this tool is actually useful to our artists, I need to modify the shaders on the walls render the same as they do in the Source engine. I’m also considering implementing the same Phong illumination shader in Source to really visually set Natural Selection 2 apart from other Source games, but that’s a topic for another blog entry.

Comments are closed.