Materials for models

From Valve Developer Community
Revision as of 18:54, 8 April 2005 by Erik Johnson (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

Materials for Source have a few components, the source files (.TGA file and .TXT file), the material definition, (.VMT) and the output from Vtex, the .VTF file (what’s seen in engine).

TGA source images

You can use whatever application you’d like for creating your source .TGA, most people choose to use Photoshop, Painter, Zbrush, or Deep Paint, depending on the needs. You should definitely keep a layered full size version of your source separate from the collapsed downsized version you convert into a .VTF.

VMT material definitions

Each Material for the Source engine needs a .VMT file. The .VMT file defines the lighting model, the base texture, and any other additional channels you may have like: specularity, self-illumination, normal mapping, transparency, translucency, and proxy shaders. Here’s an example .VMT file from HL2:

"VertexLitGeneric"
{
     "$baseTexture" "Models/Combine_soldier/Combine_elite"
     "$envmap" "env_cubemap"
     "$bumpmap" "models/combine_soldier/combine_elite_normal"
     "$normalmapalphaenvmapmask" 1
     "$envmapcontrast" 1
     "$model" 1
     "$selfillum" 1
}

This example is a material used on a polygonal model, using the “VertexLitGenric<<code>$baseTexture" "Models/Combine_soldier/Combine_elite" along with the environment map "$envmap" "env_cubemap", (env_cubemap refers to cubemap entities placed in the level, the specular reflections of this character will always reflect the world around it, assuming you have cubemap entities placed approprirately in you level. You can use a custom cubemap instead, of you choose. The normalmap is defined next. The next line "$normalmapalphaenvmapmask" 1 tells the renderer that this material has a mask for the specularity, so only some areas of the model will reflect the env_cubemap information, as defined in this case by the alpha channel of the normal map, the specual mask can be here, in the alpha of the basetexture <</code> or in a separate mask <</code> <</code> For this model, the environment mask is multiplied by itself one time to create more contrasy reflections, the "$envmapcontrast" 1 command controls this. All models need to also contain the command, "$model" 1 which tells the renderer that this material is being used on a polygonal model created from StudioMDL. The last line "$selfillum" 1 tells the renderer that the alpha channel of the basematerial contains self illuminated areas, these areas of the alpha channel show up as glowing areas of the model.

Proxy shaders

The most powerful component of the source engine material system is the Proxy shader system. Examples of what proxy shaders are capable of are shown in the shaderzoo map contained in the sdk, and furthur documentation on thier creation can be found in the materials documents.

VTEX texture converter

Vtex is an application used to convert .TGA files to the source engine format (.VTF). The simplest way to use Vtex is to create a shortcut to vtex.exe on your desktop, and drag .TGA files onto the shortcut. This will create a .VTF file in of the same name as your .TGA file in the materials directory. When you drag open a tga file with Vtex, a .TXT file is also created in the same directory as your .TGA, in this file you can issue commands to Vtex to alter your compression.

For quick material creation, try adding "-shader VertexLitGeneric" to your target field in the Vtex shortcut properties. this works with any shadertype. Dragging a texture on to this modified shortcut will then create a .VTF file as usual, and create a .VMT file with the shader and basetexture defined for you.

Checkerboard Starter Texture

Using a checkerboard texture is a good way to start laying out your UV coordinates; this lets you see very quickly if you have any distortions, streaks, or seams that may need to be corrected. Also, using a checkerboard texture gives you a very good way to measure how much texel density you have on the various parts of your model, as you define the UV’s, some areas like faces may need a bit of extra density, but overall you should strive for even and consistent texel density across your model. The default noicon.pic file in XSI is a good choice or you may use this file, Checkerboard Starter Texture (right-click save as...) included in the SDK.

Applying Textures in XSI

Applying textures in XSI is fairly straightforward, you should try to only use one basetexture, unless material demands require otherwise. Multiple textures on a model can drastically affect rendering time. To apply a texture to your model in XSI, select your model, then get property>material>blin, then get>texture>image. You can then point XSI to the location of your texture. If you do need to create multiple textures on one model, you must first select a group of polygons, make a cluster of them, then apply the material and image to your cluster. Make sure that you have your preferences set to "reload externally modified images on focus". This reloads textures when you alt-tab back to XSI from another program like Photoshop, a good time saver.

Proper Previewing

Making judgments about the progress of your textured character should be done directly in the Source engine, before getting too far with your material, export a vtf, create a vmt, build you mdl and look at the model in the engine. Working the fine points of texturing and shader parameters can only really happen after you’ve seen your model in the Engine.

How large should my material be? Export a .VTF as early as possible and load preview your model in the engine, using the mat_showmiplevel command at the console, check what mip level you’re seeing at some of the most common encounters your character is going to have during gameplay. While it may seem that bigger is better, this isn’t always the case, mipmapping can force your large texture down in size until blurriness becomes a problem.

© 2004 Valve Corporation. All rights reserved. Valve, the Valve logo, Half-Life, the Half-Life logo, the Lambda logo, Steam, the Steam logo, Team Fortress, the Team Fortress logo, Opposing Force, Day of Defeat, the Day of Defeat logo, Counter-Strike, the Counter-Strike logo, Source, the Source logo, Hammer and Counter-Strike: Condition Zero are trademarks and/or registered trademarks of Valve Corporation. Microsoft and Visual Studio are trademarks and/or registered trademarks of Microsoft Corporation. All other trademarks are property of their respective owners.