Request: Instance Switch layers

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Breinmeester
Posts: 303
Joined: Thu May 13, 2010 2:01 pm

Request: Instance Switch layers

Post by Breinmeester »

Hello wonderful scripters of the Moho forum!

I'm currently creating a workflow where facial expressions and lipsync are controlled independently from the orientation of the head (headturn phases), so either can be altered at any given time.

But I have been hitting the same wall any way I cut it: different parts that make up the mouthshape need to be seperated onto different layers. Since it is an integral part of the workflow that the lipsync is done by switch layers, this means I need to switch multiple layers (in my most economic, but less versatile instance: 2 layers) in order to do the lipsync.

Trying to avoid a high click count, I was wondering if it is possible to control all the different switch layers with one 'mother' switch layer, much like Fazek's mesh-instance duplicates.

Simply put: Is it possible to write a script that changes the switch on linked switch layers (to the layer with the same name) when the switch on a 'mother' switch layer is switched?
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

just use actions - if you group everything under a master group (bone or group layer) and create actions when that master layer is selected, all sub layers will have the action created. Then just make all your switch options as separate actions and you can recall them at any time...
Breinmeester
Posts: 303
Joined: Thu May 13, 2010 2:01 pm

Post by Breinmeester »

I know actions is a solution, but it's not the most preferable one. Switch layers are intuitive and fast and easy to use, which makes it good for pre-rendering and adjusting.
If such a script would be impossible, actions are the way to go. But I'm also using actions in some other parts of the workflow and it will look conveluted to my animators and probaply be slower than Switch layers.
Thanks anyway for thinking along, Funksmaname!

Any scripter willing to take this on or steer my in the right direction?
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

not sure how you would instruct a set of changes to a single switch on a 'mother' switch layer? how could you tell it what needs switching?

if you always need the same combination of switches together (3/4 head, 3/4 mouth) without ever needing one without the other (3/4 mouth on a front head) then why are they spread across multiple switch layers? you could group the switch layers under a switch layer, and just select the 'set' you want... is that what you need? you can nest switch layers inside eachother...

heads (switch)

- front (group)
--mouth (switch)
--eyes (switch)

- 3/4 (group)
--mouth (switch)
--eyes (switch)

then you can just switch between front and 3/4... is that what you want?
User avatar
hayasidist
Posts: 3523
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Post by hayasidist »

or put all the different layers that make up one mouth shape into a Group and then put all those groups in a switch. (switch doesn't just switch vectors - it'll switch bones, groups, other switches ..)?
Breinmeester
Posts: 303
Joined: Thu May 13, 2010 2:01 pm

Post by Breinmeester »

Hey guys!

Thanks for thinking along and coming up with alternatives, but I've been working on this for quite some time and I've tried out a lot of different things.
Deviding different parts that make up the mouth over several layers is inescapable and putting groups or switch layers inside switch layers kills the possibility of interpolating between shapes.

I either need the script or find a way to make the use of actions for lipsync easier, clearer and less time consuming. For the latter I have thought up a plan that I will be testing soon, but I still prefer the ease of use of switch layers.
not sure how you would instruct a set of changes to a single switch on a 'mother' switch layer? how could you tell it what needs switching?
The way I see it, it would work similair to Fazek's meshinstance script. The mother Switch would have a script embedded and the childeren switches as well. Through a naming convention the script knows which switch layers are children to the mother. The child Switches would switch to the layer inside with the same name whenever the mother Switch layer switches and leave a key in the timeline.
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

can you show an example of why "Deviding different parts that make up the mouth over several layers is inescapable"? I can't imagine scenario where anything is inescapable :) maybe the whole problem stems from over-complication? There may be a fundamental alternative to the way you're working which may irradicate your problem completely...

...or not - but would be good to find out!
Breinmeester
Posts: 303
Joined: Thu May 13, 2010 2:01 pm

Post by Breinmeester »

Hello,

I've found out that having Switch layer duplicates isn't the best solution to my problem as it makes the lipsync virtually uneditable, since translating keys on the timeline or deleting keys will have to be done on all switchlayers or it'll get messy really quickly. Off course Rudiger's keytool will come in handy, but still it causes for a very difficult to edit workflow. Which is unaceptable.

So I've started looking in different directions. I'v already experimented with setting the different switch layers to the right sublayer using actions and I've actually managed to create a workflow using actions that's faster than my earlier 'switch layer duplicates' idea.

But to deal with the problem of keeping the workflow easy to edit, I'm trying a similair approach as Rudiger's morphdail technique. This way the lipsync will be created with only one bone, so editing would simply mean editing the keys on that one bone. It'll be a long way to go as this technique is pretty complex for a scripting novice like me, but I'm pretty excited about the result it could lead to.

To answer your question Funksmaname: I'm doing lipsync on a head that is similair to Selgin's bitten apple head:
viewtopic.php?t=15846&start=0&postdays=0&postorder=asc
Only my head has 2 layers to make up the mouth and headshape, not 4, and there's no need for vectorlayer duplicates.

Still, I have these 2 layers that make up the shape of the mouth: the actual mouth and the shape of the head where there's a gap (the bite out of the apple) and both layers will need different shapes for the different phonemes.
Now, I could put the two layers in a group and swicth that, but I'll lose interpolation and I'll have to put all the layers for the stuff inside the mouth (teeth, tongue) in there as well. So it's better to have the different phonemes for each layer in it's own switchlayer. Hence: multiple switch layers.
User avatar
hayasidist
Posts: 3523
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Post by hayasidist »

is loss of interpolation that much of a problem? I've just taken a look at one of the automated lipsyncs and there are rarely more than 2-3 frames (at 25 fps) between phoneme changes - the main exceptions, naturally, are in "gaps" in the speech.

to mix mouth "acting" with speech - for (say) a slow change from "deadpan to smile" that could be done by animation - by a method of your choice (I've just tried one with point animation only) - within a group in the switch that is made visible when the action is needed.
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

if you've managed to simplify selgins setup it would be much appreciated if you could share your results!

The thing is with morph dials is they may not work 'live' if your character is complex - which means action will have to be baked and you're back to where you were when you were manually putting down actions... although perhaps if you had MDs only for the mouth it might work OK - you'll have to try and see. (i think exporting will still work without baking, but real time playback might not and you'll get delays when making changes to morphdials)
Breinmeester
Posts: 303
Joined: Thu May 13, 2010 2:01 pm

Post by Breinmeester »

funksmaname wrote:if you've managed to simplify selgins setup it would be much appreciated if you could share your results!
Yeah, sure! It's pretty easy actually:

Image

I've uploaded a zip-file with an example scene. It shows this technique and I've created different phonemes made up from three layers: the head shape layer, the mouth shape layer and the lower teeth. I've created a switch layer for each of those three layers and gave the sublayers corresponding names. Now you can create any of the seven phonemes by switching these three switch layers to the right sublayer.

I've animated this lipsync using the technique I'm currently develloping, but I took it out for this public example, because I'm not ready with it yet.

You can download the file here:
http://dl.dropbox.com/u/2201551/SimpleHeadRig.zip
funksmaname wrote:The thing is with morph dials is they may not work 'live' if your character is complex - which means action will have to be baked and you're back to where you were when you were manually putting down actions...
I'm now scripting a technique that's similair to Rudiger's MorphDials but a lot less complex, which I hope will make it faster. It'll also make it less versatile and less user friendly, but if whoever is rigging the characters knows how it works, it'll be good enough to work with.
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

hey thanks for that, and the file - i really like your character!
I'm still not entirely sure why you've chosen to split it all up like this though? not the build of the character, but using switch layers... You could have 3 vector layers and use actions.

Then with morph dials you can have a control bone that you move between them which effects the mouth in real time. You can also still import dat files should you need to using 'dat to switch' script or 'lipsync with morphdials' script

newer development version of MDs also supports switches so you could keep your setup the same probably, but you'd have to speak to Rudiger about getting that...
Breinmeester
Posts: 303
Joined: Thu May 13, 2010 2:01 pm

Post by Breinmeester »

The head is just something I whipped together quickly for the occasion.

I know I could also either stick the layers in group layers and switch those with only 1 switch layer or use actions (for instance controlled by MorphDials like you suggest). With group layers as sublayers to a switch layer I would lose interpolation, but you do make a good point about using actions. It's less animator friendly and clear then doing lipsync with a switch layer, but I've been working on a method using actions for lipsync that's even clearer and faster than using a switch layer.

So why don't I use actions? There is a very good reason why I approach it like this, but I can't tell you yet, as I'm still working on it. I guess you'll just have to trust me.

Thanks for thinking along though. I hope my version of the bitten apple technique is of use to you.
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

ok :)
please share your findings when you're done!

thanks for sharing this setup - selgins is more complicated mainly to get a unified outline but this way allows a natural way to include an inner mouth which is nice...

why don't you put all the teeth into the headshape switch layer? that way you're 1 less switch layer?
User avatar
hayasidist
Posts: 3523
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Post by hayasidist »

hi again.

I ran your example file twice - one with interpolation on in the switches and once with it off. this is a side-by-side comparison of the two.

http://www.mediafire.com/?b9ul4llek4jull9

I used your frame rate (12) in AS to create uncompressed AVIs; composit in premiere at 25fps with the WMV at 30fps. I think you really need to look closely to see the difference. If you can live with it (or maybe add an extra tween where necessary -- plus see my previous comment about mouth acting) this may well make life easier.


And you've got me intrugued by whatever it is you're "still working on .." :D
Post Reply