2022-04-23 22:46:06 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "scene_node.h"
|
|
|
|
|
#include "texture.h"
|
|
|
|
|
|
|
|
|
|
BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
|
|
// http://en.wikipedia.org/wiki/Shading#Lighting
|
|
|
|
|
enum class light_type {
|
|
|
|
|
directional,
|
|
|
|
|
point,
|
|
|
|
|
spot
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct light_node : scene_node {
|
2023-04-24 11:24:26 +03:00
|
|
|
explicit light_node(light_type type);
|
2022-04-23 22:46:06 +03:00
|
|
|
|
|
|
|
|
void calculate_local_transform() override;
|
|
|
|
|
|
|
|
|
|
light_type light_type_;
|
|
|
|
|
|
|
|
|
|
glm::vec4 ambient = glm::vec4(0.2, 0.2, 0.2, 1);
|
|
|
|
|
glm::vec4 diffuse = glm::vec4(0.5, 0.5, 0.5, 1);
|
|
|
|
|
glm::vec4 specular = glm::vec4(1);
|
|
|
|
|
|
|
|
|
|
glm::vec3 attenuation;
|
|
|
|
|
|
|
|
|
|
glm::vec3 spot_target;
|
|
|
|
|
float spot_cutoff;
|
|
|
|
|
float spot_exponent;
|
|
|
|
|
|
|
|
|
|
bool active = true;
|
|
|
|
|
|
|
|
|
|
int shadow_map_width = 1024;
|
|
|
|
|
glm::mat4 light_projection_matrix[6];
|
|
|
|
|
glm::mat4 world_to_light_matrix[6];
|
|
|
|
|
glm::mat4 shadow_map_bias_matrix;
|
|
|
|
|
glm::mat4 final_shadow_map_matrix[6];
|
|
|
|
|
std::shared_ptr<texture> shadow_map[6];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
END_NAMESPACE
|