Make uniforms named

This commit is contained in:
Peder Bergebakken Sundt 2019-03-15 16:26:31 +01:00
parent 9378c685a8
commit e00637d46d
4 changed files with 18 additions and 19 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;