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 @@
"Camera": {
"fov": 50.0,
"near": 0.05,
"far": 80.0
"far": 80.0,
"dof_focus": 15,
"dof_range": 3,
"dof_power": 0.5
},
"Viewtarget": {
"offset": {
......
......@@ -9,6 +9,9 @@
"Model": {
"aid": "model:character"
},
"Material_property": {
"emissive_color": {"a": 4000}
},
"Shadowcaster": {},
"Movement": {
"beats_per_step": 1,
......
......@@ -3,13 +3,13 @@
},
"Directional_light": {
"source_radius": 1.0,
"intensity": 1000.0,
"intensity": 190.0,
"color": {
"r": 1,
"g": 1,
"b": 1
"g": 0.8,
"b": 0.8
},
"shadow_intensity": 2.0,
"shadow_intensity": 0.0,
"shadow_size": 25,
"near_plane": 10.0,
"far_plane": 100,
......
......@@ -2,7 +2,7 @@
"keyframes": [
{
"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}},
"rotation": {"mean":{"angle":0}, "stddev":{"elevation":1, "azimuth":1, "angle": 1}},
"drag": 0.1
......
......@@ -9,7 +9,7 @@
},
{
"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}},
"rotation": {"mean":{"angle":0}, "stddev":{"elevation":1, "azimuth":1, "angle": 1}},
"drag": 0.1
......
Subproject commit 97d1f27e002409519dae841dd1053de1c7eca2fa
Subproject commit d997d0e29bbbbe10a5eb9c211f8131a8e46135b0
......@@ -9,6 +9,9 @@
#include <mirrage/ecs/components/transform_comp.hpp>
#include <mirrage/ecs/ecs.hpp>
#include <mirrage/renderer/model_comp.hpp>
namespace phase_shifter::level {
using namespace mirrage;
using namespace mirrage::ecs::components;
......@@ -42,9 +45,22 @@ namespace phase_shifter::level {
}
} // namespace
Level_system::Level_system(mirrage::ecs::Entity_manager& entities, mirrage::asset::Asset_manager& assets)
: _entities(entities), _assets(assets)
Level_system::Level_system(mirrage::ecs::Entity_manager& entities,
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>();
_spawners.emplace("p", [&](const Tile& tile, const glm::vec3& position) {
......@@ -80,10 +96,25 @@ namespace phase_shifter::level {
.create()
.emplace<helper::Attachment_comp>(camera.handle(),
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)
{
......@@ -150,12 +181,15 @@ namespace phase_shifter::level {
for(auto x = min_x; x < max_x; 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);
if(model_ptr != _tile_models.end() && model_ptr->second.ready()) {
auto& model = model_ptr->second.get_blocking();
auto& submeshes = model.sub_meshes();
for(auto&& submesh_index : mirrage::util::range(submeshes.size())) {
auto& geometry = render_queue.emplace_back();
geometry.entity = tile_dummy;
geometry.model = &model;
geometry.sub_mesh = std::uint32_t(submesh_index);
geometry.position = glm::vec3(x, 0, y) * offset;
......
#pragma once
#include "../gameplay/beat_system.hpp"
#include "../util/collision.hpp"
#include "level.hpp"
......@@ -24,7 +25,9 @@ namespace mirrage::asset {
namespace phase_shifter::level {
class Level_system {
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;
void draw(mirrage::renderer::Deferred_renderer& renderer);
......@@ -39,6 +42,10 @@ namespace phase_shifter::level {
mirrage::ecs::Entity_manager& _entities;
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;
std::unordered_map<std::string, std::function<auto(const Tile&, const glm::vec3&)->void>> _spawners;
......
......@@ -36,7 +36,7 @@ namespace phase_shifter {
, _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()))
, _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>(
engine.bus(), _entities, *_beat_system, *_level_system))
, _input_system(std::make_unique<input::Input_system>(engine.bus(), _entities))
......@@ -54,9 +54,11 @@ namespace phase_shifter {
_entities.register_component_type<ecs::components::Transform_comp>();
//auto s = _renderer->settings();
//s.scene_luminance_override = 300.f;
//_renderer->settings(s, false);
auto s = _renderer->settings();
s.amient_light_intensity = 0.4f;
s.exposure_luminance_override = 400.f;
s.scene_luminance_override = 400.f;
_renderer->settings(s, false);
/*auto bg_music =
engine.assets().load<std::shared_ptr<eam::opus>>("audio:bg_music_01"_aid).get_blocking();
......
......@@ -47,7 +47,7 @@ namespace phase_shifter::ui {
: _bus(bus), _mailbox(bus), _ecs(ecs)
{
_tombstones.resize(20);
_tombstones.resize(10);
for(auto& t : _tombstones) {
t.entity =
_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