diff --git a/res/shaders/simple.frag b/res/shaders/simple.frag index a4fe4ce..ac89f6f 100644 --- a/res/shaders/simple.frag +++ b/res/shaders/simple.frag @@ -4,19 +4,19 @@ in layout(location = 0) vec3 normal; in layout(location = 1) vec3 vertex; in layout(location = 2) vec2 UV; in layout(location = 3) mat3 TBN; + layout(binding = 0) uniform sampler2D diffuseTexture; layout(binding = 1) uniform sampler2D normalTexture; +uniform mat4 MVP; +uniform mat4 MV; +uniform mat4 MVnormal; + uniform bool isIlluminated; uniform bool isTextured; uniform bool isNormalMapped; uniform bool isInverted; -uniform layout(location = 6) mat4 MVP; -uniform layout(location = 7) mat4 MV; -uniform layout(location = 8) mat4 MVnormal; - - // point lights struct Light { vec3 position; diff --git a/res/shaders/simple.vert b/res/shaders/simple.vert index c8a588a..722219c 100644 --- a/res/shaders/simple.vert +++ b/res/shaders/simple.vert @@ -6,11 +6,9 @@ in layout(location = 2) vec2 UV; in layout(location = 3) vec3 tangent; in layout(location = 4) vec3 bitangent; -uniform layout(location = 6) mat4 MVP; -uniform layout(location = 7) mat4 MV; -uniform layout(location = 8) mat4 MVnormal; - -//named +uniform mat4 MVP; +uniform mat4 MV; +uniform mat4 MVnormal; uniform bool isIlluminated; uniform bool isTextured; uniform bool isNormalMapped; diff --git a/src/gamelogic.cpp b/src/gamelogic.cpp index 3d87ff2..647054b 100644 --- a/src/gamelogic.cpp +++ b/src/gamelogic.cpp @@ -218,9 +218,9 @@ void updateNodeTransformations(SceneNode* node, glm::mat4 transformationThusFar, glm::mat4 M = transformationThusFar * transformationMatrix; glm::mat4 MV = V*M; - node->currentTransformationMatrixMV = MV; - node->currentTransformationMatrix = P*MV; - node->currentTransformationMatrixMVnormal = glm::inverse(glm::transpose(MV)); + node->MV = MV; + node->MVP = P*MV; + node->MVnormal = glm::inverse(glm::transpose(MV)); for(SceneNode* child : node->children) { updateNodeTransformations(child, M, V, P); @@ -387,9 +387,9 @@ void updateFrame(GLFWwindow* window) { void renderNode(SceneNode* node) { - glUniformMatrix4fv(6, 1, GL_FALSE, glm::value_ptr(node->currentTransformationMatrix)); - glUniformMatrix4fv(7, 1, GL_FALSE, glm::value_ptr(node->currentTransformationMatrixMV)); - glUniformMatrix4fv(8, 1, GL_FALSE, glm::value_ptr(node->currentTransformationMatrixMVnormal)); + glUniformMatrix4fv(s->location("MVP") , 1, GL_FALSE, glm::value_ptr(node->MVP)); + glUniformMatrix4fv(s->location("MV") , 1, GL_FALSE, glm::value_ptr(node->MV)); + glUniformMatrix4fv(s->location("MVnormal"), 1, GL_FALSE, glm::value_ptr(node->MVnormal)); glUniform1ui(shader->location("isNormalMapped"), false); glUniform1ui(shader->location("isTextured"), false); @@ -423,6 +423,7 @@ void renderNode(SceneNode* node) { break; } case HUD: + default: break; } diff --git a/src/sceneGraph.hpp b/src/sceneGraph.hpp index 05d4b7b..051558b 100644 --- a/src/sceneGraph.hpp +++ b/src/sceneGraph.hpp @@ -51,9 +51,9 @@ struct SceneNode { glm::vec3 scale; // A transformation matrix representing the transformation of the node's location relative to its parent. This matrix is updated every frame. - glm::mat4 currentTransformationMatrix; // MVP - glm::mat4 currentTransformationMatrixMV; // MV - glm::mat4 currentTransformationMatrixMVnormal; // transpose(inverse(MV)) + glm::mat4 MVP; // MVP + glm::mat4 MV; // MV + glm::mat4 MVnormal; // transpose(inverse(MV)) // The location of the node's reference point glm::vec3 referencePoint;