A good sign
One of the things we’re working on at Unknown Worlds is the Natural Selection 2 Technology Release (NS2TR). We’ve described it in more detail elsewhere, but briefly the NS2TR is a set of materials, props, tools and a stripped down version of the game that we’ll be releasing prior to shipping NS2. This package should give level designers everything they need to create maps for Natural Selection 2.
We’re trying to craft the NS2TR in such a way that mappers will be able to get tons of visual variety out of the included materials. The art team has been experimenting with decals lately as a way of making the environments feel more unique and realistic. Decals are texture maps that can stuck on top of walls or objects in Hammer to add extra details not present in the base texture. Since the same decal can be combined with different base textures, you can get a lot more combinations out of the same set of art assets. Some of the things we’ve been turning into decals are rust stains, control panels and signs.
In Natural Selection 1 the rooms in all of the maps are tagged with a names for easier navigation. These name of the room you’re currently in is displayed on the HUD, but why not also include signs in the world with those names to help you get from one area to another?
When we considering this possibility for Natural Selection 2, we realized there was a problem. Every piece of text requires a separate texture map, which on top of being a lot of work, means we’d have to know the names of all the areas ahead of time. As an alternative, someone on the team suggested procedurally generating sign textures at run-time. Besides saving the development time, loading time and disk space, procedurally generating the signs makes it really easy for mappers to place custom signs with their own text. Since they are created at run-time, it also gives us the option of localizing all of the text on the signs so that they appear in the player’s native language.
As I began implementing, I realized that by generalizing the system a little we’d be able to do a lot more than create simple signs. My first step was to change the system from working only with decals to hooking directly into the material system. Since decals are drawn using the material system, this change still allows us to create procedural decals. The advantage is that in addition to working with decals, we can also apply procedural textures to any surface or object in the game world.
The second change I made was to use our scripting system to control the drawing of the texture. Contrast this with the original design — hard coding the system to just draw a single line of text for the sign. Sure you can add parameters to control different aspects of the hard coded approach, like the font, color, size, etc., but say you wanted a sign that looks like old peeling paint? Or a neon sign that flickers? Or a sign with text centered below an icon? Since these behaviors don’t have much in common, crafting a reasonable set of parameters to control them would be difficult. The scripting system, on the other hand, allows for all of those (and more) through a simple set of drawing functions. Since we already had a mechanism in place for drawing the UI from script code, I just hooked into the same mechanism and now any of the facilities that we could use to draw the HUD we can also use to render onto textures.
I mentioned earlier that the motivation for these changes was to allow us to do a wider range of things with the system. So what kinds of things can it do? Since the texture generator is in script code, it can use any of the game state to influence the creation of the texture. For example you could create a score board in the world that displays the names of the current leaders (think DM-Morpheus from the original Unreal Tournament). Or you could put an ammo readout on the back of a weapon like in the concept artwork I posted last week. Or you can combine a face texture, a body texture and skin hue modifier at load time to generate a unique player appearance based on the user’s preferences. Or you could implement Conway’s Game of Life on all of the computer monitors in your space station. As you can see, the possibilities are vast with a flexible system like this. Let’s hear your ideas.