User:Gammerman12/Sandbox/Authoring HWM
This is a tutorial for authoring high-end SFM heads, commonly refereed to as HWM. There's still a lot of work to be done here, but this will get a working head included as an example file in SFM into the engine with it's corrective shapes, wrinkle maps, and all.
Contents
Creating the Flexes
Creating the flexes is an interesting process. You've gotta make sure your artists won't have a pain and with HWM, it's all about giving the artists and animators control. There's not much that can be said in terms of actually creating the flexes. Rather, just try to match the many references Valve has given us. There's human references available in the Left 4 Dead 2 survivor's sources, which can be found in common/left 4 dead 2/sdk_content/Maya_Rigs_Animation/Survivors. There's also a reference of the Scout, available in the SFM, in sdktools/lua/reference_heads. For this tutorial, we'll be using the Scout reference.
Exporting the Model
If you're using Maya, you've gotta follow a couple steps to export the model correctly. With your model selected, go into the MEL script editor and enter this command
vsDmxIO -export -ufc -ac -exportType model -exportType skeletalAnimation -selection -filename "C:/Foo/Bar/parts/dmx/head_morphs.dmx"
Why do we use this command? Because of -ufc. Maya normally uses hyphens (-) in place of underscores (_), and underscores are required for DMXedit to recognize the blend shape as a corrector. -ufc means "Underscores For Correctives," which preserves underscores in the export.
Blender will preserve underscores for you, so you can skip this, open source users!
Coding for DMXedit
DMXedit requires some sort of script (.lua and apparently .py) that tells the program to run the files inside game/sdktools/lua. Under is a script used for the Medic in tf_movies, so this is a good jumping off point. For this tutorial, we will be using a modified game/sdktools/lua/reference_heads/tf_movies.dmx which has had it's correctives properly named with underscores instead of hyphens (someone at Valve, please export the scout's head with ufc!!)
You can download it here [[1]].
As for the script, this is what it looks like.
-- Removed the script here until I get approval to release it.
Some commands you should take note of are the Load and Save commands which will load your exported version and save to a version read by StudioMDL. If you are just looking to enable correctors, your dmx just needs to run through DMXEdit through only the Load and Save commands, but if you're doing something as complex as the faces, it's best to stick with Valve's scripts.
Modify this code as you need to and save in your models directory, inside a new folder next to paths called scripts, as your_model_name.lua.
If you want more on what all this does, run game/bin/dmxedit.exe with -help. It will give you a list of commands you can run in DMXedit. What this basically does is runs the .lua files in game/sdktools/lua, which will create correctors, generate wrinkle maps, and all that good stuff that makes HWM.
Fixing the Valve Scripts
Currently in the public release of SFM, there's a small discrepancy with the scripts. If you go into face_correctors, inside of game/sdktools/lua, you will find that there are some lines that mention base. However, some are not in quotations. They need to have quotations in order for the scripts to run properly. Do a quick replace of base with "base", then do another replace of ""base"" to "base"
Batch Compiling
To make the process easier, Bay showed us a nice way to compile the model and make it run through all it's needed programs after changes are made. Create a batch script in your models directory, next to the .qc, and name it compile_your_model_name.bat. Edit it so it reads:
%VGAME%/bin/dmxedit.exe -nop4 %VCONTENT%/usermod/modelsrc/hwm_tutorial/tf_scout/scripts/your_model_name.lua
pause
%VGAME%/bin/studiomdl.exe %VCONTENT%/usermod/modelsrc/hwm_tutorial/tf_scout/your_model_name.qc
pause
This basically runs the .dmx through dmxedit for ease and comfort. If you have any texture sources too, you could optionally run them all on the same file through vtex. Run the .bat file for dmx to run through all the required steps. At the end of it, you should have a model compiled and working!
Credits and TODO
There's still a ton of stuff that needs to be done for this, such as documenting left and right controllers and speedmaps, getting this to run on the Left 4 Dead 2 characters, etc. As it comes to us, we'll write documents about it. We should also document what each script does, so people creating custom characters will know what they're doing. Also, currently DMXEdit doesn't support rigging, and there's apparently a "MergeMeshAndSkeleton" command which we don't know how to use yet without losing the weight maps. Waiting on Bay/Valve for this one.
Credits go to:
Bay Raitt for the Medic Script plus general help
Narry Gewman for fixing the scripts for public use
Cra0kalo for General Help