From ffedcbfc35a8ecb93e47d69cdf329a18b12ea949 Mon Sep 17 00:00:00 2001 From: Peter Schaefer Date: Sun, 26 Apr 2015 16:38:37 +0200 Subject: [PATCH] fixed useless inversion of projection per Vertex --- Weave/Graphix/Shader.cpp | 8 ++++---- Weave/Graphix/ViewPort.cpp | 4 ++++ shader/skybox_VS.hlsl | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Weave/Graphix/Shader.cpp b/Weave/Graphix/Shader.cpp index d8a5723..b084561 100644 --- a/Weave/Graphix/Shader.cpp +++ b/Weave/Graphix/Shader.cpp @@ -33,8 +33,8 @@ void Shader::useShader() const int Shader::getAttribLocation(const string& name) const { int ind = glGetAttribLocation(handle, name.c_str()); - if (ind < 0) - Message::info("GL_GetAttLoc: Kann '" + name + "' nicht finden."); + //if (ind < 0) + // Message::info("GL_GetAttLoc: Kann '" + name + "' nicht finden."); return ind; } @@ -42,8 +42,8 @@ int Shader::getAttribLocation(const string& name) const int Shader::getUniformLocation(const string& name) const { int ind = glGetUniformLocation(handle, name.c_str()); - if (ind < 0) - Message::info("GL_GetUniLoc: Kann '" + name + "' nicht finden."); + //if (ind < 0) + // Message::info("GL_GetUniLoc: Kann '" + name + "' nicht finden."); return ind; } diff --git a/Weave/Graphix/ViewPort.cpp b/Weave/Graphix/ViewPort.cpp index d8d1e1e..487cc45 100644 --- a/Weave/Graphix/ViewPort.cpp +++ b/Weave/Graphix/ViewPort.cpp @@ -46,6 +46,10 @@ void ViewPort::bindView(Shader* shader, vec3 pos) const{ tmp = shader->getUniformLocation("uProjection"); if (tmp>=0) glUniformMatrix4fv(tmp, 1, false, value_ptr(projection)); + tmp = shader->getUniformLocation("uInvProjection"); + if (tmp >= 0) + glUniformMatrix4fv(tmp, 1, false, value_ptr(glm::inverse(projection))); + tmp = shader->getUniformLocation("uView"); if (tmp >= 0) glUniformMatrix4fv(tmp, 1, false, value_ptr(translate(view,-pos))); diff --git a/shader/skybox_VS.hlsl b/shader/skybox_VS.hlsl index a64443d..2b85546 100644 --- a/shader/skybox_VS.hlsl +++ b/shader/skybox_VS.hlsl @@ -3,16 +3,16 @@ in vec3 aPosition; -uniform mat4 uProjection; +uniform mat4 uInvProjection; uniform mat4 uModel; uniform mat4 uView; smooth out vec3 eyeDirection; void main() { - mat4 invProjection = inverse(uProjection); +// mat4 invProjection = inverse(uProjection); mat3 invModelview = transpose(mat3(uView)); - vec3 unprojected = (invProjection * vec4(aPosition, 1)).xyz; + vec3 unprojected = (uInvProjection * vec4(aPosition, 1)).xyz; eyeDirection = invModelview * unprojected; //eyeDirection = unprojected; //eyeDirection = aPosition; -- 2.47.3