Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 70 additions & 126 deletions include/dz/ECS.hpp

Large diffs are not rendered by default.

19 changes: 8 additions & 11 deletions include/dz/ECS/Camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,18 +417,20 @@ void GetCameraModel(int camera_index, out mat4 out_model, out int parent_index,
for (auto& shader : shader_vec)
shader_set_render_pass(shader, framebuffer);
}
bool backup(Serial& serial) const override {
if (!backup_internal(serial))
return false;
bool backup_virtual(Serial& serial) const override {
serial << name << imgui_name;
return true;
}
bool restore(Serial& serial) override {
if (!restore_internal(serial))
return false;
bool restore_virtual(Serial& serial) override {
serial >> name >> imgui_name;
return true;
}


template<typename TECS>
void Initialize(TECS& ecs, dz::ecs::Camera& camera) {
camera.Initialize();
}
};

using ReflectableGroup = CameraReflectableGroup;
Expand All @@ -445,11 +447,6 @@ void GetCameraModel(int camera_index, out mat4 out_model, out int parent_index,
default: break;
}
}

template<typename TECS>
void Initialize(TECS& ecs, ::ReflectableGroup& camera_group) {
Initialize();
}
};

}
8 changes: 2 additions & 6 deletions include/dz/ECS/Entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,15 @@ void GetEntityModel(int entity_index, out mat4 out_model, out int parent_index,
reflectables.push_back(component_reflectable_ptr);
}
}
bool backup(Serial& serial) const override {
if (!backup_internal(serial))
return false;
bool backup_virtual(Serial& serial) const override {
serial << name;
if (!BackupGroupVector(serial, reflectable_children))
return false;
if (!BackupGroupVector(serial, component_groups))
return false;
return true;
}
bool restore(Serial& serial) override {
if (!restore_internal(serial))
return false;
bool restore_virtual(Serial& serial) override {
serial >> name;
if (!RestoreGroupVector(serial, reflectable_children, buffer_group))
return false;
Expand Down
56 changes: 56 additions & 0 deletions include/dz/ECS/GammaCorrection.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#pragma once
#include "Provider.hpp"
#include "../Reflectable.hpp"
#include "../Shader.hpp"
namespace dz::ecs {
struct GammaCorrection : Provider<GammaCorrection> {
inline static constexpr size_t PID = 12;
inline static float Priority = 1000.0f;
inline static constexpr BufferHost BufferHostType = BufferHost::NoBuffer;
inline static std::string ProviderName = "GammaCorrection";
inline static std::string StructName = "GammaCorrection";
inline static std::unordered_map<ShaderModuleType, std::string> GLSLMethods = {
{ShaderModuleType::Fragment, R"(
vec3 LinearToSRGBAccurate(in vec3 linearColor)
{
vec3 srgbLow = linearColor * 12.92;
vec3 srgbHigh = pow(linearColor, vec3(1.0 / 2.4)) * 1.055 - 0.055;
bvec3 cutoff = lessThanEqual(linearColor, vec3(0.0031308));
return mix(srgbHigh, srgbLow, cutoff);
}
)" }
};
inline static std::vector<std::tuple<float, std::string, ShaderModuleType>> GLSLMain = {
{1000.0f, R"(
current_color = vec4(LinearToSRGBAccurate(vec3(current_color)), 1.0);
)", ShaderModuleType::Fragment}
};

struct GammaCorrectionReflectableGroup : ::ReflectableGroup {
std::string name;
GammaCorrectionReflectableGroup(BufferGroup* buffer_group):
name("GammaCorrection")
{}
GammaCorrectionReflectableGroup(BufferGroup* buffer_group, Serial& serial)
{
restore(serial);
}
GroupType GetGroupType() override {
return ReflectableGroup::Generic;
}
std::string& GetName() override {
return name;
}
bool backup_virtual(Serial& serial) const override {
serial << name;
return true;
}
bool restore_virtual(Serial& serial) override {
serial >> name;
return true;
}
};

using ReflectableGroup = GammaCorrectionReflectableGroup;
};
}
Loading
Loading