diff --git a/src/renderlogic.cpp b/src/renderlogic.cpp index 9480f41..e9a889b 100644 --- a/src/renderlogic.cpp +++ b/src/renderlogic.cpp @@ -208,7 +208,9 @@ void renderNode(SceneNode* node, Gloom::Shader* parent_shader, vectorlightID; lights[id].position = vec3(node->MV * vec4(vec3(0.0), 1.0)); lights[id].is_spot = node->nodeType == SPOT_LIGHT; - lights[id].spot_direction = node->spot_direction; // MV space + lights[id].spot_direction = (node->transform_spot) + ? node->spot_direction // MV space + : vec3(node->MVnormal * vec4(node->spot_direction, 1.0));// Model space lights[id].spot_cuttof_cos = node->spot_cuttof_cos; lights[id].attenuation = node->attenuation; lights[id].color = node->light_color; diff --git a/src/sceneGraph.hpp b/src/sceneGraph.hpp index 5fc4f9b..3c16e55 100644 --- a/src/sceneGraph.hpp +++ b/src/sceneGraph.hpp @@ -57,6 +57,7 @@ struct SceneNode { float spot_cuttof_cos = glm::cos(glm::radians(1.5)); vec3 spot_direction = vec3(0.0); // in MV space, must be normalized, automatically updated by spot_target SceneNode* spot_target = nullptr; // spot will follow this node + bool transform_spot = false; // if true, spot_direction will be in model space. // The node's position and rotation relative to its parent vec3 position = vec3(0, 0, 0);