@@ -23,7 +23,7 @@ public V1Mapper(ILogger logger)
2323 {
2424 _logger = logger ;
2525 }
26-
26+
2727 public void handleOSCMessage ( OSCMessage message )
2828 {
2929 var paramToMap = ImappingStategy . GetParamToMap ( message . address ) ;
@@ -34,7 +34,7 @@ public void handleOSCMessage(OSCMessage message)
3434 }
3535 }
3636
37- public void UpdateVRCFTEyeData ( ref UnifiedEyeData eyeData , ref UnifiedExpressionShape [ ] eyeShapes )
37+ private void UpdateVRCFTEyeData ( ref UnifiedEyeData eyeData , ref UnifiedExpressionShape [ ] eyeShapes )
3838 {
3939 HandleEyeOpenness ( ref eyeData , ref eyeShapes ) ;
4040 HandleEyeGaze ( ref eyeData ) ;
@@ -47,46 +47,50 @@ private void HandleEyeOpenness(ref UnifiedEyeData eyeData, ref UnifiedExpression
4747 // or making a surprised face. Therefore, we kinda have to cheat.
4848 // If we detect that the values provided by ETVR are below or above a certain threshold
4949 // we fake the squeeze and widen
50-
51- // todo, make this configurable via OSC commands I guess, or we switch to sockets
52- float squeezeThreshold = 0.1f ;
53- float widenThreshold = 0.95f ;
5450
55- float baseRightEyeOpenness = _parameterValues [ "RightEyeLidExpandedSqueeze" ] ;
56- float baseLeftEyeOpenness = _parameterValues [ "LeftEyeLidExpandedSqueeze" ] ;
57-
58- float rightYyeOpenness = Math . Clamp ( baseRightEyeOpenness , squeezeThreshold , widenThreshold ) ;
59- float leftYyeOpenness = Math . Clamp ( baseLeftEyeOpenness , squeezeThreshold , widenThreshold ) ;
51+ // todo for v2: make this configurable via OSC commands I guess, or we switch to sockets
52+ const float squeezeThreshold = 0.1f ;
53+ const float widenThreshold = 0.95f ;
6054
55+ var baseRightEyeOpenness = _parameterValues [ "RightEyeLidExpandedSqueeze" ] ;
56+ var baseLeftEyeOpenness = _parameterValues [ "LeftEyeLidExpandedSqueeze" ] ;
6157
62- eyeData . Right . Openness = rightYyeOpenness ;
63- eyeData . Left . Openness = leftYyeOpenness ;
58+ _handleSingleEYeOpenness ( ref eyeData . Right , ref eyeShapes , UnifiedExpressions . EyeWideRight ,
59+ UnifiedExpressions . EyeSquintRight , baseRightEyeOpenness , widenThreshold , squeezeThreshold ) ;
6460
65- if ( baseRightEyeOpenness >= widenThreshold )
66- {
67- // todo, figure out how to make this more responsive
68- // todo, maybe use a curve to determine the wideness factor based
69- // todo, based on the difference between the base openness and clamped?
70- eyeShapes [ ( int ) UnifiedExpressions . EyeWideRight ] . Weight = 1 ;
71- eyeShapes [ ( int ) UnifiedExpressions . EyeSquintRight ] . Weight = 0 ;
72- }
61+ _handleSingleEYeOpenness ( ref eyeData . Left , ref eyeShapes , UnifiedExpressions . EyeWideLeft ,
62+ UnifiedExpressions . EyeSquintLeft , baseLeftEyeOpenness , widenThreshold , squeezeThreshold ) ;
63+ }
7364
74- if ( baseLeftEyeOpenness >= widenThreshold )
65+ private void _handleSingleEYeOpenness (
66+ ref UnifiedSingleEyeData eye ,
67+ ref UnifiedExpressionShape [ ] eyeShapes ,
68+ UnifiedExpressions widenParam ,
69+ UnifiedExpressions squintParam ,
70+ float baseEyeOpenness ,
71+ float widenThreshold ,
72+ float squeezeThreshold
73+ )
74+ {
75+ eye . Openness = baseEyeOpenness ;
76+ if ( baseEyeOpenness >= widenThreshold )
7577 {
76- eyeShapes [ ( int ) UnifiedExpressions . EyeWideLeft ] . Weight = 1 ;
77- eyeShapes [ ( int ) UnifiedExpressions . EyeSquintLeft ] . Weight = 0 ;
78+ eyeShapes [ ( int ) widenParam ] . Weight = Utils . SmoothStep (
79+ widenThreshold ,
80+ 1 ,
81+ baseEyeOpenness
82+ ) ;
83+ eyeShapes [ ( int ) squintParam ] . Weight = 0 ;
7884 }
7985
80- if ( baseLeftEyeOpenness <= squeezeThreshold )
81- {
82- eyeShapes [ ( int ) UnifiedExpressions . EyeWideLeft ] . Weight = 0 ;
83- eyeShapes [ ( int ) UnifiedExpressions . EyeSquintLeft ] . Weight = 1 ;
84- }
85-
86- if ( baseRightEyeOpenness <= squeezeThreshold )
86+ if ( baseEyeOpenness <= squeezeThreshold )
8787 {
88- eyeShapes [ ( int ) UnifiedExpressions . EyeWideRight ] . Weight = 0 ;
89- eyeShapes [ ( int ) UnifiedExpressions . EyeSquintRight ] . Weight = 1 ;
88+ eyeShapes [ ( int ) widenParam ] . Weight = 0 ;
89+ eyeShapes [ ( int ) squintParam ] . Weight = Utils . SmoothStep (
90+ squeezeThreshold ,
91+ 0 ,
92+ baseEyeOpenness
93+ ) ;
9094 }
9195 }
9296
0 commit comments