MayaValveExportTextures

From DigitalBlacksmith

Jump to: navigation, search

Contents

[edit] Maya 8.0 to Valve Texture Workflow

This tutorial covers a general workflow for genertaing models in Maya 8.0, texturing these models with UVs and PSD networks, then exporting the models to Valve Source with the Prall exporter.

[edit] Tutorial

[edit] Setting up the Exporter

1. Grabbed the zip file hl2export2.5.zip by Prall. Link

2. Copied the contents of the zip file to my Maya User Profile directory:

C:\Documents and Settings\windows_login_name\My Documents\maya\8.0

Note: Because I already had a scripts and prefs directory, I manually dragged and dropped the files from the zip file to the currently existing directories. Also, if there were file conflicts between the Prall tool and the Valve bundled tool, I overwrote them.

Note: The scripts in the user profile directory are automatically loaded at startup. I don't recommend trying to alter the contents of Maya's program scripts directory.

3. If all goes well, when you open Maya, and look at the File menu you should see some new options:

  • Export SMD...
  • Export VTA
  • Import SMD..
  • Import SMD Animation
  • Import from hammer
  • Compile QC

You will also see a new shelf called HL2Export, that has 4 icons - Export, ADD, NEW, Layer:

The shelf added by the Prall Maya scripts - Click to zoom
The shelf added by the Prall Maya scripts - Click to zoom




[edit] Setting up the Valve Directories and Maya Project

First, some background...

My MOD title: ARMAR

My MOD directory, herein abbrevieated as <MODDIR> was created using the Valve Source SDK Create Mod Tool, and is located here:

C:\Steam\steamapps\SourceMods\ARMAR

1. Create the following directory structure in your MOD tree:

Note: As a minimum, ensure you have the following directories..If you have more that's OK...

<MODDIR>
   materialsrc\   
   materialsrc\mayatextbox\
   

   modelsrc\
   modelsrc\mayatextbox\

   materials\
   
   models\

Notes:

  • Here we created, or ensured the creation of 4 'level 1' directories
    • materialsrc
    • modelsrc
    • materials
    • models.
  • We also created a mayabox subdirectory in modelsrc.
    • mayabox is just a name for my model.
  • The other subdirectories - modelsrc, materials, models can all be empty, or contain other files..

2. Open up Maya and create a new scene

3. Click on File, Project, Set'

4. Navigate to the mayatextbox sub directory in the MOD:

C:\Steam\steamapps\SourceMods\ARMAR\modelsrc\mayatextbox

5. Click OK

[edit] Creating Test Meshes and Materials

We will now create some test geometry to texture and export..

1. Create a Polygon cube in Maya:

  • Create Menu, Polygon Primitives, Cube

2. Create a Polygon Cylinder:

  • Create Menu, Polygon Primitives, Cylinder

3. Use the move tool to move the cylinder on top of the cube.

4. Hit the 5 key to shade the two meshes..They should be some default color

Two Basic Meshes with Default Shading
Two Basic Meshes with Default Shading

5. Right click on the cube. Mouse down to the Assign new material...' menu, then select Phong. (not Phong E)

6. The shader panel should come up on the right. Don't assign anything now. Note the name of the Material (i.e. Phong2)

7. Right click on the cylinder. Mouse down to the Assign new material...' menu, then select Phong. (not Phong E)

8. The shader panel should come up on the right. Don't assign anything now. Note the name of the Material (i.e. Phong3)

[edit] Creating the UV Sets

Sometimes, Maya will automatically assign a UV Map to a mesh, and sometimes not. It depends on how Maya is set up. Therefore we will check to ensure we have UV sets on each Mesh.

1. Object select the cube.

2. Click the Edit UV (Top Menu Bar)->UV Texture Editor

  • If you don't see the Edit UV Menu, ensure that you are in Polygons Mode

3. This should bring up the UV Texture Editor:

The UV Texture Editor with the Cube UVs
The UV Texture Editor with the Cube UVs

At this point you should see the UV's of the cube with the background color of the Phong shader. However, sometimes the UV maps need to be established, and these also have to be linked to the Matrial Shader. Therefore, we are going to create a new set of UV's, just to be sure we can always do it instead of relying on defaults


4. Leave the UV Texture Editor open.

5. Go back and select the cube in perspective mode.

6. Go to the Create UV's Menu->Automatic Mapping (note: you can select any type of mapping here and it will work)

7. Go back to the UV Texture Editor. Using the UV Sets Menu, cycle through the various sets until you see the UV templates (boxes) in the UV Texture Editor window:

Selecting the new UV set in the UV Texture
Selecting the new UV set in the UV Texture

Once you see the UV set, note the name of the UV set (mine is uvSet11). UV sets are powerful but can cause confusion.

Repeat steps 1-7 for the cylinder

[edit] Creating the PSD networks

1. In the texture editor, with the UV Set we just created selected, and with the UVs of the cube shown in the window, select Image->Create PSD Networks.

2. In the Image Name box, navigate to the following folder:

C:\Steam\steamapps\SourceMods\ARMAR\materialsrc

NOTE: It is very important that you create a PSD here, otherwise the Prall exporter won't find the file we create later

3. Then type a new name for the psd - e.g. box.psd and hit set

4. With the Create PSD Network Dialog still open, under UV Settings, change the color value of the UV Settings to something like red (I find white doesn't export well)

5. Under UV Settings, change the UV Set to the one we just created (uvSet11)

6. Check Anti-alias Lines

7. In the Attrubutes Selection section, you will see the atributes for the shader we created for our cube (phong2). Highlight the color atribute and move it over to the right so that it is in the Selected Attributes box.

When everything is set, you should have something that looks like this:


Creating a PSD Network for the cube
Creating a PSD Network for the cube

8. Hit create to create the PSD Network.

Repeat steps 1-8 for the cylinder

[edit] Testing and Configuring the PSD networks

1. Open up the psd we assigned for the cube's psd network - e.g. box.psd

2. In photoshop (or GIMP) select the Layer 1 layer. Draw a test pattern on Layer 1. When you draw in the area of a specific UV face this indicates what you want to show on that face:

Drawing and editing on our PSD Network for the cube
Drawing and editing on our PSD Network for the cube

3. Save the file in Photoshop.

4. Go back into Maya. Select the cube. Open the UV Texture editor.

5. Make sure the UV set we created earlier (e.g. uvSet11) is selected.

6. Under the Image menu in the UV Texture Editor, select Update PSD Netwroks.

7. In the perspective mode of Maya, Hit 6 to hardware shade the model. Notice, the model shows our photoshop edits, but the UV Mapping is not correct (the edits show on each face instead of showing on the faces defined in the UVMap:

PSD edits with wrong UV mapping
PSD edits with wrong UV mapping

What we need to do here is link the uvSet to the material.

8. Ensure the cube is selected.

9. In Maya, go to Window Menu (top)->Relationship Editors->UV Linking->UV Centric

This brings up the editor where you assign uvsets to shaders (textures). This tells Maya what texture (file) you want to use for each UV Set. The left side shows all the UV sets, the right side shows the texture files. You will notice that on the right side, you will see our shader for the cube (phong2), and the color attribute for the shader.

10. To assign the new uvset (uvSet11) to the shader file, click select the uvSet we created on the left (uvSet11) then click select the PSD color file.

Assigning UV Sets to Textures
Assigning UV Sets to Textures

You will now notice in both the Perspective view and the UV texture editor that we can see our edits are correctly aligned:

Repeat steps 1-10 for the cylinder


[edit] Exporting the Models to Valve

Before we can export the textures, they need to be converted to TGA's, and we need to assign the Phong shader file to read this new TGA.

1. In photoshop, save out each psd as a tga. Use the same file name with different extension.

2. Select the mesh in perspective mode.

3. Using the channel box, find the color attribute for the Phong shader. This is a tab that shows the texture sample, and file attributes fro the texture assigned to the phong.

4. Under File Attributes, change the Image Name file of each phong shader to read the tga instead of the psd.

Changing the Image File from the psd to the tga
Changing the Image File from the psd to the tga

5. Once this is done, please follow this tutorial for exporting the meshes to Valve SMDs (pick up the tutorial at the Setting up the Export Layers.... section).

[edit] Summary

In summary here is the basic workflow:

1. Create the meshes for the model

2. Assign separate Phong materials to each mesh

3. Create new UV sets for each mesh

4. With the UV Editor, select each mesh and create a PSD network file for each. Pay attention to file size and uv sets

5. Using the UV Linking Relationship Editor, assign the appropriate UV Set to each Phong shader

6. Edit the PSDs to assign and tweak the textures.

7. Use the Update PSD textures and the 6 key to see your Photoshop updates in Maya.

8. Once you are done texturing, save each PSD as a TGA with the same name.

9. Using the channle box for the phong texture, rename the image file to map to the tga instead of the psd.

10. Follow this tutorial for exporting the meshes to Valve SMDs (pick up the tutorial at the Setting up the Export Layers.... section).

Personal tools