mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 16:55:07 +02:00
add velocity filtering to eyePosition to reduce camera jitter from faceshift
This commit is contained in:
parent
311e752682
commit
00fdc37822
3 changed files with 8 additions and 2 deletions
|
@ -592,7 +592,7 @@ void Application::paintGL() {
|
|||
|
||||
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
||||
_myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay
|
||||
_myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition());
|
||||
_myCamera.setTargetPosition(_myAvatar->getHead()->getFilteredEyePosition());
|
||||
_myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation());
|
||||
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||
|
|
|
@ -159,6 +159,10 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
|||
}
|
||||
}
|
||||
_eyePosition = calculateAverageEyePosition();
|
||||
|
||||
float velocityFilter = glm::clamp(1.0f - glm::length(_filteredEyePosition - _eyePosition), 0.0f, 1.0f);
|
||||
_filteredEyePosition = velocityFilter * _filteredEyePosition + (1.0f - velocityFilter) * _eyePosition;
|
||||
|
||||
}
|
||||
|
||||
void Head::relaxLean(float deltaTime) {
|
||||
|
|
|
@ -89,7 +89,7 @@ public:
|
|||
const bool getReturnToCenter() const { return _returnHeadToCenter; } // Do you want head to try to return to center (depends on interface detected)
|
||||
float getAverageLoudness() const { return _averageLoudness; }
|
||||
glm::vec3 calculateAverageEyePosition() const { return _leftEyePosition + (_rightEyePosition - _leftEyePosition ) * ONE_HALF; }
|
||||
|
||||
glm::vec3 getFilteredEyePosition() const { return _filteredEyePosition; }
|
||||
/// \return the point about which scaling occurs.
|
||||
glm::vec3 getScalePivot() const;
|
||||
|
||||
|
@ -120,6 +120,8 @@ private:
|
|||
glm::vec3 _leftEyePosition;
|
||||
glm::vec3 _rightEyePosition;
|
||||
glm::vec3 _eyePosition;
|
||||
glm::vec3 _filteredEyePosition; // velocity filtered world space eye position
|
||||
|
||||
float _scale;
|
||||
float _lastLoudness;
|
||||
float _audioAttack;
|
||||
|
|
Loading…
Reference in a new issue