Note: This tutorial is outdated, I DONT recommend it anymore. It only serves as a backup. Please use MESA instead http://puppet-master.net/plugins/mesa-1-1/
Who you are:
A person, who finally found this tutorial, after he couldn’t find an up-to-date tutorial for Maya and the Source Engine for ages. Well, no need to worry any longer, in this tutorial n0Face and me (Nauz), two modders, modeling for the HL2 modfication called Zeitgeits, will explain you the workflow for Maya 2011 to a source game step by step.
What you should already have:
– Maya 2011 (The student/ trial version will do aswell)
– run Source SDK and the game you want to create a model for atleast once (refer to this list for all games that include the Source SDK http://store.steampowered.com/search/?sort_by=Price&sort_order=ASC&category1=998&category2=16)
1. Beginner: Setting up Maya
- 1.1. Pralls .smd in- /exporter
- 1.2. Creating a correct folder hierachy
- 1.3. Basic settings in maya
2. Beginner: Working in Maya
- 2.1. Orientation of normals
- 2.2. Assigning of materials
- 2.4. Creating a physics model
- 2.5. Preparing your model for export/ Layers
- 2.6. Exporting the model
3. Beginner: Compiling
- 3.1. Setting up ConTEXT
- 3.2. Compile
- 3.3. Create a .vtf texture
- 3.4. Create a .vmt texture
4. Advanced: Animation and more
1. Beginner: Setting up Maya
1.1. Pralls .smd in- /exporter
To export .smd files for the model compiler of source, you’ll have to copy and paste some files into the Maya 2011 folder placed in your documents.
For Windows XP user the […]\maya\2011\ folder should be somewhere similiar to this:
[…]\Documents and Settings\your_windows_username\My Documents\maya\2011\
Windows 7: […]\Users\your_windows_username\Documents\maya\2011\
Found it? Let’s get started!
First of you need to copy the files from […]\Steam\steamapps\your_steam_name\sourcesdk\maya\4.5
and paste them into your […]\maya\2011\ folder.
Next head over to http://mitglied.multimania.de/prallvamp/ and download this file:
“Half Life 2 exporter v.2.5 for Maya 4-8 by Prall”
again, paste them into […]\maya\2011\. and always choose “Yes” when you’re asked about overriding.
////Maya 2011 users only
In Maya 2011, Prall’s exporter GUI is broken. To fix it, grab this file www.holetzky.de/smdOptionWindow.mel
(Right Click and choose “save as” smdOptionWindow.mel, make sure you do NOT save it as a .txt file!)
Place it into […]\maya\2011\scripts\
////End Maya 2011 User only
Time to run Maya and check if you’re still with me!
Your Maya file menu should contain an “export smd…” option now When you click on the square right of it, your menu should be somewhat like this:
1.2. Creating a correct folder hierachy
In case you want the export script to find your model and textures, you will need to make sure you create a specific folder structure for each of your Maya projects.
Create a new folder in your […]\maya\projects\ folder, call the folder for example “Tutorial_Maya_2011_to_Source”.
This folder needs to contain a folder called “scenes”, one called “model_sources” and also one called “materialsrc”. The materialsrc should also contain a folder called “models”.
The hierachy that will bother you for the rest of your Maya-life should look like this:
When done, in Maya, go to File -> Project -> Set and choose your “Tutorial_Maya_2011_to_Source” folder.
1.3 Basic settings in maya
Per default, Maya’s up-axis is set to Y. However, in source the up-axis is Z. To avoid headaches later, in Maya go to Window -> Settings/ Preferences -> Preferences -> Settings and change the Up axis from Y to Z.
While enjoying your stay in the Maya settings, you should also change the Working Units -> Linear option to centimeter, which is directly placed under your the up axis setting.
That should make 1 unit in Maya equal 1 unit in Source. (1 unit = 1 inch = 2,54cm)
Hit save and restart Maya to apply the changes.
As a game modeler, you may want to have an eye on your Polycount.
To see it permantly, go to Display -> Head Up Display and check “Poly Count”.
Great! Your Maya is now setup to create awesome models for Source!
2. Beginner: Working in Maya
Now it is time to do some real work. We are going through the process of creating a simple cube, add a texture and a physic mesh. Then we will organize our scene to prepare it for the exportation.
You can download the Maya project created in this the following tutorial here: http://www.northcapestudios.com/tutorial/Tutorial_Maya_2011_to_Source.rar
Well, lets get started.
2.1. Create a simple base mesh
Create a simple cube:
Assuming you are familiar with Maya, this should be an easy task for you.
If you are not familiar with Maya yet, go to Create in the Main Menu bar, then
Polygonal Primitives and click on Cube.
…tadaa, well nothing worldcrushing, but keep in mind, creating the base mesh is normally one of the most time intense steps in your working process.
For our purpose lets scale our cube up to about 25 units.
To show you another issue with the source engine, turn off the your two sided lighting, to do so go in your View panel and uncheck Lighting -> Two Sided Lighting.
Now scale your mesh to about -25 units and freeze its transformations. ( Main Menu bar -> Modify -> Freeze Transformations )
You will see your mesh turning black. Why? Good question!
By default, the normals of each face point outwards, but because of the scaling into the negative direction you flipped the normals inside. Unchecking the “Two Sided Lighting” tells Maya to light only the normal side of the faces and so the outer side turns black.
This case occurs sometimes when you are extruding, extracting or using some other Maya tools.
The problem is that the source engine naturally renders only one sided, which means the black side would turn transparent in source.
To flip the normals back outside, select single faces, in component mode, or the whole object. Then switch the Main Menu bar to Polygons
go to Normals -> Reverse, this will flip the selected faces. And now your cube should return to a gray color.
Be sure to check the orientation of the normals, before exportation or animation.
Now we have a real boring looking cube, so lets go on and add some color in the chapter.
2.2. Assigning of materials
Before we can add a texture to our cube, we have to unfold the cube. This is something everyone has done at least once in school, where you build up a cube by cutting a paper shape of a T an folding it to get in a three dimensional shape.
Unfolding a polygonal mesh is called UV-Mapping, explaining this in detail would exceed the scope of this tutorial.
There are a lot of tutorials around the web about UV-Mapping so just google it.
For complex models, I would recommend this tutorial for example http://www.3dtotal.com/team/Tutorials/human_anatomy/human_01.php
You can find the tools for UV-Mapping in the Polygons Main Menu bar under Create UVs and Edit UVs.
The UV Texture Editor can be found under Window -> UV Texture Editor.
Well, my UV-Map looks like this:
The default UV map for cubes looks similiar. so you can leave it the way it is for our simple model.
The next step is to create a texture based on the model’s UV-Map. Commonly this is a task you would do in Photoshop but you can use every other picture editing program you prefer, e.g. Gimp or even Windows Paint.
My sample texture looks like this, it is nothing fancy, just simply Mario and his friends. I usually save my images as a .tga. Important is the path where you save your texture, because the exporter will put this path in the smds. Your model textures should be placed in the […]/materialsrc/models/[…] folder. For Example: in my case I put the texture in […]/materialsrc/models/tutorial_cube_texture.tga the corresponding path in which source will search for the .vmt will be […]/modname/materials/models/tutorial_cube_texture.vmt.
Keep your texture in a size of power of two, because source will get problems with other formats.
(e.g. 256*256, 512*512, 256*512, etc.)
The next step is to apply the created texture to our cube, to do so first clean up your mesh, by deleting its history.
This will delete all the nodes of your mesh except the shape node.
(If your going to animate, beware! Because you would also delete the skinCluster node, that binds your bones to your mesh. In this case, instead delete the Non-deformer history only)
To delete the history select the mesh, go in the Main Menu bar to Edit -> Delete by Type -> History.
Now the Attribute Editor should look a lot cleaner when your cube is selected.
To add a Material to the cube which is exportable, right click and hold the cube. A menu should appear. In that context menu, head down to Assign new Material… and left click.
A new Window will pop up.
Search for the PhongE Shader which is the only shader that the export script will recognize.
The Attribute Editor should open, if not press Ctrl+A to open it.
There will be a phongE1 tab, which contains all our attributes for this material.
You can edit those and experiment to get different results, but all those attributes won’t be exported, but are more or less available through settings in the .vmt file, but this will be explained in 3.5 Create .vmt file.
The next step is to assign a File node to the PhongE Shaders color channel, i.e. to assign our previously created texture to the cube.
To do so, follow these steps:
Next to the Color channel is a checkered button, hit it.
In the opening window hit File, which is the File node we are looking for.
Notice how there is a new tab in the Attribute Editor called file1 in addition there is an place2dTexture1 tab.
In the file1 tab you can browse for your texture and add it this way to the cube. If you hit 6 on your keyboard, while being in the viewport, the texture will appear.
If you are working with tileable textures the place2dTexture1 tab might become interesting. For short, in this tab you can change settings about the offset, rotation and repetition of the texture.
Before we head to the next chapter, there are some things I would like to mention:
When you got a mesh with more than one texture, which is possible by assigning the shader to single faces, do NOT work with more than three textures per mesh/object, because Source doesn’t support that.
If you are working with multiple objects in one project you can have more than three textures, e.g. when you create a lantern, you could separate the upper part from the lower and assign every piece an own texture.
So now lets go on to the next chapter, creating the physic mesh.
2.3. Creating a physics model
It is half time, we created the mesh, checked the orientation of the normals and assigned a crappy texture to the cube.
Now it is time to add a collision model to your model!
If you would skip this step and export the model as it is and place it in a map, start the game and run towards your model, you could run through it.
This so called physic model is an invisible part of the model which allows the user to interact with it e.g. to grab it, push it or destroy it.
The physic mesh itself is a real simplified, convex version of the base mesh.
For more information about the convex shape of a physic mesh take a look at this: http://en.wikipedia.org/wiki/Convex_and_concave_polygons
When you are creating a physic mesh try to keep the polygon count to a minimum because too complex physic meshes will be a real pain in the ass for Source to calculate and would decrease your performance drastically.
Another thing is that you have to assign a PhongE to the physic mesh even through it’s not visible in game.
If you wouldn’t, the physic mesh is going to be non existent in your final model. So just apply one of the PhongE you used for your base mesh.
Ok, enough boring theory lets create our physic mesh.
Create the simple cubic physic mesh:
Of course you could create a new cube and add the texture to it and use it as the physic mesh.
In our case it is more simple, just duplicate the existing cube and you will be mostly done.
To duplicate the cube just select our cube and press Ctrl+D or go to the Main Menu bar -> Edit -> Duplicate. Just like the Command Line on the bottom indicates you got a second cube.
Just one step left and your done with this chapter. Softening the edges of the collision model. This will interpolate the edges normals, which will result in a softer look. But in this case it is necessary, so source understands the mesh in the correct way, so do NOT forget this!
To soft the edges of our second cube select it, if you are not capable to select it in the viewport, open the Outliner (Main Menu bar -> Windows -> Outliner) and select the pCube2 there.
Then go to Polygons Main Menu bar -> Normals -> Soften Edge.
You will see the difference when your done.
Well this is it. We’re done with our model. The only thing left is setting up the layers for the export.
2.4 Preparing your model for export
This step is needed to tell the exporter where he can find the base mesh and the physics mesh.
Create and add to the reference layer:
To tell Pralls exporter where to find the base mesh, we are going to create a reference layer.
To do so press the little button in the lower right corner which creates an empty layer. Double click it and name it “reference” (this is important, it has to be this name), hit save.
Now add the base mesh, which should be called “pCube1” in the Outliner, to the reference layer. Select it, right click the reference layer and hit Add selected Objects, now the base mesh is part of the reference layer.
Create and add to the physics layer:
Now to tell the exporter about the physics mesh, create a new layer called “physics” and add the physic mesh to it.
Another way is, to select the physic mesh first and “Create a new layer and assign selected Objects” in one step. To do so hit the button next to the Create a new layer.
Add the correct Memberships:
Since Maya 2008 this step is necessary, don’t ask me why they did this, because I never got problems with memberships, but they did it.
Open the membership editor, to do so right click one of the layers and hit Membership.
A new window pops up called the Relationship Editor, there are two columns, the left is for the layers and the right lists all objects in your scene just like the Outliner does.
Select the physics layer in the left column and expand the pCube2 node, by clicking the +.
It should look like this:
The problem is, that the pCubeShape2 isn’t part of the physics layer, in this state the exporter wouldn’t export anything. To change this we add the Shape nodes to the corresponding layers.
Just click on the pCubeShape2 node an it will turn blue. Now the pCube2 and the pCubeShape2 nodes are seleted.
Repeat this for the reference layer, so it looks like this:
We are finally done! Now we can export our model. Took long enough to get here!
2.5. Exporting the model
Open up the SMD Export options, go Main Menu bar -> File -> Export SMD… and klick on the little square.
The settings should look for our cube like this:
The option export Animation smds is only needed when you are working with animations which is not the case now, so we’ll leave it unchecked.
Export Reference smd from Layer “reference” and export Physics smd from Layer “physics” are self explainable and important.
The 1 frame idle animation is also needed or the model wouldn’t appear ingame, it is the all time standard animation if you don’t have others.
Export Textures writes the applied textures in the smd. Generating a QC is not necessary but makes the start a little bit easier, because you don’t have to write the whole thing from scratch, more about smds later on.
Path Settings tab:
In the second tab you can edit the folders where the smds and the textures are placed. I got used to the default paths, which are shown in the next pictures. The texture Path is irrelevant cause here the exporter is a little bit damaged and only creates a .txt.
As you can see the exporter is going to create three smds and one qc file in your model_sources folder. The names of those smds explains there usage, more or less. The Tutorial_Maya_2011_to_Source.qc will include the compilation settings (more later in chapter 3), the Tutorial_Maya_2011_to_Source.smd contains the information about the base mesh and his texture. Tutorial_Maya_2011_to_Source_phy.smd contains the physic mesh and Tutorial_Maya_2011_to_Source_idle.smd the idle animation. The last file is going to be very small in this case, because there is no real animation in it, it’s just one frame.
In the third tab you can make pre adjustments to your qc file, like Keyvalues, which are about physical behaviour. Surfaceprop settings are about the behaviour when the object is shot, e.g. when wood is under fire it emits scales of wood.
Scale modifies the dimensions of the model, which is interesting to increase or decrease the size of the model in a simple way.
The physical weight of an object is described by the Mass attribute, its unit is [kg].
An important option is the Static Prop, which describes if the model is a static, i.e. it is not influenced by force like gravity or the impulse of bullets. In this case I will check it.
In the lower part of this tab you have the possibility to add custom lines to your qc file, I don’t this much because I prefer to work with ConTEXT.
In the Animations tab you can add and edit the export of animations like setting the start and end frame. But exportation of animations will be part of a later tutorial.
Check your scene if everything is correct. Check the normals orientation, the memberships of the layers and your texture paths. Also check if you can freeze some transformations or delete history. Save your work.
And now there is only one thing left. Click the damn Full Compile button!!
But beware you are not done yet. In fact Full Compile means that the exporter creates the smds and qc files but it don’t compile the whole thing. In previous Maya versions this was possible but not any more.
Okay, now Nauz will take the lead again and will explain you the basics in compilation and creation of the texture files for source.
3. Beginner: Compiling
If you’re coming from 2.5 Exporing the model, you know that Prall’s exporter fortunately already provides you with almost all files
that you will need in order to compile your model for the Source Engine.
To find the files created by the export script, head to your model sources folder in your current Maya project.
E.g. […]\Tutorial_Maya_2011_to_Source\model_sources is the path where the Cube from this tutorial has been exported to.
Besides three files with the ending .smd, which contain the mesh, animation and texture information, there’s also a .qc file.
The .qc file basically is a simple text file, that tells the Source Compiler (which is called studiomdl.exe and located in your Source SDK bin folder), what it’s supposed to do with all the .smd files and how they are related.
Prall’s exporter writes every neccessary command into it, as long as you put a check mark in the export option window.
E.g. if you checked “export Textures“, the .qc file will contain the command $cdmaterials models/, because our .tga was placed in […]\Tutorial_Maya_2011_to_Source\materialsrc\models\.
If this would be missing, studiomdl.exe wouldn’t know, where in relation to the model files the textures are placed.
But assuming you followed this tutorial, your .qc file contains every information we need, no need for further modifying.
Since it’s a simple text file, you are able to open it with any text editor.
I recommend you using ConTEXT though, a free text editor. It offers an easy way to compile and see the compiling’s console output.
(otherwise you would need to browse to your studiomdl.exe for every single model or use a batch file everytime)
3.1 Setting up ConTEXT
Where do I get it? Here:
1. After you downloaded it, you should right-click any .qc file you recently made and go to
For the “Open with…” option you should browse to “ConTEXT Programmers Editor” and click Ok.
The settings in ConTEXT
1. Make sure that you can see the “Console Output” window under you’re .qc file.
If you cannot see it, go to the View-tab and make sure, that “Console Output” is activated.
2. Now go the Options-> Environment Options.
Click the Execute Keys tab.
Click Add below the white box.
You should be requested to enter extensions now. Type qc and click Ok.
You’re window should look like this now:
3. Move on by left-clicking on F9.
Following settings are required:
Execute: Paste you’re path to the studiomdl.exe in there.
For me compiling for episode 1 it is
And turn on the Capture console output and Scroll console to the last line options.
You’re final setting should look like this
Before you can compile your model, Steam MUST be running.
Also open your Source SDK and make sure you have set it to the game you wish to compile for.
In our example I will choose Half-Life 2, but it will work for every other game aswell.
Now just open the .qc file Tutorial_Maya_2011_to_Source.qc with ConTEXT and press F9.
In the console you can see your model compile log. Notice the files created in your choosen game’s model folder.
Now you might want to check if it worked for you! Open your Model Viewer and open the tutorial_maya_2011_to_source.mdl, you are likely to see this beautiful purple-black checkered cube.
Time to set up the texture, the final step!
3.3. Create a .vtf texture
Well, at the moment you only have a .tga texture in your Maya project. Source only accepts images in the .vtf (valve texture file) format though, which you will have to place in your game or mod folder.
There are several ways to convert a texture into the .vtf format, i personally like the Photoshop .vtf plugin the most, which you can find here:
Since we placed the .tga texture in 2.2 Assigning of materials in the […]\Tutorial_Maya_2011_to_Source\materialsrc\models\ folder,
we now have to place the .vtf texture into […]\materials\models\.
In my case the exact path is D:\Program Files\Steam\steamapps\your-steam-account\half-life 2\hl2\materials\models\.
3.4. Create a .vmt texture
Now Source wants some information how to use the .vtf texture file.
This is again done by a simple text file, this time with the extension .vmt (Valve material text).
So go ahead, create a text document next to your .vtf file and give it the name of your .tga texture + the extension .vmt, make sure its type is not a Text Document as seen below, but instead it should say VMT File.
Open the .vmt file, for example with ConTEXT, and paste in this
VertexLitGeneric is the Shader Class you must use for your models, make sure every .vmt file that descirbes a model textur begins like this.
Furthermore we tell which textur to apply to the model with the $baseTexture command, of course there are many more commands, but this will do for your “first time”.
The path after “$baseTexture” could link to any texture of your choice, it doesn’t have to be named the same as your initial .tga texture, only the .vmt name has to be identical to the .tga name.
Again, launch the Model Viewer or press Refresh to see if you mastered the .vmt and .vtf creation successfully:
Congratulation, obviously we did!
Now that was simple, wasn’t it?