diff --git a/interface/resources/shaders/face.vert b/interface/resources/shaders/face.vert index 704bf77961..358a8902fe 100644 --- a/interface/resources/shaders/face.vert +++ b/interface/resources/shaders/face.vert @@ -17,6 +17,9 @@ uniform vec2 texCoordRight; // the texture coordinate vector from bottom to the top uniform vec2 texCoordUp; +// the aspect ratio of the image +uniform float aspectRatio; + // the depth texture uniform sampler2D depthTexture; @@ -29,5 +32,5 @@ void main(void) { const float MAX_VISIBLE_DEPTH = 254.0 / 255.0; gl_FrontColor = vec4(1.0, 1.0, 1.0, step(MIN_VISIBLE_DEPTH, depth) * (1.0 - step(MAX_VISIBLE_DEPTH, depth))); gl_Position = gl_ModelViewProjectionMatrix * vec4(0.5 - gl_Vertex.x, - (gl_Vertex.y - 0.5) * length(texCoordUp) / length(texCoordRight), depth * 2.0 - 2.0, 1.0); + (gl_Vertex.y - 0.5) / aspectRatio, depth * 2.0 - 2.0, 1.0); } diff --git a/interface/src/avatar/Face.cpp b/interface/src/avatar/Face.cpp index c34edae3f4..d8a8d6c2a6 100644 --- a/interface/src/avatar/Face.cpp +++ b/interface/src/avatar/Face.cpp @@ -25,6 +25,7 @@ ProgramObject* Face::_program = 0; int Face::_texCoordCornerLocation; int Face::_texCoordRightLocation; int Face::_texCoordUpLocation; +int Face::_aspectRatioLocation; GLuint Face::_vboID; GLuint Face::_iboID; @@ -205,6 +206,7 @@ bool Face::render(float alpha) { _texCoordCornerLocation = _program->uniformLocation("texCoordCorner"); _texCoordRightLocation = _program->uniformLocation("texCoordRight"); _texCoordUpLocation = _program->uniformLocation("texCoordUp"); + _aspectRatioLocation = _program->uniformLocation("aspectRatio"); glGenBuffers(1, &_vboID); glBindBuffer(GL_ARRAY_BUFFER, _vboID); @@ -253,6 +255,7 @@ bool Face::render(float alpha) { (points[3].x - points[0].x) / _textureSize.width, (points[3].y - points[0].y) / _textureSize.height); _program->setUniformValue(_texCoordUpLocation, (points[1].x - points[0].x) / _textureSize.width, (points[1].y - points[0].y) / _textureSize.height); + _program->setUniformValue(_aspectRatioLocation, _aspectRatio); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, 0); diff --git a/interface/src/avatar/Face.h b/interface/src/avatar/Face.h index 03d127e994..1f9d41a1b3 100644 --- a/interface/src/avatar/Face.h +++ b/interface/src/avatar/Face.h @@ -67,6 +67,7 @@ private: static int _texCoordCornerLocation; static int _texCoordRightLocation; static int _texCoordUpLocation; + static int _aspectRatioLocation; static GLuint _vboID; static GLuint _iboID; };