More on the texture preview tool
I previously wrote about a tool we're developing to speed up texture production. This tool is a Source map/model viewer with the ability to "hot load" textures, materials and models. The idea behind this tool is that an artist can keep it open while working on an asset in Photoshop, and as soon as they make a change, they can see it updated in a 3D environment that closely matches what it would look like in-game.
The core functionality was in place the last time I blogged about it, but the "closely matches" part was somewhat unfulfilled. Since then I've added quite a bit, including support for loading models, fixing the shaders, support for self-shadowed radiosity normal mapping, rendering the sky (both the sky box and the 3D "sky model"), and loading files directly from Steam's GCF archives.
Here's what a Team Fortress 2 level looks like loaded in our viewer:
As you can see, it is indeed getting pretty close. Not everything is exactly as it appears in Source, but I'll leave it as an exercise for the reader to figure out the parts that aren't quite perfect yet.
I also did some optimization so that levels load and render faster in the viewer; this is one area where I'm particular optimistic about transferring my experience back into the Natural Selection 2 code base. One of my pet-peeves about most modern games is slow load times, and I hope that we can significantly raise the bar in that area.
The other side effect of working on something like this is that I've learned a few things about the Source engine. In fact, I originally wasn't planning on adding support for meshes -- it didn't seem necessary for the original purpose of the tool -- but I decided to implement it specifically to learn more about how they work. This is something I found necessary for low level access to world meshes that our dynamic infestation feature requires.
A number of people asked in response to the last blog whether or not the viewer supports hot loading of VMT files. VMT files are text files that describe the material properties for a surface in Source, including the diffuse texture, normal map, specularity, etc. Hot loading of these files wasn't part of the original functionality, but I've since added it (check out the last podcast for more on this).
Meshes can also be hot loaded, but they must be compiled using the Source tools before they are reloaded. For texture files, our viewer can directly load Photoshop PSD files, eliminating the need for artists to compile textures as they work on them. Every time they save in Photoshop, the viewer is automatically updated with the changes. The same system doesn't work for models because 3D Studio MAX files are very difficult, if not impossible, to load outside the environment of 3D Studio MAX. In the past I've found a way around this problem, but due to the complexities of the Source MDL format I don't think it would be worth the effort involved.
There are a few more things I'd like to add before I'm ready to call the viewer done, but I'm pretty happy with the state it's in now. In future blog entries we'll discuss our art pipeline and how this tool integrates into it.