Model Creation Overview

From Valve Developer Community
Jump to: navigation, search
English (en)
Edit
Some parts of this article have been broken down into other pages:
Studiomdl, Exporting a model, Compiling a model

This article is an introduction to modeling characters, weapons, vehicles and props for the Source Engine. Other articles in Category:Modeling cover the process of creating, rigging, animating, compiling, and defining physics interactions in more depth.

Basic files and tools

Softimage Mod Tool for Half-life 2 and other Source-Engine related Games/Mods

All of the models in Half-Life 2 were created with Softimage|XSI. The free version of Softimage|XSI, called Softimage Mod Tool was especially tailored for prop and character creation by modders but is discontinued. It can still be downloaded from unofficial mirrors, found on the Softimage Mod Tool page. The Valve Source Plug-in can still be downloaded from the Autodesk website (direct link).

.SMD files

.SMD files are exported from Mod Tool through the file/export menu. They come in three "flavors":

  • The reference SMD file is a complete snapshot of the model, including its geometry, its skeletal structure, its texture, and the links between its mesh vertices and its skeleton. Reference .SMDs do not contain any animation data -- they produce only a static image of the complete model at one point in time.
  • The physbox .SMD file is the volumes that the physics engine used to calculate collisions and any links between its vertices and the skeleton.
  • The animation .SMD files contain only animation data and enough skeletal information for the StudioMdl program to be sure that the animation data matches the skeleton of the reference model.

As you can see any animated model will require at least two .SMDs – and a glance at the Half-Life source files in the SDK will show you that most models include a very large number of animation files. Most models however will use only a single reference .SMD.

.QC files

It may be helpful to think of the .QC files as a kind of table of contents for model projects: the .QC provides a complete list of all the assets which will be included in a finished model. The primary function of the .QC is to tell the StudioMdl compile program where to find textures and SMD files.

The .QC is also the place where game-engine data is specified. For example, the .QC file tells the engine where to place effects like glow sprites or smoke, what animations correspond to the various AI activities, and when certain sounds should be played.

StudioMDL

Studiomdl.exe is the command-line program that actually creates the Half-Life model files. It takes the name of a .QC file as a command parameter and uses the .QC to find the relevant .SMD (model) files. The program also provides feedback on the amount of memory used for the completed model's geometry, textures, and animation data, which can be useful in debugging and optimizing your models. See Compiling Models Basics for information on how to compile models with studiomdl.exe.

If you're not comfortable with using the command line, you may want to try one of the third party tools, such as GUIStudioMDL or Studiocompiler or Crowbar

.MDL files

The final output of Studiomdl for each Half-Life model is a group of files in the gamedirectory/models folder ready to be used by the Game Engine:

  • an .MDL file which defines the structure of the model along with animation, bounding box, hit box, material, mesh and LOD information,
  • a .VVD file which stores position independent flat data for the bone weights, normals, vertices, tangents and texture coordinates used by the MDL,
  • currently three separate types of VTX file: .sw.vtx (Software), .dx80.vtx (DirectX 8.0) and .dx90.vtx (DirectX 9.0) which store hardware optimized material, skinning and triangle strip/fan information for each LOD of each mesh in the MDL,
  • often a .PHY file containing a rigid or jointed (ragdoll) collision model,
  • and sometimes a .ANI file for on-demand loading of animation sequences created using QC command $animblocksize. This is ideal for "cinematic physics".
  • Several NPCs also make use of additional .MDL files to hold animation data. Usually the NPC classname is appended with a descriptive label, such as:
  • _animations.mdl, _gestures.mdl, _postures.mdl
  • _ss.mdl
  • _shared.mdl

.VTF & .VMT files

In order to work in game, all world models must have a 'material' and at least one 'skin' as well as mesh geometry.

  • The skin begins life as a targa (TGA) image file which must be mapped to the mesh geometry in XSI's Render Mode before exporting the SMD.
  • Prior to compiling the MDL, you must compile the TGA to a VTF (skin data) file (using Vtex or studiocompiler) and create a VMT (material data) file (using Notepad or studiocompiler). Both VMT and VTF files must be placed in the gamedirectory/materials/models folder so that the MDL file knows where to find the right material and textures to apply to the model.
  • You can include additional skins, such as normalmaps, by referencing them in the .VMT file. Because the VMT file is external to the MDL, you can tweak its contents (but not its name or location) without recompiling the MDL. Also, the VTF is external to the VMT, so you can tweak (and recompile) the skin without changing the VMT or MDL.

.JPG files

Optionally you can create a thumbnail image of your model that will appear of Modelviewer's "Load Model" file browser. With a large library of models these previews make it easier to find the model you want to work with. Preview images must be saved with the same name as the model use the JPEG image format and progressive encoding (standard or lossless encoding will not work). Preview Images must be at least 96x72 pixels, anything bigger gets scaled down.

Modeling workflow

Before starting any sort of modeling, you should have a clear drawing, much like a blueprint, for your character, vehicle or prop. Once you've designed the character, you can create your geometry, edit the hard edges so it lights properly, add UV coordinates for the texture, envelope the mesh to your skeleton, add any facial expressions.

Character Modeling Considerations

Before you start designing your model, you may want to consider a few things like, performance, in game usage, budgets, animation concerns, and naming conventions. The biggest thing you need to consider before you start planning your model is the role this model has in your Mod.

How is this character going to be used?

Is this a character that's always going to be attacking from far away, or fighting up close? Is this character going to appear in dark spaces or in daylight, or both? What's the overall color of the backgrounds this character is going to appear against? How important or central is this character to your mod, is it a main character, or a seldom seen prop? The best thing you can do for your design, overall, is decide what the most likely distance, pose and environment this character is going to appear in during play, then make sure the character works best in that situation.

Concept art

Most of the time, you should start your model with a piece of concept art that solves most of the design issues at hand, this is where you decide what your character is, what shape it has, what the materials should look like and even what some of the basic poses for the animation set might be. This is also a relatively painless way to test out ideas with your team without spending the time required to build, texture and animate a character. Before you go any further, you should try and get as much feedback on your design as possible. All of the characters in Half-Life 2 went through multiple versions and refinements before they were finalized.

The Model Sheet

This model sheet shows the front and side views of the male and female resistance fighters from Half-Life 2.

Concept art usually shows a character posed and shown from an angle that may make it difficult to use as reference in modeling, so as your next step, you should make a model sheet. The model sheet is a view of the character from the front and the side, drawn straight on without any perspective, and in a neutral pose. The model sheet is a blueprint of your geometry, where you make decisions about proportions, silhouette, and form. Usually, you'll want to use the model sheet as the background image in your viewports in XSI while modeling, (sometimes referred to as Rotoscopy, see the XSI documentation)

This model sheet shows the front and side views of the male and female resistance fighters from Half-Life 2.

Performance and Budgets

Polygons counts for some of the Half-Life 2 characters:

  • Soldiers: 4,682
  • Police: 3,852
  • Resistance: 4,976
  • Zombie: 4,290
  • Helicopter: 6,415
  • Strider: 6,444
  • Alyx: 8,323

Vehicles:

  • Buggy: 5,824
  • Jalopy (muscle car in Ep2): 16,536
  • Mil Mi-8: 25,024

There are no fixed rules in determining how many polygons you use in your model, or how much texture resolution you'll use in your materials. There are upper limits of engine capability, (10,000 polygons/model, 17,433 vertices, 4096 texture size and 128 bones) but these aren't usually going to be what you're shooting for. You'll need to consider how many of the character, vehicle, or prop you're making will be on screen. If you'd like dozens of them on screen at any given time, you'll have a different budget than if you'd only like to see one of them ever on screen at a time. With humanoid characters, especially for multiplayer use, you shouldn't need to go over 4000 polygons to get a character that has enough detail to accurately describe the form, bend properly at the joints, and have enough edges to light properly. Of course you can have more than that, but with normal mapping, and high res textures, you shouldn't really need to.

One good thing about working in XSI is that you can keep your model as quads and have clearly organized edges (edge loops) that define the shape, with this sort of a model, it is easy to add and dissolve edges, especially since the UV coordinates are preserved and you can easily re-envelope your mesh with saved vertex weights. Discrete levels of detail are supported in the Source engine and can drastically improve scene rendering speed.

Tip.pngTip:Although there is a limit of maximum 17,433 vertices per .SMD, the limit per .MDL is much higher: 63828 vertices and 127474 triangles (anything that exceeds these numbers will result into a broken model). To achieve this - split your model into multiple .smd files and simply specify them with $model, $body or $bodygroup (each smd should still be 17,433 verts max). Keep in mind that $staticprop may misbehave if used with bodygroups.
Note.pngNote:Source Filmmaker Counter-Strike: Global Offensive Splitting is automatically done in certain distributions of StudioMDL, where each SMD that goes over the base limits will be split into separate bodygroups on compilation.

Example:

	$model "pill1" "pill1.smd"
	
	$model "pill2" "pill2.smd"
	
	$model "pill3" "pill3.smd"
	
	$model "pill4" "pill4.smd"
Blank image.pngTodo: The "63828" has been only tested with Half-Life 2 and Episodes. Find out if these limits are also applied to other games, like Garry's Mod, CS:GO, etc
Blank image.pngTodo: Is there a limit of bodies per .mdl ?
Blank image.pngTodo: What other distributions of StudioMDL do the automatic splitting?

Creating Geometry

By now you have a rough idea of how your character model is going to be used, what sort of a design you're creating, the specifics of the geometry from front and side, and what your triangle budget looks like. Now it's time to start creating your geometry. How to create geometry isn't specific to creating models for the Source engine, so we won't cover it in depth here, we'll just talk about some basic guidelines that may smoothe the process.

Approaches to Modeling

There are a number of ways to start creating a model, but the defacto industry standard is subdivision surfaces. When creating content for the Source engine, you'll most likely be using only one or two levels of subdivision, but this is still a good way to get organic shapes from low poly control cages. Using this method, you'll be doing most of your work by extruding geometry, and moving the resulting vertices and edges around until they match the model sheet you have in your viewport background. One common mistake made by beginning modelers is not taking advantage of the vertex weight influence on the resulting subdivision, please refer to the XSI documentation for more info on working with subdivision surfaces. At a certain point in the process, you will have to take direct control of the resulting mesh to do your final, small scale detailing.

Symmetrical modeling

Learning to identify areas of symmetry in your model can help to save time in the modeling, UV creation and Texturing process. Also, repeating elements in your design should only have to be created once, then cloned around the model as needed. There are various tools for modeling symmetrically, but using Symmetrize Polygons is by far the most effective. With this XSI tool (Model>Modify>Poly. Mesh>Symmetrize Polygons) you can duplicate areas of your mesh with a specified transform while preserving the UV coordinates and any other properties you may have defined.

Edgeloops and Animation

One thing that is required when creating your model is a good arrangement of edges around joints so that they deform accurately, with proper edge loops and enveloping, you can even have shoulders that work in most all positions. The position and envelope weight of the Edgeloops will almost always need tuning after you've enveloped your mesh to the skeleton and test a few poses.

Editing Hard/Soft Edges

After you've carefully constructed the geometry that makes up your model, you'll need to define which edges on the model should be creases. You can use the automatic smoothing option, but this usually yields less than ideal results. Choosing where hard edges go isn't a simple task. Hard edges are usually used to define creases, cracks, boundaries between materials, areas where the geometry has large angles between faces, (more than around 75 degrees). In general, all edges that have more than 90 degrees between polygons should be a hard edge, so you may want to start with that as an automatic hard edge setting. To edit hard edges, enter into an edge select mode (hotkey "i" for example) select some edges, then right click on the selection and choose Mark hard edge/vertex. Selecting those edges again, and choosing the same command act to toggle the hard edge property. You may also remove hard edge properties by deleting the edge node in the explorer.

Defining your UV coordinate space

XSI with multiple UV sets.

The next step in the modeling process is editing your UV coordinates. For basic information on editing UV coordinates, Please refer to the XSI documentation, (section Shaders, Lights and Cameras. Section: Texturing Basics). One common pitfall when starting to use the texture editor in XSI is ending up with multiple UV sets, You'll want to only have one UV set per model. In this figure, you can see how in one Texture coordinates node, you can inadvertently end up with multiple UV sets.

For the beginner, this is generally to be avoided. If you have good information in both sets, use the copy and paste UV functionality in the Texture Editor to consolidate your UV sets.

As a starting point, Try using the Get>Property>Texture Projection>Cubic mapping type, this will give you a series of good UV Islands. You can then use the Island Heal tool in the texture editor to quickly merge these pieces and correct for transform and scale. Again, refer to the XSI Documentation section The Texture Editor, Healing Polygon Islands.

After some careful healing and arranging, you should have a set of UVs with little distortion or streaking. Using this Checkerboard Starter Texture (right-click Save As...) as your starting material can help you evaluate your UVs. If you see an area with unacceptable distortion, liberal use of the Relax UV tool can solve most problems. In cases where this won't work, just use a Subprojection from the Texture Editor to reapply the UVs in that space.

Enveloping the mesh to your skeleton

When you've got a good first pass on your geometry, UVs are set, and you have a skeleton that's acceptable, it's time to envelope your mesh to the bones. You access this through the animation command panel, pressing 2 will switch the toolbar to animate mode. With your mesh selected, choose Deform>Envelope>Set envelope, then select the bones you'd like to include. To edit the resulting envelopes, use the weight panel, accessed through the brush icon near the bottom left corner of the UI. On this panel, you can also access the weight editor, where you can save and load envelope weights. For an in depth explanation of the Enveloping process, refer to the XSI documentation section: Envelopes.

Tuning your envelopes and geometry for animation

Usually, the first pass on an envelope is done in the skeleton's reference position, but this won't tell you how the envelope is really working, to see the envelope in action, you need go through a back and forth process of editing the envelopes, moving the skeleton around, then correcting the deformation by tuning your envelopes. At this point, it may be necessary to add edgeloops to joints, if you can't get good deformation through envelope tuning alone. XSI is ideally suited to this process though, since it's non linear, you can adjust your geometry without reapplying your envelope operator again and again.

Directories and Workspace Setup

Directory Structure

See Source SDK Files and Directory Structure for information on the location of the compiled models and source files. See Compiling Models for information on how to compile models using this structure.

Windows tips

In windows explorer, open the Tools > Folder Options > File Types menu. Associate .MDL files with HLMV.exe, double clicking on a .mdl file with automatically preview it in the modelviewer. Associate .QC files with the studiomdl.exe, so that you can compile the model simply by double clicking the .QC file. You can always use the Open With... command to edit it in a text editor such as notepad, or you can add entry in the right-click menu named Edit, which will open the .QC file in the text editor. You can also create an entry in the right-click menu for compiling .TGA files with Vtex.

As an alternative (or in addition to the above techniques), create desktop shortcuts to studiomdl.exe and vtex.exe. You can then drag-and-drop .QC files onto the StudioMdl shortcut and .TGA files onto the Vtex shortcut to compile them.

See also