mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-14 06:46:39 +02:00
Pass the aspect ratio into the shader, since it no longer necessarily
corresponds to the texture rectangle's aspect ratio.
This commit is contained in:
parent
0ae6887c4a
commit
ff0d63173c
3 changed files with 8 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ private:
|
|||
static int _texCoordCornerLocation;
|
||||
static int _texCoordRightLocation;
|
||||
static int _texCoordUpLocation;
|
||||
static int _aspectRatioLocation;
|
||||
static GLuint _vboID;
|
||||
static GLuint _iboID;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue