DigitalEro Offline

How to get Stereo faceflexes working in SFM

Sun, 26 Jan 2014 21:14:42

Biwinning

I'm writing this tutorial because I'm noticing that some of the great modellers here aren't using the stereoslider for faceflexes, and there are a few people who basically tell them "you should be better and use it" and aren't in anyway contributing to help with how to figure it out. So I got stereoflexes working for the first time on my Cortana model thanks to some tips by Pipedude so I am by no means a pro, I am just sharing what worked for me if others want to try it out for themselves. I use blender just because it was free download and I got used to it. I will try to accommodate 3dsmax users. This tutorial will focus on making stereo flexes work in SFM, but not how to make flexes in general you will have to google that. Stereoflexes make use of this slider circled in red… ….to determine if you want to manipulate both sides of the face (middle) or just one side of the face (left or right). The best part about the stereoflexes is that they clean up the long-ass list of flexes when you get detailed and call them things like right_lower_northsouth_nostril_inhalation_grower (it effectively halves the list by removing the need for separate right and left flexes). They also make it faster to do common expressions like raise both eyebrows at once. So lets get into it. 1) Modelling for use as stereoflexes: In your 3d modelling software, when you create your faceflexes, apply your transformations to both sides of the face for each one. So instead of making two separate flexes like “r_smile” and “l_smile” just make the one flex “smile” that incorporates the whole mouth. Or as shown below both eyebrows being raised at once. In blender this can be achieved very easily under mesh options with the x-mirror option turned on (which copies changes on one half of the symmetrical object to the other) and if the face isn’t fully symmetrical but close Topology mirror will do the same thing to vertexes that are approximately mirrors. In 3ds max there is probably a similar tool, but a mirror modifier would certainly do the trick if everything about the face is supposed to be symmetrical. Worst case scenario if none of the symmetry options work you can attempt to eyeball “symmetry” by hand. Long story short, planning to do stereoflexes should be less work because you will have half the flexes which I find compiles faster and is shorter to write a qc for. You still have to do all the same manipulations but if a symmetry operator can help you out, you will be away to the races. 2) Exporting SMD/VTA and establishing flexpairs in qc. Now you have you fancy expressions that don’t give you the ability to have your model happy on one side and sad on the other, because each flex will do a symmetrical transformation. Next you export the SMD and VTA files using whatever export script you got to go with your 3D modelling software (I assume 3ds Max puts out the same style smd and vta files as blender—correct me if I’m wrong). So now when we start to create the qc file, we will use flexpairs instead of normal flexes. If used properly, flexpairs will be able to split our current “both side” flexes into right and left flexes that can be handled with the stereo slider in SFM. The syntax for flex pairs occurs in the flexfile of the VTA within the models SMD and is as such: flexpair “[insert flexname from 3d software]” 1.0 frame [X] You must do this for all of your flexes from the 3d modelling software. If you open up the VTA file that your modelling software spit out beside your qc, it should be easy to see which flexpair should be assigned to what frame. Here is an example of my qc (on the left) beside the VTA exported by blender (on the right): [spoiler:3tc74u16] Note that the times directly correspond with the frames.[/spoiler:3tc74u16] 3) Adding flexcontrollers for the established flexpairs. Flexcontrollers follow directly after the last part, outside the flexfile but still within the $model command for the smd. Here is the syntax: flexcontroller [name for set of expressions] Right_[flexname] Left_[flexname] "range" 0.000 1.000 Where the set of expressions can be whatever, I believe, but I usually just stick with phoneme. When you add the Right_ and Left_ syntax to the flex names, you are now adding distinction for source to split the full flexes you provided into Left and Right flexes. I believe it very strict on the syntax so don’t go changing anything outside of the square brackets (well maybe the ranges if you want). The Right_flexname must precede the Left_flexname or things get messed up. Here is an example of my flex controllers which are directly following the close bracket (end of flexfile) from the last example: [spoiler:3tc74u16]flexcontroller phoneme Right_head_jaw Left_head_jaw "range" 0.000 1.000 flexcontroller phoneme Right_upper_lip_up Left_upper_lip_up "range" 0.000 1.000 flexcontroller phoneme Right_upper_lip_down Left_upper_lip_down "range" 0.000 1.000 flexcontroller phoneme Right_lower_lip_up Left_lower_lip_up "range" 0.000 1.000 flexcontroller phoneme Right_lower_lip_down Left_lower_lip_down "range" 0.000 1.000 flexcontroller phoneme Right_pucker Left_pucker "range" 0.000 1.000 flexcontroller phoneme Right_widen Left_widen "range" 0.000 1.000[/spoiler:3tc74u16] 4) Defining the flexes. This is the part where we take the flexcontroller names and give them proper names for the stereoslider (I’m assuming). This takes place in the same area of code as the flexcontrollers but just right after. We want to go from Right_[flexname] to [flexname]R for this process. Thus the syntax should like like this: %[flexname]R = Right_[flexname] %[flexname]L = Left_[flexname] Once again I believe the syntax is very strict because the R and L must directly follow the flex name for the stereo flexes to work properly. I don’t think order matters, but it is always nice to be organized. Here is my example of defining flexes directly after the last flexcontroller: [spoiler:3tc74u16]%head_jawR = Right_head_jaw %head_jawL = Left_head_jaw %upper_lip_upR = Right_upper_lip_up %upper_lip_upL = Left_upper_lip_up %upper_lip_downR = Right_upper_lip_down %upper_lip_downL = Left_upper_lip_down %lower_lip_upR = Right_lower_lip_up %lower_lip_upL = Left_lower_lip_up %lower_lip_downR = Right_lower_lip_down %lower_lip_downL = Left_lower_lip_down %puckerR = Right_pucker %puckerL = Left_pucker %widenR = Right_widen %widenL = Left_widen } //ending the SMD code for that model[/spoiler:3tc74u16] Doing a quick count of all my lines, I started with 7 flexpairs and so I have 7 lines for flexcontrollers and 14 lines for defining the flexes. I think that should be all. When writing your code like this with flexpairs, SFM takes the qc and the two-sided faceflexes and goes beep boop beep boop and chops them in half, down the middle creating L and R. I assume your origin marker for your model in the 3d modelling software has to be well centered for this to process properly. Now if everything else is correct with your models qc then your new STEREO FACEFLEXES should also work. If you want to see all the qc examples shown as one, here it is: [spoiler:3tc74u16]$model "body" "body.smd" { flexfile "body.vta" { defaultflex frame 0 flexpair "head_jaw" 1.0 frame 1 flexpair "upper_lip_up" 1.0 frame 2 flexpair "upper_lip_down" 1.0 frame 3 flexpair "lower_lip_up" 1.0 frame 4 flexpair "lower_lip_down" 1.0 frame 5 flexpair "pucker" 1.0 frame 6 flexpair "widen" 1.0 frame 7 } //end of flexfile flexcontroller phoneme Right_head_jaw Left_head_jaw "range" 0.000 1.000 flexcontroller phoneme Right_upper_lip_up Left_upper_lip_up "range" 0.000 1.000 flexcontroller phoneme Right_upper_lip_down Left_upper_lip_down "range" 0.000 1.000 flexcontroller phoneme Right_lower_lip_up Left_lower_lip_up "range" 0.000 1.000 flexcontroller phoneme Right_lower_lip_down Left_lower_lip_down "range" 0.000 1.000 flexcontroller phoneme Right_pucker Left_pucker "range" 0.000 1.000 flexcontroller phoneme Right_widen Left_widen "range" 0.000 1.000 %head_jawR = Right_head_jaw %head_jawL = Left_head_jaw %upper_lip_upR = Right_upper_lip_up %upper_lip_upL = Left_upper_lip_up %upper_lip_downR = Right_upper_lip_down %upper_lip_downL = Left_upper_lip_down %lower_lip_upR = Right_lower_lip_up %lower_lip_upL = Left_lower_lip_up %lower_lip_downR = Right_lower_lip_down %lower_lip_downL = Left_lower_lip_down %puckerR = Right_pucker %puckerL = Left_pucker %widenR = Right_widen %widenL = Left_widen } //ending the SMD code for that model[/spoiler:3tc74u16] Reply if there are any questions, ambiguities, or if what I’m saying is complete bullshit. Once again, I’m not a pro.
Mon, 27 Jan 2014 07:52:25

Vitezislav

Very nice tutorial and this will save some time :)
Sat, 03 May 2014 05:25:30

Kokurokoki

Would this also apply to GMod???