Commit 03da168c authored by Tim Scheiber's avatar Tim Scheiber

Merge branch 'develop' into feature/24-camera-screen-shake

parents 3d536398 5f103ca5
{
"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
......
{
"format": {
"version": "1.0"
},
"shaders": {
"Main shader": {
"parameters": {
"Common Parameters": {
"ao_intensity": 0.75,
"emissive_intensity": 1,
"horizonFade": 1.2999999523162842,
"nbSamples": 16
},
"Parallax Occlusion Mapping": {
"maxPOMSamples": 16,
"minPOMSamples": 4,
"pomStrength": 1,
"usePOM": false
},
"Subsurface Scattering Parameters": {
"sssColor": [
0.7009999752044678,
0.3009999990463257,
0.3050000071525574
],
"sssEnabled": true,
"sssScale": 0.5,
"sssType": 1
}
},
"shader": "pbr-metal-rough",
"shaderInstance": "Main shader"
}
},
"texturesets": {
"Glow1": {
"shader": "Main shader"
},
"Glow2": {
"shader": "Main shader"
},
"Wall_Inner": {
"shader": "Main shader"
},
"Wall_Outer": {
"shader": "Main shader"
}
}
}
{
"format": {
"version": "1.0"
},
"shaders": {
"Main shader": {
"parameters": {
"Common Parameters": {
"ao_intensity": 0.75,
"emissive_intensity": 1,
"horizonFade": 1.2999999523162842,
"nbSamples": 16
},
"Parallax Occlusion Mapping": {
"maxPOMSamples": 16,
"minPOMSamples": 4,
"pomStrength": 1,
"usePOM": false
},
"Subsurface Scattering Parameters": {
"sssColor": [
0.7009999752044678,
0.3009999990463257,
0.3050000071525574
],
"sssEnabled": true,
"sssScale": 0.5,
"sssType": 1
}
},
"shader": "pbr-metal-rough",
"shaderInstance": "Main shader"
}
},
"texturesets": {
"Glow1": {
"shader": "Main shader"
},
"Glow2": {
"shader": "Main shader"
},
"Wall_Inner": {
"shader": "Main shader"
},
"Wall_Outer": {
"shader": "Main shader"
}
}
}
Subproject commit 97d1f27e002409519dae841dd1053de1c7eca2fa
Subproject commit d997d0e29bbbbe10a5eb9c211f8131a8e46135b0
......@@ -10,6 +10,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;
......@@ -43,9 +46,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) {
......@@ -85,10 +101,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)
{
......@@ -155,12 +186,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();
......
......@@ -13,7 +13,7 @@ namespace phase_shifter::ui {
using namespace mirrage::gui::literals;
namespace {
constexpr auto hud_height = 100;
constexpr auto hud_height = 130;
constexpr auto bar_height = 80;
constexpr auto beat_bar_height = 79;
constexpr auto bar_speed = 100;
......@@ -38,35 +38,24 @@ namespace phase_shifter::ui {
if(font.is_some())
ImGui::PushFont(font.get_or_throw());
ImGui::PositionNextWindow(glm::vec2(viewport.z, hud_height),
ImGui::WindowPosition_X::left,
ImGui::WindowPosition_Y::top);
if(ImGui::Begin("hud",
nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize
| ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoInputs)) {
ImGui::Text("%i", _beat_system.beat_state().beats_left);
ImGui::End();
}
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImColor(0, 0, 0, 180).Value);
ImGui::PushStyleColor(ImGuiCol_Border, ImColor(0, 0, 0, 0).Value);
ImGui::PositionNextWindow(glm::vec2(viewport.z, hud_height),
ImGui::WindowPosition_X::center,
ImGui::WindowPosition_Y::bottom);
if(ImGui::Begin("beat",
nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize
| ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoInputs)) {
| ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoScrollbar)) {
ImGui::PushStyleColor(ImGuiCol_Border, "#00000000"_imcolor.Value); // Hide Border
ImVec2 cursor = ImGui::GetCursorScreenPos();
cursor.y += hud_height / 2.f - 10;
cursor.y += hud_height / 2.f + 10;
auto beat_state = _beat_system.beat_state();
auto beats = _beat_system.time_stamps();
auto beat_index = _beat_system.beat_index() + 1;
//auto line_offset = bar_speed * beat_state.avg_beat_time;
//auto beats = std::clamp(beat_state.beats_left, 0, 5);
ImGui::BeginChild("Line", {viewport.z, bar_height}, true);
ImGui::BeginChild("Line", {viewport.z, hud_height}, true);
ImDrawList* drawList = ImGui::GetWindowDrawList();
while(beat_index < static_cast<int>(beats.size())) {
......@@ -75,10 +64,10 @@ namespace phase_shifter::ui {
auto bar_color = beat_index < static_cast<int>(beats.size() * 0.8f) ? 0xFFFFFFFF : 0xFF0000FF;
ImVec2 p(cursor.x + viewport.z / 2 - x_offset, cursor.y - height / 2.f);
drawList->AddLine(p, {p.x, p.y + height}, bar_color, 1);
drawList->AddLine(p, {p.x, p.y + height}, bar_color, 2);
p.x = cursor.x + viewport.z / 2 + x_offset;
drawList->AddLine(p, {p.x, p.y + height}, bar_color, 1);
drawList->AddLine(p, {p.x, p.y + height}, bar_color, 2);
if(x_offset > beat_bar_length + 50) {
break;
......@@ -87,7 +76,18 @@ namespace phase_shifter::ui {
}
ImVec2 middle(cursor.x + viewport.z / 2, cursor.y - bar_height / 2.f);
drawList->AddLine(middle, {middle.x, middle.y + bar_height}, 0xFFFF0000, 4);
drawList->AddLine(middle, {middle.x, middle.y + bar_height}, 0xFFFF0000, 6);
auto beat_color = (_beat_system.beat_state().beats_left < 50
&& _beat_system.beat_state().beats_left % 2 == 0)
? ImColor(255, 0, 0)
: ImColor(255, 255, 255);
auto beats_left = std::to_string(_beat_system.beat_state().beats_left);
auto text_size = ImGui::CalcTextSize(beats_left.c_str());
drawList->AddText(ImVec2(middle.x - text_size.x / 2.f, middle.y - text_size.y - 10),
beat_color,
beats_left.c_str());
ImGui::EndChild();
ImGui::PopStyleColor();
......@@ -102,6 +102,9 @@ namespace phase_shifter::ui {
}
}
ImGui::PopStyleColor();
ImGui::PopStyleColor();
if(font.is_some())
ImGui::PopFont();
}
......
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