mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Serialized all env settings now
This commit is contained in:
@@ -903,7 +903,7 @@ namespace Nuake {
|
||||
ImGui::TableSetupColumn("set", 0, 0.6);
|
||||
ImGui::TableSetupColumn("reset", 0, 0.1);
|
||||
|
||||
SSR* ssr = scene->m_SceneRenderer->mSSR.get();
|
||||
SSR* ssr = env->mSSR.get();
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
// Title
|
||||
@@ -1112,7 +1112,6 @@ namespace Nuake {
|
||||
ImGui::TableSetupColumn("name", 0, 0.3);
|
||||
ImGui::TableSetupColumn("set", 0, 0.6);
|
||||
ImGui::TableSetupColumn("reset", 0, 0.1);
|
||||
|
||||
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace Nuake
|
||||
mShadingBuffer = CreateScope<FrameBuffer>(true, defaultResolution);
|
||||
mShadingBuffer->SetTexture(CreateRef<Texture>(defaultResolution, GL_RGB, GL_RGB16F, GL_FLOAT));
|
||||
|
||||
mSSR = CreateScope<SSR>();
|
||||
mToneMapBuffer = CreateScope<FrameBuffer>(false, defaultResolution);
|
||||
mToneMapBuffer->SetTexture(CreateRef<Texture>(defaultResolution, GL_RGB), GL_COLOR_ATTACHMENT0);
|
||||
|
||||
@@ -152,8 +151,8 @@ namespace Nuake
|
||||
|
||||
if (sceneEnv->SSREnabled)
|
||||
{
|
||||
mSSR->Resize(framebuffer.GetSize());
|
||||
mSSR->Draw(mGBuffer.get(), framebuffer.GetTexture(), mView, mProjection, scene.GetCurrentCamera());
|
||||
sceneEnv->mSSR->Resize(framebuffer.GetSize());
|
||||
sceneEnv->mSSR->Draw(mGBuffer.get(), framebuffer.GetTexture(), mView, mProjection, scene.GetCurrentCamera());
|
||||
|
||||
framebuffer.Bind();
|
||||
{
|
||||
@@ -162,7 +161,7 @@ namespace Nuake
|
||||
shader->Bind();
|
||||
|
||||
shader->SetUniformTex("u_Source", mToneMapBuffer->GetTexture().get(), 0);
|
||||
shader->SetUniformTex("u_Source2", mSSR->OutputFramebuffer->GetTexture().get(), 1);
|
||||
shader->SetUniformTex("u_Source2", sceneEnv->mSSR->OutputFramebuffer->GetTexture().get(), 1);
|
||||
Renderer::DrawQuad();
|
||||
}
|
||||
framebuffer.Unbind();
|
||||
|
||||
@@ -19,8 +19,6 @@ namespace Nuake
|
||||
void BeginRenderScene(const Matrix4& projection, const Matrix4& view, const Vector3& camPos);
|
||||
void RenderScene(Scene& scene, FrameBuffer& framebuffer);
|
||||
|
||||
Scope<SSR> mSSR;
|
||||
|
||||
FrameBuffer& GetGBuffer() const
|
||||
{
|
||||
return *mGBuffer;
|
||||
|
||||
@@ -1,16 +1,46 @@
|
||||
#pragma once
|
||||
#include "Environment.h"
|
||||
#include "src/Rendering/Renderer.h"
|
||||
|
||||
#include "src/Core/Core.h"
|
||||
|
||||
|
||||
namespace Nuake {
|
||||
|
||||
Environment::Environment()
|
||||
{
|
||||
m_AmbientColor = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
ProceduralSkybox = CreateRef<ProceduralSky>();
|
||||
|
||||
CurrentSkyType = SkyType::ProceduralSky;
|
||||
AmbientColor = Color(0.2, 0.2, 0.2, 1.0f);
|
||||
AmbientTerm = 0.5f;
|
||||
|
||||
VolumetricEnabled = true;
|
||||
VolumetricFog = 0.9f;
|
||||
VolumetricStepCount = 50.0f;
|
||||
|
||||
// Bloom
|
||||
BloomEnabled = true;
|
||||
SSAOEnabled = true;
|
||||
SSREnabled = true;
|
||||
|
||||
// DOF
|
||||
DOFEnabled = false;
|
||||
BarrelDistortionEnabled = false;
|
||||
BarrelDistortion = 0.0f;
|
||||
BarrelEdgeDistortion = 0.0f;
|
||||
BarrelScale = 1.0f;
|
||||
|
||||
// Vignette
|
||||
VignetteEnabled = false;
|
||||
VignetteIntensity = 150.0f;
|
||||
VignetteExtend = 0.150f;
|
||||
|
||||
// POST FX
|
||||
mBloom = CreateScope<Bloom>(4);
|
||||
mVolumetric = CreateScope<Volumetric>();
|
||||
mSSAO = CreateScope<SSAO>();
|
||||
mSSR = CreateScope<SSR>();
|
||||
}
|
||||
|
||||
glm::vec4 Environment::GetAmbientColor()
|
||||
@@ -23,12 +53,6 @@ namespace Nuake {
|
||||
m_AmbientColor = color;
|
||||
}
|
||||
|
||||
void Environment::Push()
|
||||
{
|
||||
Renderer::m_Shader->SetUniform1f("u_FogAmount", VolumetricFog);
|
||||
Renderer::m_Shader->SetUniform1f("u_FogStepCount", VolumetricStepCount);
|
||||
}
|
||||
|
||||
Ref<Environment> Environment::Copy()
|
||||
{
|
||||
Ref<Environment> copy = CreateRef<Environment>();
|
||||
@@ -52,29 +76,234 @@ namespace Nuake {
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
SERIALIZE_VAL(CurrentSkyType);
|
||||
SERIALIZE_VEC4(AmbientColor);
|
||||
|
||||
// Bloom
|
||||
SERIALIZE_VAL(BloomEnabled);
|
||||
SERIALIZE_VAL_LBL("BloomThreshold", mBloom->GetThreshold());
|
||||
SERIALIZE_VAL_LBL("BloomIteration", mBloom->GetIteration());
|
||||
|
||||
// Volumetric
|
||||
SERIALIZE_VAL(VolumetricEnabled);
|
||||
SERIALIZE_VAL(VolumetricFog);
|
||||
SERIALIZE_VAL(VolumetricStepCount);
|
||||
|
||||
// SSR
|
||||
SERIALIZE_VAL(SSREnabled);
|
||||
SERIALIZE_VAL_LBL("SSRRayStep", mSSR->RayStep);
|
||||
SERIALIZE_VAL_LBL("SSRIterationCount", mSSR->IterationCount);
|
||||
SERIALIZE_VAL_LBL("SSRDistanceBias", mSSR->DistanceBias);
|
||||
SERIALIZE_VAL_LBL("SSRSampleCount", mSSR->SampleCount);
|
||||
SERIALIZE_VAL_LBL("SSRSamplingEnabled", mSSR->SamplingEnabled);
|
||||
SERIALIZE_VAL_LBL("SSRExpoStep", mSSR->ExpoStep);
|
||||
SERIALIZE_VAL_LBL("SSRAdaptiveStep", mSSR->AdaptiveStep);
|
||||
SERIALIZE_VAL_LBL("SSRBinarySearch", mSSR->BinarySearch);
|
||||
SERIALIZE_VAL_LBL("SSRSampleingCoefficient", mSSR->SampleingCoefficient);
|
||||
|
||||
// SSAO
|
||||
SERIALIZE_VAL(SSAOEnabled);
|
||||
SERIALIZE_VAL_LBL("SSAORadius", mSSAO->Radius);
|
||||
SERIALIZE_VAL_LBL("SSAOBias", mSSAO->Bias);
|
||||
SERIALIZE_VAL_LBL("SSAOArea", mSSAO->Area);
|
||||
SERIALIZE_VAL_LBL("SSAOFalloff", mSSAO->Falloff);
|
||||
SERIALIZE_VAL_LBL("SSAOStrength", mSSAO->Strength);
|
||||
|
||||
// DOF
|
||||
SERIALIZE_VAL(DOFEnabled);
|
||||
|
||||
// Barrel distortion
|
||||
SERIALIZE_VAL(BarrelDistortionEnabled);
|
||||
SERIALIZE_VAL(BarrelDistortion);
|
||||
SERIALIZE_VAL(BarrelEdgeDistortion);
|
||||
SERIALIZE_VAL(BarrelScale);
|
||||
|
||||
// Vignette
|
||||
SERIALIZE_VAL(VignetteEnabled);
|
||||
SERIALIZE_VAL(VignetteExtend);
|
||||
SERIALIZE_VAL(VignetteIntensity);
|
||||
|
||||
SERIALIZE_VAL(AmbientTerm);
|
||||
SERIALIZE_VEC4(AmbientColor);
|
||||
|
||||
SERIALIZE_OBJECT(ProceduralSkybox);
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
bool Environment::Deserialize(const json& j)
|
||||
{
|
||||
// SKY
|
||||
if (j.contains("CurrentSkyType"))
|
||||
{
|
||||
CurrentSkyType = j["CurrentSkyType"];
|
||||
if (j.contains("AmbientColor"))
|
||||
DESERIALIZE_VEC4(j["AmbientColor"], AmbientColor);
|
||||
if (j.contains("VolumetricFog"))
|
||||
VolumetricFog = j["VolumetricFog"];
|
||||
if (j.contains("VolumetricStepCount"))
|
||||
VolumetricStepCount = j["VolumetricStepCount"];
|
||||
}
|
||||
|
||||
if (j.contains("ProceduralSkybox"))
|
||||
{
|
||||
ProceduralSkybox->Deserialize(j["ProceduralSkybox"]);
|
||||
}
|
||||
|
||||
|
||||
// Ambient
|
||||
if (j.contains("AmbientTerm"))
|
||||
{
|
||||
AmbientTerm = j["AmbientTerm"];
|
||||
}
|
||||
|
||||
if (j.contains("AmbientColor"))
|
||||
{
|
||||
DESERIALIZE_VEC4(j["AmbientColor"], AmbientColor);
|
||||
}
|
||||
|
||||
// Bloom
|
||||
if (j.contains("BloomEnabled"))
|
||||
{
|
||||
BloomEnabled = j["BloomEnabled"];
|
||||
}
|
||||
|
||||
if (j.contains("BloomThreshold"))
|
||||
{
|
||||
mBloom->SetThreshold(j["BloomThreshold"]);
|
||||
}
|
||||
|
||||
if (j.contains("BloomIteration"))
|
||||
{
|
||||
mBloom->SetIteration(j["BloomIteration"]);
|
||||
}
|
||||
|
||||
// SSR
|
||||
if (j.contains("SSREnabled"))
|
||||
{
|
||||
SSREnabled = j["SSREnabled"];
|
||||
}
|
||||
|
||||
if (j.contains("SSRRayStep"))
|
||||
{
|
||||
mSSR->RayStep = j["SSRRayStep"];
|
||||
}
|
||||
|
||||
if (j.contains("SSRIterationCount"))
|
||||
{
|
||||
mSSR->IterationCount = j["SSRIterationCount"];
|
||||
}
|
||||
|
||||
if (j.contains("SSRDistanceBias"))
|
||||
{
|
||||
mSSR->DistanceBias = j["SSRDistanceBias"];
|
||||
}
|
||||
|
||||
if (j.contains("SSRSampleCount"))
|
||||
{
|
||||
mSSR->SampleCount = j["SSRSampleCount"];
|
||||
}
|
||||
|
||||
if (j.contains("SSRSamplingEnabled"))
|
||||
{
|
||||
mSSR->SamplingEnabled = j["SSRSamplingEnabled"];
|
||||
}
|
||||
|
||||
if (j.contains("SSRExpoStep"))
|
||||
{
|
||||
mSSR->ExpoStep = j["SSRExpoStep"];
|
||||
}
|
||||
|
||||
if (j.contains("SSRAdaptiveStep"))
|
||||
{
|
||||
mSSR->AdaptiveStep = j["SSRAdaptiveStep"];
|
||||
}
|
||||
|
||||
if (j.contains("SSRBinarySearch"))
|
||||
{
|
||||
mSSR->BinarySearch = j["SSRBinarySearch"];
|
||||
}
|
||||
|
||||
if (j.contains("SSRSampleingCoefficient"))
|
||||
{
|
||||
mSSR->SampleingCoefficient = j["SSRSampleingCoefficient"];
|
||||
}
|
||||
|
||||
// Volumetric
|
||||
if (j.contains("VolumetricEnabled"))
|
||||
{
|
||||
VolumetricEnabled = j["VolumetricEnabled"];
|
||||
}
|
||||
|
||||
if (j.contains("VolumetricFog"))
|
||||
{
|
||||
VolumetricFog = j["VolumetricFog"];
|
||||
}
|
||||
|
||||
if (j.contains("VolumetricStepCount"))
|
||||
{
|
||||
VolumetricStepCount = j["VolumetricStepCount"];
|
||||
}
|
||||
|
||||
// SSAO
|
||||
if (j.contains("SSAOEnabled"))
|
||||
{
|
||||
SSAOEnabled = j["SSAOEnabled"];
|
||||
}
|
||||
|
||||
if (j.contains("SSAORadius"))
|
||||
{
|
||||
mSSAO->Radius = j["SSAORadius"];
|
||||
}
|
||||
|
||||
if (j.contains("SSAOBias"))
|
||||
{
|
||||
mSSAO->Bias = j["SSAOBias"];
|
||||
}
|
||||
|
||||
if (j.contains("SSAOArea"))
|
||||
{
|
||||
mSSAO->Area = j["SSAOArea"];
|
||||
}
|
||||
|
||||
if (j.contains("SSAOFalloff"))
|
||||
{
|
||||
mSSAO->Falloff = j["SSAOFalloff"];
|
||||
}
|
||||
|
||||
if (j.contains("SSAOStrength"))
|
||||
{
|
||||
mSSAO->Strength = j["SSAOStrength"];
|
||||
}
|
||||
|
||||
// DOF
|
||||
if (j.contains("DOFEnabled"))
|
||||
{
|
||||
DOFEnabled = j["DOFEnabled"];
|
||||
}
|
||||
|
||||
// Barrel distortion
|
||||
if (j.contains("BarrelDistortionEnabled"))
|
||||
{
|
||||
BarrelDistortionEnabled = j["BarrelDistortionEnabled"];
|
||||
}
|
||||
|
||||
if (j.contains("BarrelEdgeDistortion"))
|
||||
{
|
||||
BarrelEdgeDistortion = j["BarrelEdgeDistortion"];
|
||||
}
|
||||
|
||||
if (j.contains("BarrelScale"))
|
||||
{
|
||||
BarrelScale = j["BarrelScale"];
|
||||
}
|
||||
|
||||
// Vignette
|
||||
if (j.contains("VignetteEnabled"))
|
||||
{
|
||||
VignetteEnabled = j["VignetteEnabled"];
|
||||
}
|
||||
|
||||
if (j.contains("VignetteExtend"))
|
||||
{
|
||||
VignetteExtend = j["VignetteExtend"];
|
||||
}
|
||||
|
||||
if (j.contains("VignetteIntensity"))
|
||||
{
|
||||
VignetteIntensity = j["VignetteIntensity"];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,14 @@
|
||||
#include "src/Rendering/PostFX/Bloom.h"
|
||||
#include "src/Rendering/PostFX/Volumetric.h"
|
||||
#include "src/Rendering/PostFX/SSAO.h"
|
||||
#include "src/Rendering/PostFX/SSR.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
enum class SkyType {
|
||||
enum class SkyType
|
||||
{
|
||||
ProceduralSky = 0,
|
||||
ClearColor = 1
|
||||
// CubeMap
|
||||
@@ -23,27 +25,27 @@ namespace Nuake
|
||||
public:
|
||||
Environment();
|
||||
|
||||
SkyType CurrentSkyType = SkyType::ProceduralSky;
|
||||
|
||||
Color AmbientColor = Color(0, 0, 0, 1);
|
||||
SkyType CurrentSkyType;
|
||||
Ref<ProceduralSky> ProceduralSkybox;
|
||||
|
||||
bool VolumetricEnabled = true;
|
||||
float VolumetricFog = 0.90f;
|
||||
float VolumetricStepCount = 50.f;
|
||||
Color AmbientColor;
|
||||
|
||||
float AmbientTerm = 0.5f;
|
||||
bool VolumetricEnabled;
|
||||
float VolumetricFog;
|
||||
float VolumetricStepCount;
|
||||
|
||||
float AmbientTerm;
|
||||
float Exposure = 3.5f;
|
||||
float Gamma = 1.1f;
|
||||
|
||||
bool BloomEnabled = true;
|
||||
Scope<Bloom> mBloom;
|
||||
Scope<Volumetric> mVolumetric;
|
||||
|
||||
bool SSAOEnabled = true;
|
||||
Scope<SSAO> mSSAO;
|
||||
|
||||
bool SSREnabled = true;
|
||||
Scope<SSR> mSSR;
|
||||
|
||||
bool DOFEnabled = false;
|
||||
|
||||
@@ -62,8 +64,6 @@ namespace Nuake
|
||||
glm::vec4 GetAmbientColor();
|
||||
void SetAmbientColor(glm::vec4 color);
|
||||
|
||||
void Push();
|
||||
|
||||
Ref<Environment> Copy();
|
||||
|
||||
json Serialize() override;
|
||||
|
||||
Reference in New Issue
Block a user