16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 19:09:20 +02:00
This commit is contained in:
2026-05-24 21:48:05 +02:00
parent 5b51188dfe
commit 2c599cb419
46 changed files with 2034 additions and 85 deletions

View File

@@ -38,6 +38,17 @@ public:
// types
typedef std::vector<light_record> lightrecord_array;
struct free_light_record {
glm::dvec3 position;
glm::vec3 direction { 0.f, -1.f, 0.f };
glm::vec3 color { 1.f, 1.f, 1.f };
float intensity { 1.0f };
float range { 25.0f };
float inner_cutoff { 0.9659f }; // cos(15°)
float outer_cutoff { 0.9063f }; // cos(25°)
};
// members
lightrecord_array data;
std::vector<free_light_record> free_lights;
};

View File

@@ -19,6 +19,7 @@ http://mozilla.org/MPL/2.0/.
#include "utilities/utilities.h"
#include "simulation/simulationtime.h"
#include "application/application.h"
#include "entitysystem/ECScene.h"
#include "model/AnimModel.h"
#include "rendering/opengl33geometrybank.h"
#include "rendering/screenshot.h"
@@ -867,7 +868,7 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
setup_drawing(true);
Render_Alpha(simulation::Region);
// particles
// particles + ECS effects
Render_particles();
// precipitation; done at end, only before cab render
@@ -3578,6 +3579,10 @@ void opengl33_renderer::Render_particles()
Bind_Texture(0, m_smoketexture);
m_particlerenderer.update(m_renderpass.pass_camera);
m_renderpass.draw_stats.particles = m_particlerenderer.render();
// ECS particle, line and effect rendering — runs here so matrices/UBOs are set up
if (auto *scene = Application.sceneManager.CurrentScene())
scene->Render();
}
void opengl33_renderer::Render_vr_models()
@@ -4707,6 +4712,31 @@ void opengl33_renderer::Update_Lights(light_array &Lights)
++light_i;
++renderlight;
}
// fill free ECS SpotLight data
for (auto const &fl : Lights.free_lights)
{
if (light_i >= gl::MAX_LIGHTS) break;
auto const lightoffset = glm::vec3{ fl.position - camera };
if (glm::length(lightoffset) > 1000.f) continue;
gl::light_element_ubs *light = &light_ubs.lights[light_i];
light->pos = mv * glm::vec4(lightoffset, 1.0f);
light->dir = mv * glm::vec4(fl.direction, 0.0f);
light->type = gl::light_element_ubs::SPOT;
light->in_cutoff = fl.inner_cutoff;
light->out_cutoff = fl.outer_cutoff;
light->color = fl.color * fl.intensity;
light->linear = 4.5f / fl.range;
light->quadratic = 75.0f / (fl.range * fl.range);
light->ambient = 0.0f;
light->intensity = fl.intensity;
light->headlight_projection = glm::mat4(0.f);
light->headlight_weights = glm::vec4(0.f);
++light_i;
}
light_ubs.lights_count = light_i;
// fill sunlight data
light_ubs.ambient = m_sunlight.ambient * m_sunlight.factor;// *simulation::Environment.light_intensity();

View File

@@ -130,6 +130,8 @@ class opengl33_renderer : public gfx_renderer {
// draws supplied geometry handles
void Draw_Geometry(std::vector<gfx::geometrybank_handle>::iterator begin, std::vector<gfx::geometrybank_handle>::iterator end);
void Draw_Geometry(const gfx::geometrybank_handle &handle);
// draws a geometry chunk, uploading the current modelview matrix first
void draw(gfx::geometry_handle const &handle) override;
// material methods
void Bind_Material_Shadow(material_handle const Material);
void Update_AnimModel(TAnimModel *model);
@@ -289,7 +291,6 @@ class opengl33_renderer : public gfx_renderer {
bool init_viewport(viewport_config &vp);
void draw(const gfx::geometry_handle &handle);
void draw(std::vector<gfx::geometrybank_handle>::iterator begin, std::vector<gfx::geometrybank_handle>::iterator end);
void draw_debug_ui();

View File

@@ -66,6 +66,8 @@ public:
virtual void Bind_Texture( std::size_t const Unit, texture_handle const Texture ) = 0;
virtual auto Texture( texture_handle const Texture ) -> ITexture & = 0;
virtual auto Texture( texture_handle const Texture ) const -> ITexture const & = 0;
// draw a geometry chunk with the current transform state (no-op in backends that don't support it)
virtual void draw( gfx::geometry_handle const & ) {}
// utility methods
virtual void Pick_Control_Callback( std::function<void( TSubModel const *, const glm::vec2 )> Callback ) = 0;
virtual void Pick_Node_Callback( std::function<void( scene::basic_node * )> Callback ) = 0;