Chang the custom node shaders to be inherited by the children if left to nullptr
This commit is contained in:
parent
32ee578082
commit
ce277dfce5
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue