Make uniforms named
This commit is contained in:
parent
9378c685a8
commit
e00637d46d
|
@ -4,19 +4,19 @@ in layout(location = 0) vec3 normal;
|
||||||
in layout(location = 1) vec3 vertex;
|
in layout(location = 1) vec3 vertex;
|
||||||
in layout(location = 2) vec2 UV;
|
in layout(location = 2) vec2 UV;
|
||||||
in layout(location = 3) mat3 TBN;
|
in layout(location = 3) mat3 TBN;
|
||||||
|
|
||||||
layout(binding = 0) uniform sampler2D diffuseTexture;
|
layout(binding = 0) uniform sampler2D diffuseTexture;
|
||||||
layout(binding = 1) uniform sampler2D normalTexture;
|
layout(binding = 1) uniform sampler2D normalTexture;
|
||||||
|
|
||||||
|
uniform mat4 MVP;
|
||||||
|
uniform mat4 MV;
|
||||||
|
uniform mat4 MVnormal;
|
||||||
|
|
||||||
uniform bool isIlluminated;
|
uniform bool isIlluminated;
|
||||||
uniform bool isTextured;
|
uniform bool isTextured;
|
||||||
uniform bool isNormalMapped;
|
uniform bool isNormalMapped;
|
||||||
uniform bool isInverted;
|
uniform bool isInverted;
|
||||||
|
|
||||||
uniform layout(location = 6) mat4 MVP;
|
|
||||||
uniform layout(location = 7) mat4 MV;
|
|
||||||
uniform layout(location = 8) mat4 MVnormal;
|
|
||||||
|
|
||||||
|
|
||||||
// point lights
|
// point lights
|
||||||
struct Light {
|
struct Light {
|
||||||
vec3 position;
|
vec3 position;
|
||||||
|
|
|
@ -6,11 +6,9 @@ in layout(location = 2) vec2 UV;
|
||||||
in layout(location = 3) vec3 tangent;
|
in layout(location = 3) vec3 tangent;
|
||||||
in layout(location = 4) vec3 bitangent;
|
in layout(location = 4) vec3 bitangent;
|
||||||
|
|
||||||
uniform layout(location = 6) mat4 MVP;
|
uniform mat4 MVP;
|
||||||
uniform layout(location = 7) mat4 MV;
|
uniform mat4 MV;
|
||||||
uniform layout(location = 8) mat4 MVnormal;
|
uniform mat4 MVnormal;
|
||||||
|
|
||||||
//named
|
|
||||||
uniform bool isIlluminated;
|
uniform bool isIlluminated;
|
||||||
uniform bool isTextured;
|
uniform bool isTextured;
|
||||||
uniform bool isNormalMapped;
|
uniform bool isNormalMapped;
|
||||||
|
|
|
@ -218,9 +218,9 @@ void updateNodeTransformations(SceneNode* node, glm::mat4 transformationThusFar,
|
||||||
glm::mat4 M = transformationThusFar * transformationMatrix;
|
glm::mat4 M = transformationThusFar * transformationMatrix;
|
||||||
glm::mat4 MV = V*M;
|
glm::mat4 MV = V*M;
|
||||||
|
|
||||||
node->currentTransformationMatrixMV = MV;
|
node->MV = MV;
|
||||||
node->currentTransformationMatrix = P*MV;
|
node->MVP = P*MV;
|
||||||
node->currentTransformationMatrixMVnormal = glm::inverse(glm::transpose(MV));
|
node->MVnormal = glm::inverse(glm::transpose(MV));
|
||||||
|
|
||||||
for(SceneNode* child : node->children) {
|
for(SceneNode* child : node->children) {
|
||||||
updateNodeTransformations(child, M, V, P);
|
updateNodeTransformations(child, M, V, P);
|
||||||
|
@ -387,9 +387,9 @@ void updateFrame(GLFWwindow* window) {
|
||||||
|
|
||||||
|
|
||||||
void renderNode(SceneNode* node) {
|
void renderNode(SceneNode* node) {
|
||||||
glUniformMatrix4fv(6, 1, GL_FALSE, glm::value_ptr(node->currentTransformationMatrix));
|
glUniformMatrix4fv(s->location("MVP") , 1, GL_FALSE, glm::value_ptr(node->MVP));
|
||||||
glUniformMatrix4fv(7, 1, GL_FALSE, glm::value_ptr(node->currentTransformationMatrixMV));
|
glUniformMatrix4fv(s->location("MV") , 1, GL_FALSE, glm::value_ptr(node->MV));
|
||||||
glUniformMatrix4fv(8, 1, GL_FALSE, glm::value_ptr(node->currentTransformationMatrixMVnormal));
|
glUniformMatrix4fv(s->location("MVnormal"), 1, GL_FALSE, glm::value_ptr(node->MVnormal));
|
||||||
glUniform1ui(shader->location("isNormalMapped"), false);
|
glUniform1ui(shader->location("isNormalMapped"), false);
|
||||||
glUniform1ui(shader->location("isTextured"), false);
|
glUniform1ui(shader->location("isTextured"), false);
|
||||||
|
|
||||||
|
@ -423,6 +423,7 @@ void renderNode(SceneNode* node) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HUD:
|
case HUD:
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,9 @@ struct SceneNode {
|
||||||
glm::vec3 scale;
|
glm::vec3 scale;
|
||||||
|
|
||||||
// A transformation matrix representing the transformation of the node's location relative to its parent. This matrix is updated every frame.
|
// 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 MVP; // MVP
|
||||||
glm::mat4 currentTransformationMatrixMV; // MV
|
glm::mat4 MV; // MV
|
||||||
glm::mat4 currentTransformationMatrixMVnormal; // transpose(inverse(MV))
|
glm::mat4 MVnormal; // transpose(inverse(MV))
|
||||||
|
|
||||||
// The location of the node's reference point
|
// The location of the node's reference point
|
||||||
glm::vec3 referencePoint;
|
glm::vec3 referencePoint;
|
||||||
|
|
Loading…
Reference in New Issue