72{
73
74 camera *primary_camera {};
75 for (auto &&[entity, camera] : Registry.view<camera_component>().each())
76 if (camera.IsPrimary) { primary_camera = &camera.Camera; break; }
77 if (primary_camera == nullptr) return;
78 if (primary_camera->GetViewportWidth() != ViewportWidth || primary_camera->GetViewportHeight() != ViewportHeight)
79 primary_camera->Resize(ViewportWidth, ViewportHeight);
80
82 {
83 for (auto &&[entity, point_light, transform] : Registry.group<point_light_component>(entt::get<transform_component>).each())
84 renderer::SubmitPointLight(transform.Position, point_light.Color * point_light.Strength, point_light.Constant, point_light.Linear, point_light.Quadratic);
85
86 for (auto &&[entity, directional_light, transform] : Registry.group<directional_light_component>(entt::get<transform_component>).each())
87 {
88 vec3 direction = transform.AnglesMatr.TransformVector(
vec3 { 0, -1, 0 });
89 vec3 at = transform.Position + direction;
91 matr4::View(transform.Position, at, { 0, 1, 0 }) * directional_light.GetProjection(), directional_light.GetShadowMap());
92 }
93
94 for (auto &&[entity, spot_light, transform] : Registry.group<spot_light_component>(entt::get<transform_component>).each())
95 {
96 vec3 direction = transform.AnglesMatr.TransformVector(
vec3 { 0, -1, 0 });
98 spot_light.InnerCutoffCos, spot_light.OuterCutoffCos, spot_light.Epsilon);
99 }
100
101 for (auto &&[entity, mesh, transform] : Registry.group<mesh_component>(entt::get<transform_component>).each())
103 }
105}
static matr4 View(vec3< float > Location, vec3< float > At, vec3< float > Up)
static void StartPipeline(const camera &Camera, const vec3 &EnviromentAmbiente)
static void Submit(const shared< mesh > &Mesh, const vec3 &Scale, const vec3 &Angles, const vec3 &Position)
static void SubmitSpotLight(const vec3 &Position, const vec3 &Direction, const vec3 &Color, float InnerCutoffCos, float OuterCutoffCos, float Epsilon)
static void SubmitPointLight(const vec3 &Position, const vec3 &Color, float Constant, float Linear, float Quadratic)
static void EndPipeline()
static void SubmitDirectionalLight(const vec3 &Direction, const vec3 &Color, bool IsShadows=false, const matr4 &ViewProjection={}, const shared< frame_buffer > &ShadowMap=nullptr)