Commit 4b9f919b authored by Florian Oetke's avatar Florian Oetke

scene lighting

parent ccb6e796
Pipeline #3416 canceled with stage
{
"Transform": {
},
"Directional_light": {
"source_radius": 1.0,
"intensity": 80.0,
"color": {
"r": 1,
"g": 0.4,
"b": 0.4
},
"shadow_intensity": 10.0,
"shadow_size": 25,
"near_plane": 10.0,
"far_plane": 100,
"update_frequency": 1,
"light_particles": false
}
}
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
"Camera": { "Camera": {
"fov": 50.0, "fov": 50.0,
"near": 0.05, "near": 0.05,
"far": 80.0 "far": 80.0,
"dof_focus": 15,
"dof_range": 3,
"dof_power": 0.5
}, },
"Viewtarget": { "Viewtarget": {
"offset": { "offset": {
......
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
"Model": { "Model": {
"aid": "model:character" "aid": "model:character"
}, },
"Material_property": {
"emissive_color": {"a": 4000}
},
"Shadowcaster": {}, "Shadowcaster": {},
"Movement": { "Movement": {
"beats_per_step": 1, "beats_per_step": 1,
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
}, },
"Directional_light": { "Directional_light": {
"source_radius": 1.0, "source_radius": 1.0,
"intensity": 1000.0, "intensity": 190.0,
"color": { "color": {
"r": 1, "r": 1,
"g": 1, "g": 0.8,
"b": 1 "b": 0.8
}, },
"shadow_intensity": 2.0, "shadow_intensity": 0.0,
"shadow_size": 25, "shadow_size": 25,
"near_plane": 10.0, "near_plane": 10.0,
"far_plane": 100, "far_plane": 100,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"keyframes": [ "keyframes": [
{ {
"time": 0, "time": 0,
"color": {"mean":{"hue":0, "saturation":1, "alpha":20}, "stddev":{"hue":0.001}}, "color": {"mean":{"hue":0, "saturation":1, "alpha":3}, "stddev":{"hue":0.001}},
"size": {"mean": {"x": 0.5, "y":0.5, "z":0.5}, "stddev":{"x": 0.3, "y":0.3, "z":0.3}}, "size": {"mean": {"x": 0.5, "y":0.5, "z":0.5}, "stddev":{"x": 0.3, "y":0.3, "z":0.3}},
"rotation": {"mean":{"angle":0}, "stddev":{"elevation":1, "azimuth":1, "angle": 1}}, "rotation": {"mean":{"angle":0}, "stddev":{"elevation":1, "azimuth":1, "angle": 1}},
"drag": 0.1 "drag": 0.1
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
}, },
{ {
"time": 0.1, "time": 0.1,
"color": {"mean":{"hue":0.472, "saturation":1, "alpha":20}, "stddev":{"hue":0.004}}, "color": {"mean":{"hue":0.472, "saturation":1, "alpha":6}, "stddev":{"hue":0.004}},
"size": {"mean": {"x": 0.5, "y":0.5, "z":0.5}, "stddev":{"x": 0.1, "y":0.1, "z":0.1}}, "size": {"mean": {"x": 0.5, "y":0.5, "z":0.5}, "stddev":{"x": 0.1, "y":0.1, "z":0.1}},
"rotation": {"mean":{"angle":0}, "stddev":{"elevation":1, "azimuth":1, "angle": 1}}, "rotation": {"mean":{"angle":0}, "stddev":{"elevation":1, "azimuth":1, "angle": 1}},
"drag": 0.1 "drag": 0.1
......
Subproject commit 97d1f27e002409519dae841dd1053de1c7eca2fa Subproject commit d997d0e29bbbbe10a5eb9c211f8131a8e46135b0
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
#include <mirrage/ecs/components/transform_comp.hpp> #include <mirrage/ecs/components/transform_comp.hpp>
#include <mirrage/ecs/ecs.hpp> #include <mirrage/ecs/ecs.hpp>
#include <mirrage/renderer/model_comp.hpp>
namespace phase_shifter::level { namespace phase_shifter::level {
using namespace mirrage; using namespace mirrage;
using namespace mirrage::ecs::components; using namespace mirrage::ecs::components;
...@@ -42,9 +45,22 @@ namespace phase_shifter::level { ...@@ -42,9 +45,22 @@ namespace phase_shifter::level {
} }
} // namespace } // namespace
Level_system::Level_system(mirrage::ecs::Entity_manager& entities, mirrage::asset::Asset_manager& assets) Level_system::Level_system(mirrage::ecs::Entity_manager& entities,
: _entities(entities), _assets(assets) mirrage::asset::Asset_manager& assets,
const gameplay::Beat_system& beat)
: _entities(entities), _assets(assets), _beat(beat)
{ {
auto create_tile_dummy = [&](glm::vec4 c) {
auto e = entities.emplace_empty();
e.emplace<mirrage::renderer::Material_property_comp>(c);
_tile_dummies.emplace_back(e);
};
create_tile_dummy(glm::vec4(0.f, 0.f, 0.f, 0.f));
create_tile_dummy(glm::vec4(1, 1, 1, 4000.f));
create_tile_dummy(glm::vec4(1, 0.5f, 0.5f, 10000.f));
create_tile_dummy(glm::vec4(1, 1, 1, 4000.f));
_entities.register_component_type<gameplay::Rigid_body_comp>(); _entities.register_component_type<gameplay::Rigid_body_comp>();
_spawners.emplace("p", [&](const Tile& tile, const glm::vec3& position) { _spawners.emplace("p", [&](const Tile& tile, const glm::vec3& position) {
...@@ -80,10 +96,25 @@ namespace phase_shifter::level { ...@@ -80,10 +96,25 @@ namespace phase_shifter::level {
.create() .create()
.emplace<helper::Attachment_comp>(camera.handle(), .emplace<helper::Attachment_comp>(camera.handle(),
glm::rotate(sun_dir, glm::vec3(0, 0, 1)) * 40.f); glm::rotate(sun_dir, glm::vec3(0, 0, 1)) * 40.f);
sun_elevation = 0.3f * glm::pi<float>();
sun_azimuth = glm::pi<float>() - 0.2f;
sun_dir = glm::quat(glm::vec3(
(sun_elevation - 2.f) * glm::pi<float>() / 2.f, glm::pi<float>() * sun_azimuth, 0.f));
_entities.entity_builder("anti_sun")
.rotation(sun_dir)
.position(glm::rotate(sun_dir, glm::vec3(0, 0, 1)) * 40.f)
.create();
}); });
} }
auto Level_system::update(const mirrage::util::Time& time) -> void {} auto Level_system::update(const mirrage::util::Time& time) -> void
{
if(_beat.beat_state().beat) {
_beat_light_offset = (_beat_light_offset + 1) % _tile_dummies.size();
}
}
void Level_system::draw(mirrage::renderer::Deferred_renderer& renderer) void Level_system::draw(mirrage::renderer::Deferred_renderer& renderer)
{ {
...@@ -150,12 +181,15 @@ namespace phase_shifter::level { ...@@ -150,12 +181,15 @@ namespace phase_shifter::level {
for(auto x = min_x; x < max_x; x++) { for(auto x = min_x; x < max_x; x++) {
auto tile = level.tiles[y][x]; auto tile = level.tiles[y][x];
auto tile_dummy = _tile_dummies[(x + y + _beat_light_offset) % _tile_dummies.size()].handle();
auto model_ptr = _tile_models.find(tile); auto model_ptr = _tile_models.find(tile);
if(model_ptr != _tile_models.end() && model_ptr->second.ready()) { if(model_ptr != _tile_models.end() && model_ptr->second.ready()) {
auto& model = model_ptr->second.get_blocking(); auto& model = model_ptr->second.get_blocking();
auto& submeshes = model.sub_meshes(); auto& submeshes = model.sub_meshes();
for(auto&& submesh_index : mirrage::util::range(submeshes.size())) { for(auto&& submesh_index : mirrage::util::range(submeshes.size())) {
auto& geometry = render_queue.emplace_back(); auto& geometry = render_queue.emplace_back();
geometry.entity = tile_dummy;
geometry.model = &model; geometry.model = &model;
geometry.sub_mesh = std::uint32_t(submesh_index); geometry.sub_mesh = std::uint32_t(submesh_index);
geometry.position = glm::vec3(x, 0, y) * offset; geometry.position = glm::vec3(x, 0, y) * offset;
......
#pragma once #pragma once
#include "../gameplay/beat_system.hpp"
#include "../util/collision.hpp" #include "../util/collision.hpp"
#include "level.hpp" #include "level.hpp"
...@@ -24,7 +25,9 @@ namespace mirrage::asset { ...@@ -24,7 +25,9 @@ namespace mirrage::asset {
namespace phase_shifter::level { namespace phase_shifter::level {
class Level_system { class Level_system {
public: public:
Level_system(mirrage::ecs::Entity_manager& entities, mirrage::asset::Asset_manager& assets); Level_system(mirrage::ecs::Entity_manager& entities,
mirrage::asset::Asset_manager& assets,
const gameplay::Beat_system&);
auto update(const mirrage::util::Time& time) -> void; auto update(const mirrage::util::Time& time) -> void;
void draw(mirrage::renderer::Deferred_renderer& renderer); void draw(mirrage::renderer::Deferred_renderer& renderer);
...@@ -39,6 +42,10 @@ namespace phase_shifter::level { ...@@ -39,6 +42,10 @@ namespace phase_shifter::level {
mirrage::ecs::Entity_manager& _entities; mirrage::ecs::Entity_manager& _entities;
mirrage::asset::Asset_manager& _assets; mirrage::asset::Asset_manager& _assets;
const gameplay::Beat_system& _beat;
int _beat_light_offset = 0;
std::vector<mirrage::ecs::Entity_facet> _tile_dummies;
Level_ptr _current_level; Level_ptr _current_level;
std::unordered_map<std::string, std::function<auto(const Tile&, const glm::vec3&)->void>> _spawners; std::unordered_map<std::string, std::function<auto(const Tile&, const glm::vec3&)->void>> _spawners;
......
...@@ -36,7 +36,7 @@ namespace phase_shifter { ...@@ -36,7 +36,7 @@ namespace phase_shifter {
, _model_loading(std::make_unique<renderer::Loading_system>(_entities, engine.assets())) , _model_loading(std::make_unique<renderer::Loading_system>(_entities, engine.assets()))
, _sound_manager(std::make_unique<audio::Sound_manager>(engine.audio(), engine.bus(), engine.assets())) , _sound_manager(std::make_unique<audio::Sound_manager>(engine.audio(), engine.bus(), engine.assets()))
, _beat_system(std::make_unique<gameplay::Beat_system>(engine.bus(), engine.assets())) , _beat_system(std::make_unique<gameplay::Beat_system>(engine.bus(), engine.assets()))
, _level_system(std::make_unique<level::Level_system>(_entities, engine.assets())) , _level_system(std::make_unique<level::Level_system>(_entities, engine.assets(), *_beat_system))
, _movement_system(std::make_unique<gameplay::Movement_system>( , _movement_system(std::make_unique<gameplay::Movement_system>(
engine.bus(), _entities, *_beat_system, *_level_system)) engine.bus(), _entities, *_beat_system, *_level_system))
, _input_system(std::make_unique<input::Input_system>(engine.bus(), _entities)) , _input_system(std::make_unique<input::Input_system>(engine.bus(), _entities))
...@@ -54,9 +54,11 @@ namespace phase_shifter { ...@@ -54,9 +54,11 @@ namespace phase_shifter {
_entities.register_component_type<ecs::components::Transform_comp>(); _entities.register_component_type<ecs::components::Transform_comp>();
//auto s = _renderer->settings(); auto s = _renderer->settings();
//s.scene_luminance_override = 300.f; s.amient_light_intensity = 0.4f;
//_renderer->settings(s, false); s.exposure_luminance_override = 400.f;
s.scene_luminance_override = 400.f;
_renderer->settings(s, false);
/*auto bg_music = /*auto bg_music =
engine.assets().load<std::shared_ptr<eam::opus>>("audio:bg_music_01"_aid).get_blocking(); engine.assets().load<std::shared_ptr<eam::opus>>("audio:bg_music_01"_aid).get_blocking();
......
...@@ -47,7 +47,7 @@ namespace phase_shifter::ui { ...@@ -47,7 +47,7 @@ namespace phase_shifter::ui {
: _bus(bus), _mailbox(bus), _ecs(ecs) : _bus(bus), _mailbox(bus), _ecs(ecs)
{ {
_tombstones.resize(20); _tombstones.resize(10);
for(auto& t : _tombstones) { for(auto& t : _tombstones) {
t.entity = t.entity =
_ecs.entity_builder("enemy_tombstone").position(glm::vec3{-999.f, 0.f, -999.f}).create(); _ecs.entity_builder("enemy_tombstone").position(glm::vec3{-999.f, 0.f, -999.f}).create();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment