@@ -40,30 +40,52 @@ public void UpdateVRCFTEyeData(ref UnifiedEyeData eyeData, ref UnifiedExpression
4040
4141 private void HandleEyeOpenness ( ref UnifiedEyeData eyeData , ref UnifiedExpressionShape [ ] eyeShapes )
4242 {
43- // we should widen the eye
44- if ( _parameterValues [ "RightEyeLidExpandedSqueeze" ] > 0.8f )
43+ // so how it works, currently we cannot output values above 1.0 and below 0.0
44+ // which means, we cannot really output whether someone's squeezing their eyes
45+ // or making a surprised face. Therefore, we kinda have to cheat.
46+ // If detect that the values provided by ETVR are below or above a certain threshold
47+ // we fake the squeeze and widen
48+
49+ // todo, make this configurable via OSC commands I guess, or we switch to sockets
50+ float squeezeThreshold = 0.1f ;
51+ float widenThreshold = 0.95f ;
52+
53+ float baseRightEyeOpenness = _parameterValues [ "RightEyeLidExpandedSqueeze" ] ;
54+ float baseLeftEyeOpenness = _parameterValues [ "LeftEyeLidExpandedSqueeze" ] ;
55+
56+ float rightYyeOpenness = Math . Clamp ( baseRightEyeOpenness , squeezeThreshold , widenThreshold ) ;
57+ float leftYyeOpenness = Math . Clamp ( baseLeftEyeOpenness , squeezeThreshold , widenThreshold ) ;
58+
59+
60+ eyeData . Right . Openness = rightYyeOpenness ;
61+ eyeData . Left . Openness = leftYyeOpenness ;
62+
63+ if ( baseRightEyeOpenness >= widenThreshold )
4564 {
46- eyeData . Right . Openness = _parameterValues [ "RightEyeLidExpandedSqueeze" ] ;
65+ // todo, figure out how to make this more responsive
66+ // todo, maybe use a curve to determine the wideness factor based
67+ // todo, based on the difference between the base openness and clamped?
4768 eyeShapes [ ( int ) UnifiedExpressions . EyeWideRight ] . Weight = 1 ;
69+ eyeShapes [ ( int ) UnifiedExpressions . EyeSquintRight ] . Weight = 0 ;
4870 }
49- if ( _parameterValues [ "RightEyeLidExpandedSqueeze" ] < 0.0f )
71+
72+ if ( baseLeftEyeOpenness >= widenThreshold )
5073 {
51- eyeData . Right . Openness = _parameterValues [ "RightEyeLidExpandedSqueeze" ] ;
52- eyeShapes [ ( int ) UnifiedExpressions . EyeSquintRight ] . Weight = - 1 ;
74+ eyeShapes [ ( int ) UnifiedExpressions . EyeWideLeft ] . Weight = 1 ;
75+ eyeShapes [ ( int ) UnifiedExpressions . EyeSquintLeft ] . Weight = 0 ;
5376 }
54- eyeData . Left . Openness = _parameterValues [ "RightEyeLidExpandedSqueeze" ] ;
55-
56- if ( _parameterValues [ "LeftEyeLidExpandedSqueeze" ] > 0.8f )
77+
78+ if ( baseLeftEyeOpenness <= squeezeThreshold )
5779 {
58- eyeData . Left . Openness = _parameterValues [ "LeftEyeLidExpandedSqueeze" ] ;
59- eyeShapes [ ( int ) UnifiedExpressions . EyeWideLeft ] . Weight = 1 ;
80+ eyeShapes [ ( int ) UnifiedExpressions . EyeWideLeft ] . Weight = 0 ;
81+ eyeShapes [ ( int ) UnifiedExpressions . EyeSquintLeft ] . Weight = 1 ;
6082 }
61- if ( _parameterValues [ "LeftEyeLidExpandedSqueeze" ] < 0.0f )
83+
84+ if ( baseRightEyeOpenness <= squeezeThreshold )
6285 {
63- eyeData . Left . Openness = _parameterValues [ "LeftEyeLidExpandedSqueeze" ] ;
64- eyeShapes [ ( int ) UnifiedExpressions . EyeSquintLeft ] . Weight = - 1 ;
86+ eyeShapes [ ( int ) UnifiedExpressions . EyeWideRight ] . Weight = 0 ;
87+ eyeShapes [ ( int ) UnifiedExpressions . EyeSquintRight ] . Weight = 1 ;
6588 }
66- eyeData . Left . Openness = _parameterValues [ "LeftEyeLidExpandedSqueeze" ] ;
6789 }
6890
6991 private void HandleEyeGaze ( ref UnifiedEyeData eyeData )
0 commit comments