Jump to content

Facial animation tutorial with lip sync (papyrus script)


trepleen

Recommended Posts

How to perform facial expression animation - Pucker Kiss
 
SceneKiss (An actual scene created in creation kit)

note: this scene plays along side a kissing animation between two npcs, the kissing animation is 13.3 seconds in length. The length of this scene is 13 seconds.
 
Action 1 (2.0 seconds)

;let's start from a fresh slate and reset expression overrides for player & katreena
refalias_katreenadarkmoore.getactorref().resetexpressionoverrides()
game.getplayer().resetexpressionoverrides()

;set expression to nuetral mood
refalias_katreenadarkmoore.getactorref().setexpressionoverride(7, 100)
game.getplayer().setexpressionoverride(7, 100)

Action 2 (2.0 seconds)

;set duration inbetween setting phoneme strength
;1 = one second
;0.5 = half a second
;0.1 = 1/10 of a second
float delay = 0.03

;slowly animate from default lip position to actual pucker, by setting a value then adding a slight delay, rinse, repeat until lips reach desired level of pucker
;the value of 3 represents the ChjSh phoneme 
refalias_katreenadarkmoore.getactorref().setexpressionphoneme(3, 0.1)
game.getplayer().setexpressionphoneme(3, 0.1)
utility.wait(delay)
refalias_katreenadarkmoore.getactorref().setexpressionphoneme(3, 0.3)
game.getplayer().setexpressionphoneme(3, 0.15)
utility.wait(delay)
refalias_katreenadarkmoore.getactorref().setexpressionphoneme(3, 0.5)
game.getplayer().setexpressionphoneme(3, 0.2)
utility.wait(delay)
refalias_katreenadarkmoore.getactorref().setexpressionphoneme(3, 0.8)
game.getplayer().setexpressionphoneme(3, 0.25)
utility.wait(delay)
refalias_katreenadarkmoore.getactorref().setexpressionphoneme(3, 1)
game.getplayer().setexpressionphoneme(3, 0.3)

;this holds the id we can use to stop the kissing sounds in the animation end event
int startkiss = slfc_soundmarker_startkiss.play(game.getplayer())

Action 3 (4.0 seconds)

;set duration inbetween setting phoneme strength
;1 = one second
;0.5 = half a second
;0.1 = 1/10 of a second
float delay = 0.03

;slowly animate from pucker to default lip position, notice how we lower the strength of the ;phoneme
;the value of 3 represents the ChjSh phoneme 
refalias_katreenadarkmoore.getactorref().setexpressionphoneme(3, 1)
game.getplayer().setexpressionphoneme(3, 0.3)
utility.wait(delay)
refalias_katreenadarkmoore.getactorref().setexpressionphoneme(3, 0.8)
game.getplayer().setexpressionphoneme(3, 0.25)
utility.wait(delay)
refalias_katreenadarkmoore.getactorref().setexpressionphoneme(3, 0.5)
game.getplayer().setexpressionphoneme(3, 0.2)
utility.wait(delay)
refalias_katreenadarkmoore.getactorref().setexpressionphoneme(3, 0.3)
game.getplayer().setexpressionphoneme(3, 0.15)
utility.wait(delay)
refalias_katreenadarkmoore.getactorref().setexpressionphoneme(3, 0)
game.getplayer().setexpressionphoneme(3, 0)

;make kiss sound
int endkiss = slfc_soundmarker_endkiss.play(game.getplayer())

Action 4 (5.0 seconds)

;let's start from a fresh slate and reset expression overrides for player & katreena
refalias_katreenadarkmoore.getactorref().resetexpressionoverrides()
game.getplayer().resetexpressionoverrides()

How to perform facial expression animation with Lip Sync
 
I'm assuming you know how to set up a scene in the creation kit. Make sure you call the following code before the actor begins speaking, this will avoid the lip, mouth bug.

;let's start from a fresh slate and reset expression overrides for player & katreena
refalias_katreenadarkmoore.getactorref().resetexpressionoverrides()
game.getplayer().resetexpressionoverrides()

;set expression to nuetral mood
refalias_katreenadarkmoore.getactorref().setexpressionoverride(7, 100)
game.getplayer().setexpressionoverride(7, 100)

Experiment with the above, if you find something more efficient let me know.

 

A value of 7, 100 sets the default facial expression to "nuetral" before the npc begins speaking.   You can also set this value to an expression that matches the same facial expression you set in your dialogue expression setting (make sure the strengths match).
 
Check this link for the various expressions, phoneme and modifiers.
 
http://git.loverslab.com/sexlab/framework/wikis/expression-functions
 
Additional, useful functions....
 
ACTOR.SETEXPRESSIONOVERRIDE
http://www.creationkit.com/SetExpressionOverride_-_Actor
 
ACTOR.CLEAREXPRESSIONOVERRIDE
http://www.creationkit.com/ClearExpressionOverride_-_Actor

Link to comment

Er was katreenadarkmoore supposed to be replaced by npc_actor in all cases above?  Right now it looks like you are working with two different actors.

 

 

Regardless, if this works to make Lip Sync and Facial Expressions work together in the Sexlab Framework then well done:

 

 

 

OlaPl.gif

 

 

 

 

Link to comment

Er was katreenadarkmoore supposed to be replaced by npc_actor in all cases above?  Right now it looks like you are working with two different actors.

 

 

Regardless, if this works to make Lip Sync and Facial Expressions work together in the Sexlab Framework then well done:

 

 

 

OlaPl.gif

 

 

 

Thanks! I made the corrections, i've been coding too long today and nice pic!

Link to comment

Reading that again, are you really saying that you need to move the facial expression to neutral before the lip sync bit starts?

 

No, you can set it to whatever expression you want.

 

I noticed that sometimes when you choose dialogue options, the npc mouth will cut off and stay open in an odd way. Setting that expression override will give it a default expression to get rid of the odd open mouth.

Link to comment

There's no real reason to use MfgConsoleFunc's functions anymore since SKSE added them a couple versions ago. SexLab doesn't include it anymore as a result.

Actor.SetExpressionPhoneme(int id, float value) ;// (SKSE) Sets phoneme id to value between 0.0 - 1.0 
Actor.SetExpressionModifier(int id, float value) ;// (SKSE) Sets modifier id to value between 0.0 - 1.0 
Actor.ResetExpressionOverrides() ;// (SKSE) Resets all 3, phoneme, modifiers, as well as expression
Actor.ClearExpressionOverride() ;// (Vanilla) only resets expression - doesn't need to be called before a new expression override, hence "override".

Important to note that the SKSE functions take a float value of 0.0 to 1.0, instead of MfgConsoleFunc's 0 to 100 integer.

Link to comment

There's no real reason to use MfgConsoleFunc's functions anymore since SKSE added them a couple versions ago. SexLab doesn't include it anymore as a result.

Actor.SetExpressionPhoneme(int id, float value) ;// (SKSE) Sets phoneme id to value between 0.0 - 1.0 
Actor.SetExpressionModifier(int id, float value) ;// (SKSE) Sets modifier id to value between 0.0 - 1.0 
Actor.ResetExpressionOverrides() ;// (SKSE) Resets all 3, phoneme, modifiers, as well as expression
Actor.ClearExpressionOverride() ;// (Vanilla) only resets expression - doesn't need to be called before a new expression override, hence "override".

Important to note that the SKSE functions take a float value of 0.0 to 1.0, instead of MfgConsoleFunc's 0 to 100 integer.

 

Ah, but does this process as detailed actually fix the jittering lips problem when both expressions and lip sync are turned on in Sexlab?

Link to comment

There's no real reason to use MfgConsoleFunc's functions anymore since SKSE added them a couple versions ago. SexLab doesn't include it anymore as a result.

Actor.SetExpressionPhoneme(int id, float value) ;// (SKSE) Sets phoneme id to value between 0.0 - 1.0 
Actor.SetExpressionModifier(int id, float value) ;// (SKSE) Sets modifier id to value between 0.0 - 1.0 
Actor.ResetExpressionOverrides() ;// (SKSE) Resets all 3, phoneme, modifiers, as well as expression
Actor.ClearExpressionOverride() ;// (Vanilla) only resets expression - doesn't need to be called before a new expression override, hence "override".

Important to note that the SKSE functions take a float value of 0.0 to 1.0, instead of MfgConsoleFunc's 0 to 100 integer.

 

Thank you very much for this info!

 

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use