Add support for spot lights with a fixed direction in model space
This commit is contained in:
parent
383d5d3f62
commit
199765e112
|
@ -208,7 +208,9 @@ void renderNode(SceneNode* node, Gloom::Shader* parent_shader, vector<NodeDistSh
|
||||||
uint id = node->lightID;
|
uint id = node->lightID;
|
||||||
lights[id].position = vec3(node->MV * vec4(vec3(0.0), 1.0));
|
lights[id].position = vec3(node->MV * vec4(vec3(0.0), 1.0));
|
||||||
lights[id].is_spot = node->nodeType == SPOT_LIGHT;
|
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].spot_cuttof_cos = node->spot_cuttof_cos;
|
||||||
lights[id].attenuation = node->attenuation;
|
lights[id].attenuation = node->attenuation;
|
||||||
lights[id].color = node->light_color;
|
lights[id].color = node->light_color;
|
||||||
|
|
|
@ -57,6 +57,7 @@ struct SceneNode {
|
||||||
float spot_cuttof_cos = glm::cos(glm::radians(1.5));
|
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
|
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
|
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
|
// The node's position and rotation relative to its parent
|
||||||
vec3 position = vec3(0, 0, 0);
|
vec3 position = vec3(0, 0, 0);
|
||||||
|
|
Loading…
Reference in New Issue