diff --git a/src/gamelogic.cpp b/src/gamelogic.cpp index 9585fb2..d95a98d 100644 --- a/src/gamelogic.cpp +++ b/src/gamelogic.cpp @@ -368,7 +368,7 @@ void updateFrame(GLFWwindow* window) { } -void renderNode(SceneNode* node) { +void renderNode(SceneNode* node, Gloom::Shader* parent_shader = default_shader) { struct Light { // lights as stored in the shader // coordinates in MV space vec3 position; @@ -389,7 +389,7 @@ void renderNode(SceneNode* node) { // activate the correct shader Gloom::Shader* node_shader = (node->shader != nullptr) ? node->shader - : default_shader; + : parent_shader; if (s != node_shader) { s = node_shader; s->activate(); @@ -435,7 +435,7 @@ void renderNode(SceneNode* node) { } for(SceneNode* child : node->children) { - renderNode(child); + renderNode(child, node_shader); } } diff --git a/src/sceneGraph.hpp b/src/sceneGraph.hpp index eba8596..816e005 100644 --- a/src/sceneGraph.hpp +++ b/src/sceneGraph.hpp @@ -57,7 +57,7 @@ struct SceneNode { vec3 rotation = vec3(0, 0, 0); vec3 scale = vec3(1, 1, 1); - // set this if the shape uses a custom shader other than the default one + // set this if the shape uses a custom shader other than the inherited one Gloom::Shader* shader = nullptr; // A transformation matrix representing the transformation of the node's location relative to its parent. This matrix is updated every frame.