From cf8e4dbadca32b7b54e7d108f67b1a5d10ed6759 Mon Sep 17 00:00:00 2001 From: Silverlan Date: Sun, 12 Jan 2025 20:31:38 +0100 Subject: [PATCH] feat: remove glow render pass Emissions are now handled via scene shaders. --- .../shaders/programs/post_processing/hdr.frag | 7 - assets/shaders/programs/scene/glow/glow.frag | 16 - assets/shaders/programs/scene/glow/glow.glsl | 16 - assets/shaders/programs/scene/glow/glow.vert | 28 -- .../include/pragma/console/c_cvar_global.h | 1 - .../pragma/console/c_cvar_global_functions.h | 1 - .../components/c_raytracing_component.hpp | 2 +- .../c_rasterization_renderer_component.hpp | 3 - .../c_renderer_pp_glow_component.hpp | 56 ---- .../renderers/rasterization/glow_data.hpp | 46 --- .../pragma/gui/debug/widebugglowbloom.hpp | 25 -- .../include/pragma/rendering/c_renderflags.h | 3 +- .../include/pragma/rendering/c_rendermode.h | 2 +- .../post_processing/c_shader_pp_glow.hpp | 41 --- .../post_processing/c_shader_pp_hdr.hpp | 8 +- .../rendering/shaders/world/c_shader_glow.hpp | 72 ----- core/client/src/console/c_cvar_glowmap.cpp | 37 --- .../renderers/c_renderer_component.cpp | 2 - .../c_renderer_pp_glow_component.cpp | 287 ------------------ .../c_renderer_pp_tone_mapping_component.cpp | 3 +- .../renderers/rasterization/bloom.cpp | 4 +- .../renderers/rasterization/glow_data.cpp | 55 ---- .../renderers/rasterization/render_core.cpp | 2 - core/client/src/game/c_game_components.cpp | 2 - .../client/src/gui/debug/widebugglowbloom.cpp | 83 ----- core/client/src/lua/c_lentity_components2.cpp | 10 - core/client/src/lua/c_lua.cpp | 30 +- core/client/src/lua/c_luaclass.cpp | 5 - core/client/src/rendering/c_render.cpp | 4 +- .../renderers/rasterization_renderer.cpp | 1 - .../src/rendering/scene/scene_render_desc.cpp | 24 +- .../src/rendering/shaders/c_shaders.cpp | 4 - .../post_processing/c_shader_pp_glow.cpp | 74 ----- .../post_processing/c_shader_pp_hdr.cpp | 11 +- .../rendering/shaders/world/c_shader_glow.cpp | 239 --------------- 35 files changed, 34 insertions(+), 1170 deletions(-) delete mode 100644 assets/shaders/programs/scene/glow/glow.frag delete mode 100644 assets/shaders/programs/scene/glow/glow.glsl delete mode 100644 assets/shaders/programs/scene/glow/glow.vert delete mode 100644 core/client/include/pragma/entities/components/renderers/c_renderer_pp_glow_component.hpp delete mode 100644 core/client/include/pragma/entities/components/renderers/rasterization/glow_data.hpp delete mode 100644 core/client/include/pragma/gui/debug/widebugglowbloom.hpp delete mode 100644 core/client/include/pragma/rendering/shaders/post_processing/c_shader_pp_glow.hpp delete mode 100644 core/client/include/pragma/rendering/shaders/world/c_shader_glow.hpp delete mode 100644 core/client/src/console/c_cvar_glowmap.cpp delete mode 100644 core/client/src/entities/components/renderers/c_renderer_pp_glow_component.cpp delete mode 100644 core/client/src/entities/components/renderers/rasterization/glow_data.cpp delete mode 100644 core/client/src/gui/debug/widebugglowbloom.cpp delete mode 100644 core/client/src/rendering/shaders/post_processing/c_shader_pp_glow.cpp delete mode 100644 core/client/src/rendering/shaders/world/c_shader_glow.cpp diff --git a/assets/shaders/programs/post_processing/hdr.frag b/assets/shaders/programs/post_processing/hdr.frag index e948696b4..3dbaf9418 100644 --- a/assets/shaders/programs/post_processing/hdr.frag +++ b/assets/shaders/programs/post_processing/hdr.frag @@ -7,13 +7,11 @@ layout(location = 0) in vec2 vs_vert_uv; layout(LAYOUT_ID(TEXTURES, SCENE)) uniform sampler2D u_texture; layout(LAYOUT_ID(TEXTURES, BLOOM)) uniform sampler2D u_bloom; -layout(LAYOUT_ID(TEXTURES, GLOW)) uniform sampler2D u_glow; layout(LAYOUT_PUSH_CONSTANTS()) uniform RenderSettings { float exposure; float bloomScale; - float glowScale; // Obsolete uint toneMapping; uint flipVertically; } @@ -25,7 +23,6 @@ layout(location = 0) out vec4 fs_color; layout(constant_id = 0) const uint CSPEC_BLOOM_ENABLED = 1; layout(constant_id = 1) const uint CSPEC_FXAA_ENABLED = 1; -layout(constant_id = 2) const uint CSPEC_GLOW_ENABLED = 0; void main() { @@ -37,10 +34,6 @@ void main() vec3 colBloom = texture(u_bloom, uv).rgb; col.rgb += colBloom * u_renderSettings.bloomScale; } - if(CSPEC_GLOW_ENABLED == 1) { - vec3 colGlow = texture(u_glow, uv).rgb; - col.rgb += colGlow; - } fs_color = vec4(apply_tone_mapping(col.rgb, u_renderSettings.toneMapping, u_renderSettings.exposure), col.a); if(CSPEC_FXAA_ENABLED == 1) diff --git a/assets/shaders/programs/scene/glow/glow.frag b/assets/shaders/programs/scene/glow/glow.frag deleted file mode 100644 index d8d774422..000000000 --- a/assets/shaders/programs/scene/glow/glow.frag +++ /dev/null @@ -1,16 +0,0 @@ -#version 440 - -#include "glow.glsl" - -vec4 get_glow_map_color() { return texture(u_glowMap, fs_in.vert_uv).rgba; } - -layout(LAYOUT_PUSH_CONSTANTS()) uniform pushConstants { float glowScale; } -u_pushConstants; - -layout(location = 0) out vec4 fs_color; - -void main() -{ - fs_color = get_glow_map_color(); - fs_color.rgb *= u_pushConstants.glowScale; -} diff --git a/assets/shaders/programs/scene/glow/glow.glsl b/assets/shaders/programs/scene/glow/glow.glsl deleted file mode 100644 index 690eec823..000000000 --- a/assets/shaders/programs/scene/glow/glow.glsl +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef F_SH_GLOW_GLS -#define F_SH_GLOW_GLS - -#define SHADER_VERTEX_DATA_LOCATION 0 - -#include "/common/export.glsl" - -layout(location = 4) EXPORT_VS VS_OUT { vec2 vert_uv; } -#ifdef GLS_FRAGMENT_SHADER -fs_in -#else -vs_out -#endif - ; - -#endif diff --git a/assets/shaders/programs/scene/glow/glow.vert b/assets/shaders/programs/scene/glow/glow.vert deleted file mode 100644 index d58234c4e..000000000 --- a/assets/shaders/programs/scene/glow/glow.vert +++ /dev/null @@ -1,28 +0,0 @@ -#version 440 - -#extension GL_ARB_separate_shader_objects : enable -#extension GL_ARB_shading_language_420pack : enable - -#define SHADER_BONE_WEIGHT_ID_LOCATION 1 -#define SHADER_BONE_WEIGHT_LOCATION (SHADER_BONE_WEIGHT_ID_LOCATION + 1) - -#define SHADER_BONE_WEIGHT_EXT_ID_LOCATION (SHADER_BONE_WEIGHT_LOCATION + 1) -#define SHADER_BONE_WEIGHT_EXT_LOCATION (SHADER_BONE_WEIGHT_EXT_ID_LOCATION + 1) - -#define SHADER_VERTEX_BUFFER_LOCATION (SHADER_BONE_WEIGHT_EXT_LOCATION + 1) - -#include "glow.glsl" -#include "/common/inputs/vs_skeletal_animation.glsl" -#include "/common/inputs/camera.glsl" -#include "/common/inputs/entity.glsl" - -layout(location = SHADER_VERTEX_BUFFER_LOCATION) in vec3 in_vert_pos; -layout(location = SHADER_UV_BUFFER_LOCATION) in vec2 in_vert_uv; - -void main() -{ - vec4 vpos = get_weighted_vertex_position(is_weighted(), vec4(in_vert_pos, 1.0)); - mat4 MVP = get_view_projection_matrix() * get_model_matrix(); - gl_Position = MVP * vpos; - vs_out.vert_uv = in_vert_uv; -} diff --git a/core/client/include/pragma/console/c_cvar_global.h b/core/client/include/pragma/console/c_cvar_global.h index aea3fe69d..f5f7cf4d4 100644 --- a/core/client/include/pragma/console/c_cvar_global.h +++ b/core/client/include/pragma/console/c_cvar_global.h @@ -32,7 +32,6 @@ REGISTER_CONCOMMAND_CL(shader_reload, CMD_shader_reload, ConVarFlags::None, "Rel REGISTER_CONCOMMAND_CL(shader_list, CMD_shader_list, ConVarFlags::None, "Prints a list of all currently loaded shaders"); REGISTER_CONCOMMAND_CL(shader_optimize, CMD_shader_optimize, ConVarFlags::None, "Uses LunarGLASS to optimize the specified shader."); REGISTER_CONCOMMAND_CL(debug_light_shadowmap, CMD_debug_light_shadowmap, ConVarFlags::None, "Displays the depth map for the given light on screen. Call without arguments to turn the display off. Usage: debug_light_shadowmap "); -REGISTER_CONCOMMAND_CL(debug_glow_bloom, CMD_debug_glow_bloom, ConVarFlags::None, "Displays the scene glow texture on screen. Usage: debug_glow_bloom <1/0>"); REGISTER_CONCOMMAND_CL(debug_hdr_bloom, CMD_debug_hdr_bloom, ConVarFlags::None, "Displays the scene bloom texture on screen. Usage: debug_hdr_bloom <1/0>"); REGISTER_CONCOMMAND_CL(debug_render_octree_dynamic_print, CMD_debug_render_octree_dynamic_print, ConVarFlags::None, "Prints the octree for dynamic objects to the console, or a file if a file name is specified."); REGISTER_CONCOMMAND_CL(debug_render_octree_dynamic_find, CMD_debug_render_octree_dynamic_find, ConVarFlags::None, "Finds the specified entity in the octree for dynamic objects."); diff --git a/core/client/include/pragma/console/c_cvar_global_functions.h b/core/client/include/pragma/console/c_cvar_global_functions.h index dd553bff1..033cd0944 100644 --- a/core/client/include/pragma/console/c_cvar_global_functions.h +++ b/core/client/include/pragma/console/c_cvar_global_functions.h @@ -28,7 +28,6 @@ DLLCLIENT void CMD_shader_reload(NetworkState *state, pragma::BasePlayerComponen DLLCLIENT void CMD_shader_list(NetworkState *state, pragma::BasePlayerComponent *pl, std::vector &argv); DLLCLIENT void CMD_shader_optimize(NetworkState *state, pragma::BasePlayerComponent *pl, std::vector &argv); DLLCLIENT void CMD_debug_light_shadowmap(NetworkState *state, pragma::BasePlayerComponent *pl, std::vector &argv); -DLLCLIENT void CMD_debug_glow_bloom(NetworkState *state, pragma::BasePlayerComponent *pl, std::vector &argv); DLLCLIENT void CMD_debug_hdr_bloom(NetworkState *state, pragma::BasePlayerComponent *pl, std::vector &argv); DLLCLIENT void CMD_debug_render_octree_dynamic_print(NetworkState *state, pragma::BasePlayerComponent *pl, std::vector &argv); DLLCLIENT void CMD_debug_render_octree_dynamic_find(NetworkState *state, pragma::BasePlayerComponent *pl, std::vector &argv); diff --git a/core/client/include/pragma/entities/components/c_raytracing_component.hpp b/core/client/include/pragma/entities/components/c_raytracing_component.hpp index 9f2c9d6ee..1c0d91056 100644 --- a/core/client/include/pragma/entities/components/c_raytracing_component.hpp +++ b/core/client/include/pragma/entities/components/c_raytracing_component.hpp @@ -41,7 +41,7 @@ namespace pragma { UseNormalMap = RenderModeSkybox << 1u }; - static_assert(umath::to_integral(pragma::rendering::SceneRenderPass::Count) == 5); + static_assert(umath::to_integral(pragma::rendering::SceneRenderPass::Count) == 4); // Bounds for the sub-mesh. w-component is unused. Vector4 aabbMin = {}; Vector4 aabbMax = {}; diff --git a/core/client/include/pragma/entities/components/renderers/c_rasterization_renderer_component.hpp b/core/client/include/pragma/entities/components/renderers/c_rasterization_renderer_component.hpp index aba9fa992..b693f9e44 100644 --- a/core/client/include/pragma/entities/components/renderers/c_rasterization_renderer_component.hpp +++ b/core/client/include/pragma/entities/components/renderers/c_rasterization_renderer_component.hpp @@ -12,9 +12,6 @@ #include #include "pragma/entities/c_baseentity.h" #include "pragma/rendering/renderers/base_renderer.hpp" -#include "pragma/entities/components/renderers/rasterization/glow_data.hpp" -#include "pragma/entities/components/renderers/rasterization/hdr_data.hpp" -#include "pragma/entities/components/renderers/rasterization/glow_data.hpp" #include "pragma/entities/components/renderers/rasterization/hdr_data.hpp" #include "pragma/rendering/c_rendermode.h" #include diff --git a/core/client/include/pragma/entities/components/renderers/c_renderer_pp_glow_component.hpp b/core/client/include/pragma/entities/components/renderers/c_renderer_pp_glow_component.hpp deleted file mode 100644 index 2a8f8803e..000000000 --- a/core/client/include/pragma/entities/components/renderers/c_renderer_pp_glow_component.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (c) 2021 Silverlan - */ - -#ifndef __C_RENDERER_PP_GLOW_COMPONENT_HPP__ -#define __C_RENDERER_PP_GLOW_COMPONENT_HPP__ - -#include "pragma/entities/components/renderers/c_renderer_pp_base_component.hpp" -#include "pragma/entities/components/renderers/c_renderer_component.hpp" -#include "pragma/rendering/shaders/post_processing/c_shader_pp_bloom_blur.hpp" -#include "pragma/rendering/controlled_blur_settings.hpp" - -namespace pragma { - class CRasterizationRendererComponent; - class DLLCLIENT CRendererPpGlowComponent final : public CRendererPpBaseComponent { - public: - static void RegisterMembers(pragma::EntityComponentManager &componentManager, TRegisterComponentMember registerMember); - CRendererPpGlowComponent(BaseEntity &ent); - - void SetBlurRadius(uint32_t radius); - void SetBlurSigma(double sigma); - uint32_t GetBlurRadius() const; - double GetBlurSigma() const; - - void SetBlurAmount(int32_t blurAmount); - int32_t GetBlurAmount() const; - - prosper::Texture &GetGlowTexture(); - - virtual void Initialize() override; - virtual void InitializeLuaObject(lua_State *l) override; - virtual std::string GetIdentifier() const override { return "glow"; } - virtual uint32_t GetPostProcessingWeight() const override { return umath::to_integral(CRendererComponent::StandardPostProcessingWeight::Bloom); } - - virtual void OnTick(double dt) override; - private: - void SetPipelineDirty(); - virtual void DoRenderEffect(const util::DrawSceneInfo &drawSceneInfo) override; - void InitializeRenderTarget(); - void RecordGlowPass(const util::DrawSceneInfo &drawSceneInfo); - void ExecuteGlowPass(const util::DrawSceneInfo &drawSceneInfo); - std::shared_ptr m_glowRt; - - std::shared_ptr m_blurRt; - std::shared_ptr m_blurSet = nullptr; - - ControlledBlurSettings m_controlledBlurSettings; - - std::shared_ptr m_glowCommandBufferGroup = nullptr; - }; -}; - -#endif diff --git a/core/client/include/pragma/entities/components/renderers/rasterization/glow_data.hpp b/core/client/include/pragma/entities/components/renderers/rasterization/glow_data.hpp deleted file mode 100644 index 55494d774..000000000 --- a/core/client/include/pragma/entities/components/renderers/rasterization/glow_data.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (c) 2021 Silverlan - */ - -#ifndef __GLOW_DATA_HPP__ -#define __GLOW_DATA_HPP__ - -#include "pragma/clientdefinitions.h" -#include -#include -#include -#include -#include - -namespace prosper { - class RenderTarget; - class BlurSet; - class Shader; -}; -namespace pragma { - class CParticleSystemComponent; -}; -namespace pragma::rendering { - class HDRData; - class DLLCLIENT GlowData { - public: - GlowData(); - ~GlowData(); - GlowData(const GlowData &) = delete; - GlowData &operator=(const GlowData &) = delete; - bool Initialize(uint32_t width, uint32_t height, const HDRData &hdrInfo); - //Vulkan::DescriptorSet descSetAdditive; // prosper TODO - util::WeakHandle shader = {}; - std::vector tmpBloomParticles; - bool bGlowScheduled = false; // Glow meshes scheduled for this frame? (=tmpGlowMeshes isn't empty) - std::shared_ptr renderTarget = nullptr; - std::shared_ptr blurSet = nullptr; - private: - CallbackHandle m_cbReloadCommandBuffer; - }; -}; - -#endif diff --git a/core/client/include/pragma/gui/debug/widebugglowbloom.hpp b/core/client/include/pragma/gui/debug/widebugglowbloom.hpp deleted file mode 100644 index 8ea6847bb..000000000 --- a/core/client/include/pragma/gui/debug/widebugglowbloom.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (c) 2021 Silverlan - */ - -#ifndef __WIDEBUGGLOWBLOOM_HPP__ -#define __WIDEBUGGLOWBLOOM_HPP__ - -#include "pragma/clientdefinitions.h" -#include - -class DLLCLIENT WIDebugGlowBloom : public WITexturedRect { - public: - WIDebugGlowBloom(); - virtual ~WIDebugGlowBloom() override; - private: - virtual void DoUpdate() override; - void UpdateBloomImage(); - CallbackHandle m_cbRenderHDRMap = {}; - std::shared_ptr m_renderTarget = nullptr; -}; - -#endif diff --git a/core/client/include/pragma/rendering/c_renderflags.h b/core/client/include/pragma/rendering/c_renderflags.h index 317b17aaf..f97851eb4 100644 --- a/core/client/include/pragma/rendering/c_renderflags.h +++ b/core/client/include/pragma/rendering/c_renderflags.h @@ -17,8 +17,7 @@ enum class RenderFlags : uint32_t { Skybox = View << 1, Shadows = Skybox << 1, Particles = Shadows << 1, - Glow = Particles << 1, - Debug = Glow << 1, + Debug = Particles << 1, Water = Debug << 1, Static = Water << 1, Dynamic = Static << 1, diff --git a/core/client/include/pragma/rendering/c_rendermode.h b/core/client/include/pragma/rendering/c_rendermode.h index bf7a13949..b0b66fe3c 100644 --- a/core/client/include/pragma/rendering/c_rendermode.h +++ b/core/client/include/pragma/rendering/c_rendermode.h @@ -15,7 +15,7 @@ #include namespace pragma::rendering { - enum class SceneRenderPass : uint8_t { None = 0, World, View, Sky, Glow, Count }; + enum class SceneRenderPass : uint8_t { None = 0, World, View, Sky, Count }; enum class RenderMask : uint64_t { None = 0u }; using RenderGroup = RenderMask; diff --git a/core/client/include/pragma/rendering/shaders/post_processing/c_shader_pp_glow.hpp b/core/client/include/pragma/rendering/shaders/post_processing/c_shader_pp_glow.hpp deleted file mode 100644 index 18d651665..000000000 --- a/core/client/include/pragma/rendering/shaders/post_processing/c_shader_pp_glow.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (c) 2021 Silverlan - */ - -#ifndef __C_SHADER_PP_GLOW_HPP__ -#define __C_SHADER_PP_GLOW_HPP__ - -#include "pragma/rendering/shaders/world/c_shader_textured.hpp" - -namespace pragma { - class DLLCLIENT ShaderPPGlow : public ShaderGameWorldLightingPass { - public: - static prosper::DescriptorSetInfo DESCRIPTOR_SET_INSTANCE; - static prosper::DescriptorSetInfo DESCRIPTOR_SET_SCENE; - - static prosper::Format RENDER_PASS_FORMAT; - -#pragma pack(push, 1) - struct PushConstants { - float glowScale; - }; -#pragma pack(pop) - - ShaderPPGlow(prosper::IPrContext &context, const std::string &identifier); - virtual std::shared_ptr InitializeMaterialDescriptorSet(CMaterial &mat) override; - bool RecordGlowMaterial(prosper::ShaderBindState &bindState, CMaterial &mat) const; - protected: - virtual uint32_t GetCameraDescriptorSetIndex() const override; - virtual uint32_t GetInstanceDescriptorSetIndex() const override; - virtual void InitializeRenderPass(std::shared_ptr &outRenderPass, uint32_t pipelineIdx) override; - virtual void InitializeGfxPipelineDescriptorSets() override; - virtual void InitializeGfxPipelinePushConstantRanges() override; - virtual void InitializeGfxPipeline(prosper::GraphicsPipelineCreateInfo &pipelineInfo, uint32_t pipelineIdx) override; - virtual uint32_t GetRenderSettingsDescriptorSetIndex() const override { return std::numeric_limits::max(); } - }; -}; - -#endif diff --git a/core/client/include/pragma/rendering/shaders/post_processing/c_shader_pp_hdr.hpp b/core/client/include/pragma/rendering/shaders/post_processing/c_shader_pp_hdr.hpp index cac6d13a3..efb99dffc 100644 --- a/core/client/include/pragma/rendering/shaders/post_processing/c_shader_pp_hdr.hpp +++ b/core/client/include/pragma/rendering/shaders/post_processing/c_shader_pp_hdr.hpp @@ -31,25 +31,19 @@ namespace pragma { enum class TextureBinding : uint32_t { Texture = 0u, Bloom, - Glow }; #pragma pack(push, 1) struct PushConstants { float exposure; float bloomScale; - float glowScale; rendering::ToneMapping toneMapping; uint32_t flipVertically; }; #pragma pack(pop) ShaderPPHDR(prosper::IPrContext &context, const std::string &identifier); - bool RecordDraw( - prosper::ShaderBindState &bindState, prosper::IDescriptorSet &descSetTexture, - pragma::rendering::ToneMapping toneMapping, float exposure, float bloomScale, float glowScale, - bool flipVertically = false - ) const; + bool RecordDraw(prosper::ShaderBindState &bindState, prosper::IDescriptorSet &descSetTexture, pragma::rendering::ToneMapping toneMapping, float exposure, float bloomScale, bool flipVertically = false) const; protected: virtual void InitializeGfxPipeline(prosper::GraphicsPipelineCreateInfo &pipelineInfo, uint32_t pipelineIdx) override; virtual void InitializeShaderResources() override; diff --git a/core/client/include/pragma/rendering/shaders/world/c_shader_glow.hpp b/core/client/include/pragma/rendering/shaders/world/c_shader_glow.hpp deleted file mode 100644 index bb21058d3..000000000 --- a/core/client/include/pragma/rendering/shaders/world/c_shader_glow.hpp +++ /dev/null @@ -1,72 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (c) 2023 Silverlan - */ - -#ifndef __C_SHADER_GLOW_HPP__ -#define __C_SHADER_GLOW_HPP__ - -#include "pragma/rendering/shaders/world/c_shader_textured.hpp" - -class Texture; -namespace pragma { - class DLLCLIENT ShaderGlow : public ShaderGameWorldLightingPass { - public: - static prosper::DescriptorSetInfo DESCRIPTOR_SET_PBR; - - enum class MaterialBinding : uint32_t { - MaterialSettings = umath::to_integral(ShaderGameWorldLightingPass::MaterialBinding::MaterialSettings), - AlbedoMap, - NormalMap, - RMAMap, - EmissionMap, - ParallaxMap, - WrinkleStretchMap, - WrinkleCompressMap, - ExponentMap, - GlowMap, - - Count - }; - - enum class PBRBinding : uint32_t { - IrradianceMap = 0u, - PrefilterMap, - BRDFMap, - - Count - }; - - ShaderGlow(prosper::IPrContext &context, const std::string &identifier); - ShaderGlow(prosper::IPrContext &context, const std::string &identifier, const std::string &vsShader, const std::string &fsShader, const std::string &gsShader = ""); - - virtual std::shared_ptr InitializeMaterialDescriptorSet(CMaterial &mat) override; - prosper::IDescriptorSet &GetDefaultPbrDescriptorSet() const; - - // - virtual void RecordBindScene(rendering::ShaderProcessor &shaderProcessor, const pragma::CSceneComponent &scene, const pragma::CRasterizationRendererComponent &renderer, prosper::IDescriptorSet &dsScene, prosper::IDescriptorSet &dsRenderer, prosper::IDescriptorSet &dsRenderSettings, - prosper::IDescriptorSet &dsShadows, const Vector4 &drawOrigin, ShaderGameWorld::SceneFlags &inOutSceneFlags) const override; - - static bool BindDescriptorSetTexture(Material &mat, prosper::IDescriptorSet &ds, TextureInfo *texInfo, uint32_t bindingIndex, const std::string &defaultTexName, Texture **optOutTex = nullptr); - static bool BindDescriptorSetTexture(Material &mat, prosper::IDescriptorSet &ds, TextureInfo *texInfo, uint32_t bindingIndex, Texture *optDefaultTex = nullptr); - prosper::IDescriptorSet *GetReflectionProbeDescriptorSet(const pragma::CSceneComponent &scene, float &outIblStrength, ShaderGameWorld::SceneFlags &inOutSceneFlags) const; - protected: - using ShaderGameWorldLightingPass::RecordDraw; - virtual void InitializeRenderPass(std::shared_ptr &outRenderPass, uint32_t pipelineIdx) override; - void RecordBindSceneDescriptorSets(rendering::ShaderProcessor &shaderProcessor, const pragma::CSceneComponent &scene, const pragma::CRasterizationRendererComponent &renderer, prosper::IDescriptorSet &dsScene, prosper::IDescriptorSet &dsRenderer, - prosper::IDescriptorSet &dsRenderSettings, prosper::IDescriptorSet &dsShadows, ShaderGameWorld::SceneFlags &inOutSceneFlags, float &outIblStrength) const; - virtual void OnPipelinesInitialized() override; - virtual void InitializeGfxPipeline(prosper::GraphicsPipelineCreateInfo &pipelineInfo, uint32_t pipelineIdx) override; - virtual void UpdateRenderFlags(CModelSubMesh &mesh, SceneFlags &inOutFlags) override; - virtual void InitializeGfxPipelineDescriptorSets() override; - std::shared_ptr InitializeMaterialDescriptorSet(CMaterial &mat, const prosper::DescriptorSetInfo &descSetInfo); - bool BindDescriptorSetBaseTextures(CMaterial &mat, const prosper::DescriptorSetInfo &descSetInfo, prosper::IDescriptorSet &ds); - - SceneFlags m_extRenderFlags = SceneFlags::None; - std::shared_ptr m_defaultPbrDsg = nullptr; - }; -}; - -#endif diff --git a/core/client/src/console/c_cvar_glowmap.cpp b/core/client/src/console/c_cvar_glowmap.cpp deleted file mode 100644 index d259dd98f..000000000 --- a/core/client/src/console/c_cvar_glowmap.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (c) 2021 Silverlan - */ - -#include "stdafx_client.h" -#include "pragma/gui/debug/widebugglowbloom.hpp" -#include - -extern DLLCLIENT CGame *c_game; - -void CMD_debug_glow_bloom(NetworkState *, pragma::BasePlayerComponent *, std::vector &argv) -{ - auto &wgui = WGUI::GetInstance(); - auto *pRoot = wgui.GetBaseElement(); - if(c_game == nullptr || argv.empty() || pRoot == nullptr) - return; - const std::string name = "debug_glow_bloom"; - auto *pEl = pRoot->FindDescendantByName(name); - auto v = util::to_int(argv.front()); - if(v == 0) { - if(pEl != nullptr) - pEl->Remove(); - return; - } - if(pEl != nullptr) - return; - pEl = wgui.Create(); - if(pEl == nullptr) - return; - pEl->SetName(name); - pEl->SetSize(256, 256); - pEl->SetZPos(std::numeric_limits::max()); - pEl->Update(); -} diff --git a/core/client/src/entities/components/renderers/c_renderer_component.cpp b/core/client/src/entities/components/renderers/c_renderer_component.cpp index 481440fba..5adc0820b 100644 --- a/core/client/src/entities/components/renderers/c_renderer_component.cpp +++ b/core/client/src/entities/components/renderers/c_renderer_component.cpp @@ -8,7 +8,6 @@ #include "stdafx_client.h" #include "pragma/entities/components/renderers/c_renderer_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_bloom_component.hpp" -#include "pragma/entities/components/renderers/c_renderer_pp_glow_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_dof_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_fog_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_tone_mapping_component.hpp" @@ -62,7 +61,6 @@ void CRendererComponent::Initialize() GetEntity().AddComponent(); GetEntity().AddComponent(); GetEntity().AddComponent(); - GetEntity().AddComponent(); GetEntity().AddComponent(); GetEntity().AddComponent(); } diff --git a/core/client/src/entities/components/renderers/c_renderer_pp_glow_component.cpp b/core/client/src/entities/components/renderers/c_renderer_pp_glow_component.cpp deleted file mode 100644 index 9ccf58ec8..000000000 --- a/core/client/src/entities/components/renderers/c_renderer_pp_glow_component.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (c) 2021 Silverlan - */ - -#include "stdafx_client.h" -#include "pragma/entities/components/renderers/c_renderer_pp_glow_component.hpp" -#include "pragma/entities/components/renderers/c_renderer_component.hpp" -#include "pragma/entities/components/renderers/c_rasterization_renderer_component.hpp" -#include "pragma/entities/components/c_scene_component.hpp" -#include "pragma/entities/components/base_entity_component_logging.hpp" -#include "pragma/rendering/shaders/post_processing/c_shader_pp_bloom_blur.hpp" -#include "pragma/rendering/shaders/post_processing/c_shader_pp_hdr.hpp" -#include "pragma/rendering/shaders/world/c_shader_textured.hpp" -#include "pragma/rendering/shaders/world/c_shader_glow.hpp" -#include "pragma/rendering/world_environment.hpp" -#include "pragma/rendering/render_processor.hpp" -#include "pragma/entities/entity_component_system_t.hpp" -#include "pragma/console/c_cvar.h" -#include -#include -#include -#include -#include -#include -#include - -extern DLLCLIENT CGame *c_game; -extern DLLCLIENT CEngine *c_engine; - -using namespace pragma; - -static auto cvBloomEnabled = GetClientConVar("render_bloom_enabled"); -static auto cvBloomAmount = GetClientConVar("render_bloom_amount"); - -static util::WeakHandle g_bloomBlurH {}; -static util::WeakHandle g_bloomBlurV {}; -static void init_shaders() -{ - if(g_bloomBlurH.expired()) - g_bloomBlurH = c_engine->GetShader("pp_bloom_blur_h"); - if(g_bloomBlurV.expired()) - g_bloomBlurV = c_engine->GetShader("pp_bloom_blur_v"); -} - -void CRendererPpGlowComponent::RegisterMembers(pragma::EntityComponentManager &componentManager, TRegisterComponentMember registerMember) -{ - using T = CRendererPpGlowComponent; - - using TBlurRadius = uint32_t; - { - auto memberInfo = create_component_member_info(&T::SetBlurRadius), static_cast(&T::GetBlurRadius)>("blurRadius", ShaderPPBloomBlurBase::DEFAULT_RADIUS); - memberInfo.SetMin(0); - memberInfo.SetMax(ControlledBlurSettings::MAX_BLUR_RADIUS); - registerMember(std::move(memberInfo)); - } - - using TBlurSigma = double; - { - auto memberInfo = create_component_member_info(&T::SetBlurSigma), static_cast(&T::GetBlurSigma)>("blurSigma", ShaderPPBloomBlurBase::DEFAULT_SIGMA); - memberInfo.SetMin(0); - memberInfo.SetMax(ControlledBlurSettings::MAX_BLUR_SIGMA); - registerMember(std::move(memberInfo)); - } - - using TBlurAmount = int32_t; - { - auto memberInfo = create_component_member_info(&T::SetBlurAmount), static_cast(&T::GetBlurAmount)>("blurAmount", -1); - memberInfo.SetMin(-1); - memberInfo.SetMax(20); - registerMember(std::move(memberInfo)); - } -} - -CRendererPpGlowComponent::CRendererPpGlowComponent(BaseEntity &ent) : CRendererPpBaseComponent(ent) { SetPipelineDirty(); } -prosper::Texture &CRendererPpGlowComponent::GetGlowTexture() { return m_glowRt->GetTexture(); } - -void CRendererPpGlowComponent::DoRenderEffect(const util::DrawSceneInfo &drawSceneInfo) -{ - if(!m_glowRt) - return; - auto &hdrInfo = m_renderer->GetHDRInfo(); - auto &drawCmd = drawSceneInfo.commandBuffer; - auto &texture = m_glowRt->GetTexture(); - // Blit high-res bloom image into low-res image, which is cheaper to blur - drawCmd->RecordImageBarrier(texture.GetImage(), prosper::ImageLayout::ColorAttachmentOptimal, prosper::ImageLayout::TransferSrcOptimal); - drawCmd->RecordImageBarrier(m_blurRt->GetTexture().GetImage(), prosper::ImageLayout::ShaderReadOnlyOptimal, prosper::ImageLayout::TransferDstOptimal); - drawCmd->RecordBlitTexture(texture, m_blurRt->GetTexture().GetImage()); - - if(!m_controlledBlurSettings.IsValid()) - return; - - drawCmd->RecordImageBarrier(texture.GetImage(), prosper::ImageLayout::TransferSrcOptimal, prosper::ImageLayout::ColorAttachmentOptimal); - drawCmd->RecordImageBarrier(m_blurRt->GetTexture().GetImage(), prosper::ImageLayout::TransferDstOptimal, prosper::ImageLayout::ShaderReadOnlyOptimal); - m_controlledBlurSettings.RecordBlur(drawCmd, *m_blurSet); - //drawCmd->RecordImageBarrier(bloomTexture->GetImage(), prosper::ImageLayout::TransferSrcOptimal, prosper::ImageLayout::ColorAttachmentOptimal); -} -void CRendererPpGlowComponent::InitializeLuaObject(lua_State *l) { return BaseEntityComponent::InitializeLuaObject>(l); } -void CRendererPpGlowComponent::ExecuteGlowPass(const util::DrawSceneInfo &drawSceneInfo) -{ - if(!m_glowRt) - return; -#if 0 - static auto matInitialized = false; - if(!matInitialized) { - auto mat = pragma::get_client_state()->LoadMaterial("models/antlion_guard/antlionguard2"); - if(mat) { - auto *shader = static_cast(pragma::get_cengine()->GetShader("glow").get()); - shader->InitializeMaterialDescriptorSet(static_cast(*mat)); - matInitialized = true; - } - } -#endif - - if(drawSceneInfo.renderStats) - (*drawSceneInfo.renderStats)->BeginGpuTimer(RenderStats::RenderStage::PostProcessingGpuGlow, *drawSceneInfo.commandBuffer); - - util::ScopeGuard scopeGuard {[&drawSceneInfo]() { - if(drawSceneInfo.renderStats) - (*drawSceneInfo.renderStats)->EndGpuTimer(RenderStats::RenderStage::PostProcessingGpuGlow, *drawSceneInfo.commandBuffer); - }}; - - c_game->StartGPUProfilingStage("PostProcessingBloom"); - - auto &drawCmd = drawSceneInfo.commandBuffer; - auto &texGlow = m_glowRt->GetTexture(); - drawCmd->RecordImageBarrier(texGlow.GetImage(), prosper::ImageLayout::ShaderReadOnlyOptimal, prosper::ImageLayout::TransferDstOptimal); - drawCmd->RecordClearImage(texGlow.GetImage(), prosper::ImageLayout::TransferDstOptimal, std::array {0.f, 0.f, 0.f, 0.f}); - drawCmd->RecordImageBarrier(texGlow.GetImage(), prosper::ImageLayout::TransferDstOptimal, prosper::ImageLayout::ColorAttachmentOptimal); - - // - - // TODO: This shouldn't be here - if(drawSceneInfo.commandBuffer->RecordBeginRenderPass(*m_glowRt, {prosper::ClearColorValue {std::array {0.f, 0.f, 0.f, 1.f}}, prosper::ClearColorValue {std::array {0.f, 0.f, 0.f, 1.f}}}, prosper::IPrimaryCommandBuffer::RenderPassFlags::SecondaryCommandBuffers)) { - m_glowCommandBufferGroup->ExecuteCommands(*drawCmd); - - // TODO - auto cRenderer = GetEntity().GetComponent(); - if(cRenderer.valid()) - m_renderer->RecordRenderParticleSystems(*drawCmd, drawSceneInfo, cRenderer->GetCulledParticles(), pragma::rendering::SceneRenderPass::World, false /* depthPass */, true /* glow */); - } - - drawSceneInfo.commandBuffer->RecordEndRenderPass(); - // - c_game->StopGPUProfilingStage(); // PostProcessingBloom -} -void CRendererPpGlowComponent::RecordGlowPass(const util::DrawSceneInfo &drawSceneInfo) -{ - if(!m_glowRt) - return; - - auto &rt = m_glowRt; - m_glowCommandBufferGroup->StartRecording(rt->GetRenderPass(), rt->GetFramebuffer()); - - if(!umath::is_flag_set(drawSceneInfo.flags, util::DrawSceneInfo::Flags::DisableLightingPass)) { - if((drawSceneInfo.renderFlags & RenderFlags::Glow) != RenderFlags::None) { - m_glowCommandBufferGroup->Record([this, &drawSceneInfo](prosper::ISecondaryCommandBuffer &cmd) mutable { - util::RenderPassDrawInfo rpDrawInfo {drawSceneInfo, cmd}; - pragma::rendering::LightingStageRenderProcessor rsys {rpDrawInfo, {} /* drawOrigin */}; - auto &sceneRenderDesc = drawSceneInfo.scene->GetSceneRenderDesc(); - auto *glowStageStats = drawSceneInfo.renderStats ? &drawSceneInfo.renderStats->GetPassStats(RenderStats::RenderPass::GlowPass) : nullptr; - rsys.Render(*sceneRenderDesc.GetRenderQueue(pragma::rendering::SceneRenderPass::Glow, false /* translucent */), glowStageStats); - }); - } - } - - m_glowCommandBufferGroup->EndRecording(); -} -void CRendererPpGlowComponent::SetBlurRadius(uint32_t radius) -{ - m_controlledBlurSettings.SetRadius(radius); - SetPipelineDirty(); -} -void CRendererPpGlowComponent::SetBlurSigma(double sigma) -{ - m_controlledBlurSettings.SetSigma(sigma); - SetPipelineDirty(); -} -uint32_t CRendererPpGlowComponent::GetBlurRadius() const { return m_controlledBlurSettings.GetRadius(); } -double CRendererPpGlowComponent::GetBlurSigma() const { return m_controlledBlurSettings.GetSigma(); } - -void CRendererPpGlowComponent::SetBlurAmount(int32_t blurAmount) { m_controlledBlurSettings.SetBlurAmount(blurAmount); } -int32_t CRendererPpGlowComponent::GetBlurAmount() const { return m_controlledBlurSettings.GetBlurAmount(); } -void CRendererPpGlowComponent::Initialize() -{ - CRendererPpBaseComponent::Initialize(); - - BindEventUnhandled(pragma::CRendererComponent::EVENT_ON_RENDER_TARGET_RELOADED, [this](std::reference_wrapper evData) { InitializeRenderTarget(); }); - BindEventUnhandled(pragma::CRasterizationRendererComponent::EVENT_ON_RECORD_LIGHTING_PASS, [this](std::reference_wrapper evData) { RecordGlowPass(static_cast(evData.get()).drawSceneInfo); }); - BindEventUnhandled(pragma::CRasterizationRendererComponent::EVENT_POST_LIGHTING_PASS, [this](std::reference_wrapper evData) { ExecuteGlowPass(static_cast(evData.get()).drawSceneInfo); }); -} -void CRendererPpGlowComponent::InitializeRenderTarget() -{ - auto rendererC = GetEntity().GetComponent(); - auto cRenderer = GetEntity().GetComponent(); - if(rendererC.expired() || cRenderer.expired()) - return; - - auto &context = c_engine->GetRenderContext(); - - m_glowCommandBufferGroup = context.CreateSwapCommandBufferGroup(context.GetWindow()); - - // TODO: Image view? - prosper::util::ImageCreateInfo createInfo {}; - createInfo.width = cRenderer->GetPrepass().textureDepth->GetImage().GetWidth(); - createInfo.height = cRenderer->GetPrepass().textureDepth->GetImage().GetHeight(); - createInfo.format = pragma::ShaderGlow::RENDER_PASS_FORMAT; - createInfo.usage = prosper::ImageUsageFlags::SampledBit | prosper::ImageUsageFlags::ColorAttachmentBit | prosper::ImageUsageFlags::TransferSrcBit | prosper::ImageUsageFlags::TransferDstBit; - createInfo.postCreateLayout = prosper::ImageLayout::ColorAttachmentOptimal; - - auto img = context.CreateImage(createInfo); - auto tex = context.CreateTexture({}, *img, prosper::util::ImageViewCreateInfo {}, prosper::util::SamplerCreateInfo {}); - - auto imgBloom = context.CreateImage(createInfo); - auto texBloom = context.CreateTexture({}, *imgBloom, prosper::util::ImageViewCreateInfo {}, prosper::util::SamplerCreateInfo {}); - //auto &descSetHdrResolve = *dsgBloomTonemapping->GetDescriptorSet(); - //descSetHdrResolve.SetBindingTexture(*bloomBlurTexture, umath::to_integral(pragma::ShaderPPHDR::TextureBinding::Bloom)); - - auto rp = static_cast(pragma::get_cengine()->GetShader("glow").get())->GetRenderPass(); - if(!rp) { - LogError("Invalid render pass!"); - return; - } - - auto rt = context.CreateRenderTarget({tex, texBloom, cRenderer->GetPrepass().textureDepth}, rp); - rt->SetDebugName("scene_glow_rt"); - m_glowRt = rt; - - // Blur - prosper::util::TextureCreateInfo texCreateInfo {}; - texCreateInfo.flags = prosper::util::TextureCreateInfo::Flags::Resolvable; - - // TODO - uint32_t width = 512; - uint32_t height = 512; - - prosper::util::ImageCreateInfo imgCreateInfo {}; - imgCreateInfo.format = pragma::ShaderGameWorldLightingPass::RENDER_PASS_FORMAT; - imgCreateInfo.usage = prosper::ImageUsageFlags::SampledBit | prosper::ImageUsageFlags::ColorAttachmentBit | prosper::ImageUsageFlags::TransferSrcBit | prosper::ImageUsageFlags::TransferDstBit; - // imgCreateInfo.samples = sampleCount; - imgCreateInfo.postCreateLayout = prosper::ImageLayout::ShaderReadOnlyOptimal; - - imgCreateInfo.usage - = prosper::ImageUsageFlags::SampledBit | prosper::ImageUsageFlags::ColorAttachmentBit | prosper::ImageUsageFlags::TransferDstBit | prosper::ImageUsageFlags::TransferSrcBit; // Note: Transfer flag required for debugging purposes only (See debug_glow_bloom console command) - //if(sampleCount != prosper::SampleCountFlags::e1Bit) - // imgCreateInfo.usage |= prosper::ImageUsageFlags::TransferSrcBit; - imgCreateInfo.usage |= prosper::ImageUsageFlags::TransferSrcBit; - - // The bloom image has to be blurred multiple times, which is expensive for larger resolutions. - // We don't really care about the quality of the blur image though, so we're using a smaller - // version of the bloom image for post-processing. - auto aspectRatio = width / static_cast(height); - imgCreateInfo.width = width; - imgCreateInfo.height = static_cast(imgCreateInfo.width * aspectRatio); - - prosper::util::ImageViewCreateInfo hdrImgViewCreateInfo {}; - // Note: We need the alpha channel for FXAA Luma - // hdrImgViewCreateInfo.swizzleAlpha = prosper::ComponentSwizzle::One; - prosper::util::SamplerCreateInfo hdrSamplerCreateInfo {}; - hdrSamplerCreateInfo.addressModeU = prosper::SamplerAddressMode::ClampToEdge; - hdrSamplerCreateInfo.addressModeV = prosper::SamplerAddressMode::ClampToEdge; - hdrSamplerCreateInfo.minFilter = prosper::Filter::Linear; // Note: These have to be linear for FXAA! - hdrSamplerCreateInfo.magFilter = prosper::Filter::Linear; - - if((imgCreateInfo.height % 2) != 0) - ++imgCreateInfo.height; - auto hdrBloomBlurImg = context.CreateImage(imgCreateInfo); - auto bloomBlurTexture = context.CreateTexture(texCreateInfo, *hdrBloomBlurImg, hdrImgViewCreateInfo, hdrSamplerCreateInfo); - imgCreateInfo.width = width; - imgCreateInfo.height = height; - m_blurRt = context.CreateRenderTarget({bloomBlurTexture}, prosper::ShaderGraphics::GetRenderPass(context, umath::to_integral(prosper::ShaderBlurBase::Pipeline::R16G16B16A16Sfloat))); - m_blurRt->SetDebugName("scene_glow_blur_rt"); - m_blurSet = prosper::BlurSet::Create(context, m_blurRt); - - auto &descSet = *cRenderer->GetHDRInfo().dsgBloomTonemapping->GetDescriptorSet(); - descSet.SetBindingTexture(*bloomBlurTexture, umath::to_integral(pragma::ShaderPPHDR::TextureBinding::Glow)); -} -void CRendererPpGlowComponent::SetPipelineDirty() { SetTickPolicy(pragma::TickPolicy::Always); } - -void CRendererPpGlowComponent::OnTick(double dt) -{ - CRendererPpBaseComponent::OnTick(dt); - SetTickPolicy(TickPolicy::Never); - m_controlledBlurSettings.UpdateShaderPipelines(); -} diff --git a/core/client/src/entities/components/renderers/c_renderer_pp_tone_mapping_component.cpp b/core/client/src/entities/components/renderers/c_renderer_pp_tone_mapping_component.cpp index 16fc496c0..1d375d2df 100644 --- a/core/client/src/entities/components/renderers/c_renderer_pp_tone_mapping_component.cpp +++ b/core/client/src/entities/components/renderers/c_renderer_pp_tone_mapping_component.cpp @@ -67,7 +67,6 @@ void CRendererPpToneMappingComponent::DoRenderEffect(const util::DrawSceneInfo & prosper::ShaderBindState bindState {*drawCmd}; if(shaderPPHdr.RecordBeginDraw(bindState, umath::to_integral(pipeline)) == true) { const float bloomAdditiveScale = 0.5f; - auto glowScale = 0.f; //(GetGlowInfo().bGlowScheduled == true) ? 1.f : 0.f; rendering::ToneMapping toneMapping; if(drawSceneInfo.toneMapping.has_value()) @@ -84,7 +83,7 @@ void CRendererPpToneMappingComponent::DoRenderEffect(const util::DrawSceneInfo & } } - shaderPPHdr.RecordDraw(bindState, descSetHdrResolve, toneMapping, m_renderer->GetHDRExposure(), bloomAdditiveScale, glowScale, umath::is_flag_set(drawSceneInfo.flags, util::DrawSceneInfo::Flags::FlipVertically)); + shaderPPHdr.RecordDraw(bindState, descSetHdrResolve, toneMapping, m_renderer->GetHDRExposure(), bloomAdditiveScale, umath::is_flag_set(drawSceneInfo.flags, util::DrawSceneInfo::Flags::FlipVertically)); shaderPPHdr.RecordEndDraw(bindState); } drawCmd->RecordEndRenderPass(); diff --git a/core/client/src/entities/components/renderers/rasterization/bloom.cpp b/core/client/src/entities/components/renderers/rasterization/bloom.cpp index 269c1d29c..bb906586c 100644 --- a/core/client/src/entities/components/renderers/rasterization/bloom.cpp +++ b/core/client/src/entities/components/renderers/rasterization/bloom.cpp @@ -8,7 +8,6 @@ #include "pragma/rendering/renderers/rasterization_renderer.hpp" #include "pragma/entities/components/renderers/rasterization/culled_mesh_data.hpp" #include "pragma/entities/components/renderers/c_rasterization_renderer_component.hpp" -#include "pragma/rendering/shaders/post_processing/c_shader_pp_glow.hpp" #include "pragma/rendering/occlusion_culling/c_occlusion_octree_impl.hpp" #include "pragma/rendering/scene/util_draw_scene_info.hpp" #include "pragma/console/c_cvar.h" @@ -109,7 +108,8 @@ void pragma::CRasterizationRendererComponent::RenderGlowMeshes(std::shared_ptr

-#include -#include -#include -#include -#include - -extern DLLCLIENT CEngine *c_engine; -extern DLLCLIENT CGame *c_game; - -using namespace pragma::rendering; - -GlowData::GlowData() : bGlowScheduled(false) { shader = c_engine->GetShader("glow"); } -GlowData::~GlowData() -{ - if(m_cbReloadCommandBuffer.IsValid()) - m_cbReloadCommandBuffer.Remove(); -} -bool GlowData::Initialize(uint32_t width, uint32_t height, const HDRData &hdrInfo) -{ - auto depthTex = hdrInfo.prepass.textureDepth; - if(depthTex->IsMSAATexture()) - depthTex = static_cast(*depthTex).GetResolvedTexture(); - - prosper::util::ImageCreateInfo imgCreateInfo {}; - imgCreateInfo.width = width; - imgCreateInfo.height = height; - imgCreateInfo.format = pragma::ShaderPPGlow::RENDER_PASS_FORMAT; - imgCreateInfo.usage = prosper::ImageUsageFlags::ColorAttachmentBit | prosper::ImageUsageFlags::SampledBit | prosper::ImageUsageFlags::TransferSrcBit; // Note: Transfer flag required for debugging purposes only (See debug_glow_bloom console command) - imgCreateInfo.memoryFeatures = prosper::MemoryFeatureFlags::GPUBulk; - auto img = c_engine->GetRenderContext().CreateImage(imgCreateInfo); - prosper::util::ImageViewCreateInfo imgViewCreateInfo {}; - prosper::util::SamplerCreateInfo samplerCreateInfo {}; - samplerCreateInfo.addressModeU = prosper::SamplerAddressMode::ClampToEdge; - samplerCreateInfo.addressModeV = prosper::SamplerAddressMode::ClampToEdge; - auto tex = c_engine->GetRenderContext().CreateTexture({}, *img, imgViewCreateInfo, samplerCreateInfo); - renderTarget = c_engine->GetRenderContext().CreateRenderTarget({tex, depthTex}, prosper::ShaderGraphics::GetRenderPass(c_engine->GetRenderContext())); - renderTarget->SetDebugName("glow_rt"); - - auto rtBlur = c_engine->GetRenderContext().CreateRenderTarget({tex}, prosper::ShaderGraphics::GetRenderPass(c_engine->GetRenderContext(), umath::to_integral(prosper::ShaderBlurBase::Pipeline::R8G8B8A8Unorm))); - rtBlur->SetDebugName("glow_blur_rt"); - blurSet = prosper::BlurSet::Create(c_engine->GetRenderContext(), rtBlur); - return true; -} diff --git a/core/client/src/entities/components/renderers/rasterization/render_core.cpp b/core/client/src/entities/components/renderers/rasterization/render_core.cpp index 7f6f64b68..296a12c61 100644 --- a/core/client/src/entities/components/renderers/rasterization/render_core.cpp +++ b/core/client/src/entities/components/renderers/rasterization/render_core.cpp @@ -9,11 +9,9 @@ #include "pragma/rendering/renderers/rasterization_renderer.hpp" #include "pragma/entities/components/renderers/rasterization/culled_mesh_data.hpp" #include "pragma/entities/components/renderers/rasterization/hdr_data.hpp" -#include "pragma/entities/components/renderers/rasterization/glow_data.hpp" #include "pragma/entities/components/renderers/c_rasterization_renderer_component.hpp" #include "pragma/entities/components/renderers/c_renderer_component.hpp" #include "pragma/entities/environment/effects/c_env_particle_system.h" -#include "pragma/rendering/shaders/post_processing/c_shader_pp_glow.hpp" #include "pragma/rendering/shaders/post_processing/c_shader_pp_fog.hpp" #include "pragma/rendering/shaders/post_processing/c_shader_pp_fxaa.hpp" #include "pragma/rendering/shaders/post_processing/c_shader_pp_hdr.hpp" diff --git a/core/client/src/game/c_game_components.cpp b/core/client/src/game/c_game_components.cpp index 018f1deab..cf0344326 100644 --- a/core/client/src/game/c_game_components.cpp +++ b/core/client/src/game/c_game_components.cpp @@ -142,7 +142,6 @@ #include "pragma/entities/components/renderers/c_renderer_pp_fog_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_dof_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_bloom_component.hpp" -#include "pragma/entities/components/renderers/c_renderer_pp_glow_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_tone_mapping_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_fxaa_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_motion_blur_component.hpp" @@ -281,7 +280,6 @@ void CGame::InitializeEntityComponents(pragma::EntityComponentManager &component componentManager.RegisterComponentType("renderer_pp_fog", {"rendering/post_processing", hideInEditor}); componentManager.RegisterComponentType("renderer_pp_dof", {"rendering/post_processing", hideInEditor}); componentManager.RegisterComponentType("renderer_pp_bloom", {"rendering/post_processing", hideInEditor}); - componentManager.RegisterComponentType("renderer_pp_glow", {"rendering/post_processing", hideInEditor}); componentManager.RegisterComponentType("renderer_pp_tone_mapping", {"rendering/post_processing", hideInEditor}); componentManager.RegisterComponentType("renderer_pp_fxaa", {"rendering/post_processing", hideInEditor}); componentManager.RegisterComponentType("renderer_pp_motion_blur", {"rendering/post_processing", hideInEditor}); diff --git a/core/client/src/gui/debug/widebugglowbloom.cpp b/core/client/src/gui/debug/widebugglowbloom.cpp deleted file mode 100644 index 00b7c5af2..000000000 --- a/core/client/src/gui/debug/widebugglowbloom.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (c) 2021 Silverlan - */ - -#include "stdafx_client.h" -#include "pragma/clientstate/clientstate.h" -#include "pragma/gui/debug/widebugglowbloom.hpp" -#include "pragma/rendering/renderers/rasterization_renderer.hpp" -#include "pragma/entities/components/renderers/c_rasterization_renderer_component.hpp" -#include "pragma/entities/components/renderers/c_renderer_pp_glow_component.hpp" -#include "pragma/entities/components/renderers/c_renderer_component.hpp" -#include "pragma/entities/components/c_scene_component.hpp" -#include "pragma/entities/entity_component_system_t.hpp" -#include -#include -#include -#include - -extern DLLCLIENT CEngine *c_engine; -extern DLLCLIENT ClientState *client; -extern DLLCLIENT CGame *c_game; - -LINK_WGUI_TO_CLASS(WIDebugGlowBloom, WIDebugGlowBloom); - -WIDebugGlowBloom::WIDebugGlowBloom() : WITexturedRect() {} - -WIDebugGlowBloom::~WIDebugGlowBloom() -{ - if(m_cbRenderHDRMap.IsValid()) - m_cbRenderHDRMap.Remove(); - m_renderTarget = nullptr; -} - -void WIDebugGlowBloom::UpdateBloomImage() -{ - auto &drawCmd = c_engine->GetDrawCommandBuffer(); - auto *scene = c_game->GetScene(); - auto *renderer = scene ? dynamic_cast(scene->GetRenderer()) : nullptr; - if(renderer == nullptr) - return; - auto raster = renderer->GetEntity().GetComponent(); - if(raster.expired()) - return; - auto glowC = renderer->GetEntity().GetComponent(); - if(glowC.expired()) - return; - auto &glowTexture = glowC->GetGlowTexture(); - auto &imgSrc = glowTexture.GetImage(); - auto &imgDst = m_renderTarget->GetTexture().GetImage(); - - drawCmd->RecordImageBarrier(imgSrc,prosper::ImageLayout::ColorAttachmentOptimal,prosper::ImageLayout::TransferSrcOptimal); - drawCmd->RecordImageBarrier(imgDst,prosper::ImageLayout::ShaderReadOnlyOptimal,prosper::ImageLayout::TransferDstOptimal); - drawCmd->RecordBlitImage({},imgSrc,imgDst); - drawCmd->RecordImageBarrier(imgSrc,prosper::ImageLayout::TransferSrcOptimal,prosper::ImageLayout::ColorAttachmentOptimal); - drawCmd->RecordImageBarrier(imgDst,prosper::ImageLayout::TransferDstOptimal,prosper::ImageLayout::ShaderReadOnlyOptimal); -} - -void WIDebugGlowBloom::DoUpdate() -{ - WITexturedRect::DoUpdate(); - if(c_game == nullptr) - return; - prosper::util::ImageCreateInfo imgCreateInfo {}; - imgCreateInfo.width = GetWidth(); - imgCreateInfo.height = GetHeight(); - imgCreateInfo.format = prosper::Format::R8G8B8A8_UNorm; - imgCreateInfo.memoryFeatures = prosper::MemoryFeatureFlags::GPUBulk; - imgCreateInfo.usage = prosper::ImageUsageFlags::ColorAttachmentBit | prosper::ImageUsageFlags::SampledBit | prosper::ImageUsageFlags::TransferDstBit; - auto img = c_engine->GetRenderContext().CreateImage(imgCreateInfo); - prosper::util::ImageViewCreateInfo imgViewCreateInfo {}; - prosper::util::SamplerCreateInfo samplerCreateInfo {}; - auto tex = c_engine->GetRenderContext().CreateTexture({}, *img, imgViewCreateInfo, samplerCreateInfo); - prosper::util::RenderPassCreateInfo rpInfo {}; - rpInfo.attachments.push_back({img->GetFormat(), prosper::ImageLayout::ColorAttachmentOptimal, prosper::AttachmentLoadOp::Load, prosper::AttachmentStoreOp::Store, img->GetSampleCount(), prosper::ImageLayout::ColorAttachmentOptimal}); - rpInfo.subPasses.push_back({prosper::util::RenderPassCreateInfo::SubPass {{0ull}}}); - auto rp = c_engine->GetRenderContext().CreateRenderPass(rpInfo); - m_renderTarget = c_engine->GetRenderContext().CreateRenderTarget({tex}, rp, {}); - m_cbRenderHDRMap = c_game->AddCallback("PostRenderScenes", FunctionCallback<>::Create(std::bind(&WIDebugGlowBloom::UpdateBloomImage, this))); - SetTexture(m_renderTarget->GetTexture()); -} diff --git a/core/client/src/lua/c_lentity_components2.cpp b/core/client/src/lua/c_lentity_components2.cpp index b58641523..82e0d25cf 100644 --- a/core/client/src/lua/c_lentity_components2.cpp +++ b/core/client/src/lua/c_lentity_components2.cpp @@ -18,7 +18,6 @@ #include "pragma/entities/components/renderers/c_renderer_pp_fog_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_dof_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_bloom_component.hpp" -#include "pragma/entities/components/renderers/c_renderer_pp_glow_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_tone_mapping_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_fxaa_component.hpp" #include "pragma/entities/components/renderers/c_renderer_pp_motion_blur_component.hpp" @@ -145,15 +144,6 @@ void RegisterLuaEntityComponents2_cl(lua_State *l, luabind::module_ &entsMod) defPpBloom.def("SetBlurAmount", &pragma::CRendererPpBloomComponent::SetBlurAmount); entsMod[defPpBloom]; - auto defPpGlow = pragma::lua::create_entity_component_class("RendererPpGlowComponent"); - defPpGlow.def("SetBlurRadius", &pragma::CRendererPpGlowComponent::SetBlurRadius); - defPpGlow.def("SetBlurSigma", &pragma::CRendererPpGlowComponent::SetBlurSigma); - defPpGlow.def("GetBlurRadius", &pragma::CRendererPpGlowComponent::GetBlurRadius); - defPpGlow.def("GetBlurSigma", &pragma::CRendererPpGlowComponent::GetBlurSigma); - defPpGlow.def("GetBlurAmount", &pragma::CRendererPpGlowComponent::GetBlurAmount); - defPpGlow.def("SetBlurAmount", &pragma::CRendererPpGlowComponent::SetBlurAmount); - entsMod[defPpGlow]; - auto defPpToneMapping = pragma::lua::create_entity_component_class("RendererPpToneMappingComponent"); defPpToneMapping.def("SetApplyToHdrImage", &pragma::CRendererPpToneMappingComponent::SetApplyToHdrImage); entsMod[defPpToneMapping]; diff --git a/core/client/src/lua/c_lua.cpp b/core/client/src/lua/c_lua.cpp index edbbcad2d..1fa550738 100644 --- a/core/client/src/lua/c_lua.cpp +++ b/core/client/src/lua/c_lua.cpp @@ -97,10 +97,8 @@ void Lua::register_shared_client_state(lua_State *l) auto modLocale = luabind::module_(l, "locale"); modLocale[luabind::def("load", Lua::Locale::load), luabind::def("get_language", Lua::Locale::get_language), luabind::def("change_language", Lua::Locale::change_language), luabind::def("set_text", Lua::Locale::set_localization), luabind::def("localize", Lua::Locale::localize), luabind::def("relocalize", Lua::Locale::relocalize)]; - modLocale[luabind::def( - "get_used_characters", +[]() -> std::string { return ::Locale::GetUsedCharacters().cpp_str(); })]; - modLocale[luabind::def( - "load_all", +[]() { ::Locale::LoadAll(); })]; + modLocale[luabind::def("get_used_characters", +[]() -> std::string { return ::Locale::GetUsedCharacters().cpp_str(); })]; + modLocale[luabind::def("load_all", +[]() { ::Locale::LoadAll(); })]; modLocale[luabind::def("clear", Lua::Locale::clear)]; modLocale[luabind::def("get_texts", Lua::Locale::get_texts)]; modLocale[luabind::def( @@ -352,13 +350,27 @@ void CGame::RegisterLua() {"CURSOR_MODE_DISABLED", umath::to_integral(GLFW::CursorMode::Disabled)}, {"CURSOR_MODE_HIDDEN", umath::to_integral(GLFW::CursorMode::Hidden)}, {"CURSOR_MODE_NORMAL", umath::to_integral(GLFW::CursorMode::Normal)}}); Lua::RegisterLibraryEnums(GetLuaState(), "game", - {{"RENDER_FLAG_NONE", 0}, {"RENDER_FLAG_BIT_WORLD", umath::to_integral(RenderFlags::World)}, {"RENDER_FLAG_BIT_VIEW", umath::to_integral(RenderFlags::View)}, {"RENDER_FLAG_BIT_SKYBOX", umath::to_integral(RenderFlags::Skybox)}, - {"RENDER_FLAG_BIT_SHADOWS", umath::to_integral(RenderFlags::Shadows)}, {"RENDER_FLAG_BIT_PARTICLES", umath::to_integral(RenderFlags::Particles)}, {"RENDER_FLAG_BIT_GLOW", umath::to_integral(RenderFlags::Glow)}, {"RENDER_FLAG_BIT_DEBUG", umath::to_integral(RenderFlags::Debug)}, - {"RENDER_FLAG_ALL", umath::to_integral(RenderFlags::All)}, {"RENDER_FLAG_REFLECTION_BIT", umath::to_integral(RenderFlags::Reflection)}, {"RENDER_FLAG_WATER_BIT", umath::to_integral(RenderFlags::Water)}, {"RENDER_FLAG_STATIC_BIT", umath::to_integral(RenderFlags::Static)}, - {"RENDER_FLAG_DYNAMIC_BIT", umath::to_integral(RenderFlags::Dynamic)}, {"RENDER_FLAG_TRANSLUCENT_BIT", umath::to_integral(RenderFlags::Translucent)}, {"RENDER_FLAG_HDR_BIT", umath::to_integral(RenderFlags::HDR)}, + { + {"RENDER_FLAG_NONE", 0}, + {"RENDER_FLAG_BIT_WORLD", umath::to_integral(RenderFlags::World)}, + {"RENDER_FLAG_BIT_VIEW", umath::to_integral(RenderFlags::View)}, + {"RENDER_FLAG_BIT_SKYBOX", umath::to_integral(RenderFlags::Skybox)}, + {"RENDER_FLAG_BIT_SHADOWS", umath::to_integral(RenderFlags::Shadows)}, + {"RENDER_FLAG_BIT_PARTICLES", umath::to_integral(RenderFlags::Particles)}, + {"RENDER_FLAG_BIT_DEBUG", umath::to_integral(RenderFlags::Debug)}, + {"RENDER_FLAG_ALL", umath::to_integral(RenderFlags::All)}, + {"RENDER_FLAG_REFLECTION_BIT", umath::to_integral(RenderFlags::Reflection)}, + {"RENDER_FLAG_WATER_BIT", umath::to_integral(RenderFlags::Water)}, + {"RENDER_FLAG_STATIC_BIT", umath::to_integral(RenderFlags::Static)}, + {"RENDER_FLAG_DYNAMIC_BIT", umath::to_integral(RenderFlags::Dynamic)}, + {"RENDER_FLAG_TRANSLUCENT_BIT", umath::to_integral(RenderFlags::Translucent)}, + {"RENDER_FLAG_HDR_BIT", umath::to_integral(RenderFlags::HDR)}, {"RENDER_FLAG_PARTICLE_DEPTH_BIT", umath::to_integral(RenderFlags::ParticleDepth)}, - {"ASSET_LOAD_FLAG_NONE", umath::to_integral(util::AssetLoadFlags::None)}, {"ASSET_LOAD_FLAG_DONT_CACHE", umath::to_integral(util::AssetLoadFlags::DontCache)}, {"ASSET_LOAD_FLAG_IGNORE_CACHE", umath::to_integral(util::AssetLoadFlags::IgnoreCache)}}); + {"ASSET_LOAD_FLAG_NONE", umath::to_integral(util::AssetLoadFlags::None)}, + {"ASSET_LOAD_FLAG_DONT_CACHE", umath::to_integral(util::AssetLoadFlags::DontCache)}, + {"ASSET_LOAD_FLAG_IGNORE_CACHE", umath::to_integral(util::AssetLoadFlags::IgnoreCache)}, + }); auto gameMod = luabind::module(GetLuaState(), "game"); RegisterLuaGameClasses(gameMod); diff --git a/core/client/src/lua/c_luaclass.cpp b/core/client/src/lua/c_luaclass.cpp index 3f6517c70..14b1ad418 100644 --- a/core/client/src/lua/c_luaclass.cpp +++ b/core/client/src/lua/c_luaclass.cpp @@ -56,7 +56,6 @@ #include "pragma/lua/classes/c_lworldenvironment.hpp" #include "pragma/asset/c_util_model.hpp" #include "pragma/rendering/shaders/util/c_shader_compose_rma.hpp" -#include "pragma/rendering/shaders/post_processing/c_shader_pp_glow.hpp" #include "pragma/rendering/shader_material/shader_material.hpp" #include "pragma/rendering/shader_graph/manager.hpp" #include "pragma/lua/libraries/ludm.hpp" @@ -865,10 +864,6 @@ void ClientState::RegisterSharedLuaClasses(Lua::Interface &lua, bool bGUI) defShaderTextured3D.def("GetShaderMaterialName", &pragma::ShaderGameWorldLightingPass::GetShaderMaterialName); modShader[defShaderTextured3D]; - auto defShaderGlow = luabind::class_>("Glow"); - defShaderGlow.add_static_constant("RENDER_PASS_COLOR_FORMAT", umath::to_integral(pragma::ShaderPPGlow::RENDER_PASS_FORMAT)); - modShader[defShaderGlow]; - auto defShaderCompute = luabind::class_("Compute"); defShaderCompute.def("RecordDispatch", &Lua::Shader::Compute::RecordDispatch); defShaderCompute.def("RecordDispatch", +[](lua_State *l, prosper::ShaderCompute &shader, prosper::ShaderBindState &bindState, uint32_t x, uint32_t y) { Lua::Shader::Compute::RecordDispatch(l, shader, bindState, x, y, 1u); }); diff --git a/core/client/src/rendering/c_render.cpp b/core/client/src/rendering/c_render.cpp index 90c3a5373..3d9d589a3 100644 --- a/core/client/src/rendering/c_render.cpp +++ b/core/client/src/rendering/c_render.cpp @@ -582,9 +582,9 @@ void CGame::RenderScenes(const std::vector &drawSceneInfos) } if(drawWorld == 2) - drawSceneInfo.renderFlags &= ~(RenderFlags::Shadows | RenderFlags::Glow); + drawSceneInfo.renderFlags &= ~(RenderFlags::Shadows); else if(drawWorld == 0) - drawSceneInfo.renderFlags &= ~(RenderFlags::Shadows | RenderFlags::Glow | RenderFlags::View | RenderFlags::World | RenderFlags::Skybox); + drawSceneInfo.renderFlags &= ~(RenderFlags::Shadows | RenderFlags::View | RenderFlags::World | RenderFlags::Skybox); if(cvDrawStatic->GetBool() == false) drawSceneInfo.renderFlags &= ~RenderFlags::Static; diff --git a/core/client/src/rendering/renderers/rasterization_renderer.cpp b/core/client/src/rendering/renderers/rasterization_renderer.cpp index 9e312ed5a..ab464df19 100644 --- a/core/client/src/rendering/renderers/rasterization_renderer.cpp +++ b/core/client/src/rendering/renderers/rasterization_renderer.cpp @@ -13,7 +13,6 @@ #include "pragma/rendering/shaders/world/c_shader_pbr.hpp" #include "pragma/rendering/shaders/world/c_shader_prepass.hpp" #include "pragma/entities/components/renderers/rasterization/hdr_data.hpp" -#include "pragma/entities/components/renderers/rasterization/glow_data.hpp" #include "pragma/rendering/scene/util_draw_scene_info.hpp" #include "pragma/rendering/render_processor.hpp" #include "pragma/rendering/render_queue.hpp" diff --git a/core/client/src/rendering/scene/scene_render_desc.cpp b/core/client/src/rendering/scene/scene_render_desc.cpp index 080297237..79a1c8e6c 100644 --- a/core/client/src/rendering/scene/scene_render_desc.cpp +++ b/core/client/src/rendering/scene/scene_render_desc.cpp @@ -109,10 +109,8 @@ static RenderFlags render_mode_to_render_flag(pragma::rendering::SceneRenderPass return RenderFlags::View; case pragma::rendering::SceneRenderPass::Sky: return RenderFlags::Skybox; - case pragma::rendering::SceneRenderPass::Glow: - return RenderFlags::Glow; } - static_assert(umath::to_integral(pragma::rendering::SceneRenderPass::Count) == 5); + static_assert(umath::to_integral(pragma::rendering::SceneRenderPass::Count) == 4); return RenderFlags::None; } @@ -127,8 +125,6 @@ SceneRenderDesc::RenderQueueId SceneRenderDesc::GetRenderQueueId(pragma::renderi // return !translucent ? RenderQueueId::Water : RenderQueueId::Invalid; case pragma::rendering::SceneRenderPass::World: return !translucent ? RenderQueueId::World : RenderQueueId::WorldTranslucent; - case pragma::rendering::SceneRenderPass::Glow: - return RenderQueueId::Glow; } static_assert(umath::to_integral(RenderQueueId::Count) == 8u); return RenderQueueId::Invalid; @@ -229,24 +225,6 @@ void SceneRenderDesc::AddRenderMeshesToRenderQueue(pragma::CRasterizationRendere fOptInsertItemToQueue(*renderQueue, item); else renderQueue->Add(item); - - if(renderBufferData[meshIdx].IsGlowPassEnabled() && umath::is_flag_set(renderFlags, RenderFlags::Glow)) { - auto *renderQueueGlow = getRenderQueue(pragma::rendering::SceneRenderPass::Glow, false); - if(renderQueueGlow) { - // TODO - auto *shader = static_cast(c_engine->GetShader("glow").get()); - auto pipelineIdx = shader->FindPipelineIndex(pragma::rendering::PassType::Generic, renderC.GetShaderPipelineSpecialization(), specializationFlags); - - prosper::PipelineID pipelineId; - if(pipelineIdx.has_value() != false && shader->GetPipelineId(pipelineId, *pipelineIdx) == true && pipelineId != std::numeric_limits::max()) { - pragma::rendering::RenderQueueItem itemGlow {static_cast(renderC.GetEntity()), meshIdx, *mat, pipelineId, nullptr}; - if(fOptInsertItemToQueue) - fOptInsertItemToQueue(*renderQueueGlow, itemGlow); - else - renderQueueGlow->Add(itemGlow); - } - } - } } } void SceneRenderDesc::AddRenderMeshesToRenderQueue(pragma::CRasterizationRendererComponent *optRasterizationRenderer, RenderFlags renderFlags, pragma::CRenderComponent &renderC, const pragma::CSceneComponent &scene, const pragma::CCameraComponent &cam, const Mat4 &vp, diff --git a/core/client/src/rendering/shaders/c_shaders.cpp b/core/client/src/rendering/shaders/c_shaders.cpp index cb59bf154..b8db458dc 100644 --- a/core/client/src/rendering/shaders/c_shaders.cpp +++ b/core/client/src/rendering/shaders/c_shaders.cpp @@ -42,7 +42,6 @@ #include "pragma/rendering/shaders/world/c_shader_loading.hpp" #include "pragma/rendering/shaders/post_processing/c_shader_ssao.hpp" #include "pragma/rendering/shaders/post_processing/c_shader_ssao_blur.hpp" -#include "pragma/rendering/shaders/post_processing/c_shader_pp_glow.hpp" #include "pragma/rendering/shaders/world/water/c_shader_water.hpp" #include "pragma/rendering/shaders/world/water/c_shader_water_splash.hpp" #include "pragma/rendering/shaders/world/water/c_shader_water_surface_integrate.hpp" @@ -54,7 +53,6 @@ #include "pragma/rendering/shaders/c_shader_cubemap_to_equirectangular.hpp" #include "pragma/rendering/shaders/world/raytracing/c_shader_raytracing.hpp" #include "pragma/rendering/shaders/world/c_shader_pbr.hpp" -#include "pragma/rendering/shaders/world/c_shader_glow.hpp" #include "pragma/rendering/shaders/info/c_shader_velocity_buffer.hpp" #include "pragma/rendering/shaders/world/c_shader_eye.hpp" #include "pragma/rendering/shaders/world/c_shader_unlit.hpp" @@ -104,7 +102,6 @@ void register_game_shaders() shaderManager.RegisterShader("pbr_blend", [](prosper::IPrContext &context, const std::string &identifier) { return new pragma::ShaderPBRBlend(context, identifier); }); shaderManager.RegisterShader("eye", [](prosper::IPrContext &context, const std::string &identifier) { return new pragma::ShaderEye(context, identifier); }); shaderManager.RegisterShader("eye_legacy", [](prosper::IPrContext &context, const std::string &identifier) { return new pragma::ShaderEyeLegacy(context, identifier); }); - shaderManager.RegisterShader("glow", [](prosper::IPrContext &context, const std::string &identifier) { return new pragma::ShaderGlow(context, identifier); }); // shaderManager.RegisterShader("flat",[](prosper::IPrContext &context,const std::string &identifier) {return new pragma::ShaderFlat(context,identifier);}); // shaderManager.RegisterShader("test",[](prosper::IPrContext &context,const std::string &identifier) {return new pragma::ShaderTest(context,identifier);}); @@ -159,7 +156,6 @@ void register_game_shaders() shaderManager.RegisterShader("ssao", [](prosper::IPrContext &context, const std::string &identifier) { return new pragma::ShaderSSAO(context, identifier); }); shaderManager.RegisterShader("ssao_blur", [](prosper::IPrContext &context, const std::string &identifier) { return new pragma::ShaderSSAOBlur(context, identifier); }); - shaderManager.RegisterShader("pp_glow", [](prosper::IPrContext &context, const std::string &identifier) { return new pragma::ShaderPPGlow(context, identifier); }); shaderManager.RegisterShader("pp_hdr", [](prosper::IPrContext &context, const std::string &identifier) { return new pragma::ShaderPPHDR(context, identifier); }); shaderManager.RegisterShader("pp_fog", [](prosper::IPrContext &context, const std::string &identifier) { return new pragma::ShaderPPFog(context, identifier); }); shaderManager.RegisterShader("pp_dof", [](prosper::IPrContext &context, const std::string &identifier) { return new pragma::ShaderPPDoF(context, identifier); }); diff --git a/core/client/src/rendering/shaders/post_processing/c_shader_pp_glow.cpp b/core/client/src/rendering/shaders/post_processing/c_shader_pp_glow.cpp deleted file mode 100644 index 76ab4a157..000000000 --- a/core/client/src/rendering/shaders/post_processing/c_shader_pp_glow.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (c) 2023 Silverlan - */ - -#include "stdafx_client.h" -#include "pragma/rendering/shaders/post_processing/c_shader_pp_glow.hpp" -#include "pragma/model/c_modelmesh.h" -#include "pragma/model/vk_mesh.h" -#include -#include -#include -#include -#include -#include - -using namespace pragma; - -extern DLLCLIENT CEngine *c_engine; - -decltype(ShaderPPGlow::DESCRIPTOR_SET_INSTANCE) ShaderPPGlow::DESCRIPTOR_SET_INSTANCE = {&ShaderGameWorldLightingPass::DESCRIPTOR_SET_INSTANCE}; -decltype(ShaderPPGlow::DESCRIPTOR_SET_SCENE) ShaderPPGlow::DESCRIPTOR_SET_SCENE = {&ShaderGameWorldLightingPass::DESCRIPTOR_SET_SCENE}; -decltype(ShaderPPGlow::RENDER_PASS_FORMAT) ShaderPPGlow::RENDER_PASS_FORMAT = prosper::Format::R8G8B8A8_UNorm; -ShaderPPGlow::ShaderPPGlow(prosper::IPrContext &context, const std::string &identifier) : ShaderGameWorldLightingPass(context, identifier, "programs/scene/glow/glow", "programs/scene/glow/glow") -{ - m_shaderMaterialName = "glow"; - // SetBaseShader(); -} -void ShaderPPGlow::InitializeGfxPipelinePushConstantRanges() { AttachPushConstantRange(0u, sizeof(PushConstants), prosper::ShaderStageFlags::FragmentBit); } -void ShaderPPGlow::InitializeGfxPipelineDescriptorSets() -{ - AddDescriptorSetGroup(DESCRIPTOR_SET_INSTANCE); - AddDescriptorSetGroup(DESCRIPTOR_SET_SCENE); -} -void ShaderPPGlow::InitializeGfxPipeline(prosper::GraphicsPipelineCreateInfo &pipelineInfo, uint32_t pipelineIdx) -{ - ShaderGameWorldLightingPass::InitializeGfxPipeline(pipelineInfo, pipelineIdx); - pipelineInfo.ToggleDepthBias(true, -180.f /* constant factor */, -180.f /* clamp */, 0.f /* slope factor */); -} -uint32_t ShaderPPGlow::GetCameraDescriptorSetIndex() const { return DESCRIPTOR_SET_SCENE.setIndex; } -uint32_t ShaderPPGlow::GetInstanceDescriptorSetIndex() const { return DESCRIPTOR_SET_INSTANCE.setIndex; } -void ShaderPPGlow::InitializeRenderPass(std::shared_ptr &outRenderPass, uint32_t pipelineIdx) -{ - auto sampleCount = GetSampleCount(pipelineIdx); - CreateCachedRenderPass( - {{{{RENDER_PASS_FORMAT, prosper::ImageLayout::ColorAttachmentOptimal, prosper::AttachmentLoadOp::Clear, prosper::AttachmentStoreOp::Store, sampleCount, prosper::ImageLayout::ShaderReadOnlyOptimal}, - {RENDER_PASS_DEPTH_FORMAT, prosper::ImageLayout::DepthStencilAttachmentOptimal, prosper::AttachmentLoadOp::Load, prosper::AttachmentStoreOp::Store /* depth values have already been written by prepass */, sampleCount, prosper::ImageLayout::DepthStencilAttachmentOptimal}}}}, - outRenderPass, pipelineIdx); -} -std::shared_ptr ShaderPPGlow::InitializeMaterialDescriptorSet(CMaterial &mat) { return ShaderGameWorldLightingPass::InitializeMaterialDescriptorSet(mat); } -bool ShaderPPGlow::RecordGlowMaterial(prosper::ShaderBindState &bindState, CMaterial &mat) const -{ - auto *glowMap = mat.GetGlowMap(); - if(glowMap == nullptr || glowMap->texture == nullptr) - return false; - auto descSetGroup = mat.GetDescriptorSetGroup(const_cast(*this)); - if(descSetGroup == nullptr) - descSetGroup = const_cast(this)->InitializeMaterialDescriptorSet(mat); // Attempt to initialize on the fly - if(descSetGroup == nullptr) - return false; - auto &data = mat.GetDataBlock(); - if(data != nullptr && data->GetBool("glow_alpha_only") == true) { - auto texture = std::static_pointer_cast(glowMap->texture); - if(prosper::util::has_alpha(texture->GetVkTexture()->GetImage().GetFormat()) == false) - return false; - } - auto scale = 1.f; - if(data != nullptr) - data->GetFloat("glow_scale", &scale); - - return false; // RecordPushConstants(bindState, PushConstants {scale}) && RecordBindDescriptorSet(bindState, *descSetGroup->GetDescriptorSet(), GetMaterialDescriptorSetIndex()); -} diff --git a/core/client/src/rendering/shaders/post_processing/c_shader_pp_hdr.cpp b/core/client/src/rendering/shaders/post_processing/c_shader_pp_hdr.cpp index d6687ebc5..258ad509f 100644 --- a/core/client/src/rendering/shaders/post_processing/c_shader_pp_hdr.cpp +++ b/core/client/src/rendering/shaders/post_processing/c_shader_pp_hdr.cpp @@ -21,8 +21,7 @@ using namespace pragma; decltype(ShaderPPHDR::DESCRIPTOR_SET_TEXTURE) ShaderPPHDR::DESCRIPTOR_SET_TEXTURE = { "TEXTURES", - {prosper::DescriptorSetInfo::Binding {"SCENE", prosper::DescriptorType::CombinedImageSampler, prosper::ShaderStageFlags::FragmentBit}, prosper::DescriptorSetInfo::Binding {"BLOOM", prosper::DescriptorType::CombinedImageSampler, prosper::ShaderStageFlags::FragmentBit}, - prosper::DescriptorSetInfo::Binding {"GLOW", prosper::DescriptorType::CombinedImageSampler, prosper::ShaderStageFlags::FragmentBit}}, + {prosper::DescriptorSetInfo::Binding {"SCENE", prosper::DescriptorType::CombinedImageSampler, prosper::ShaderStageFlags::FragmentBit}, prosper::DescriptorSetInfo::Binding {"BLOOM", prosper::DescriptorType::CombinedImageSampler, prosper::ShaderStageFlags::FragmentBit}}, }; decltype(ShaderPPHDR::RENDER_PASS_FORMAT) ShaderPPHDR::RENDER_PASS_FORMAT = prosper::Format::R8G8B8A8_UNorm; decltype(ShaderPPHDR::RENDER_PASS_FORMAT_HDR) ShaderPPHDR::RENDER_PASS_FORMAT_HDR = prosper::Format::R16G16B16A16_SFloat; @@ -55,10 +54,6 @@ void ShaderPPHDR::InitializeGfxPipeline(prosper::GraphicsPipelineCreateInfo &pip auto fxaaEnabled = (settings.fxaaEnabled && static_cast(pipelineIdx) != Pipeline::HDR); AddSpecializationConstant(pipelineInfo, prosper::ShaderStageFlags::FragmentBit, 1u /* constantId */, static_cast(fxaaEnabled)); - - static auto settingsGlowEnabled = false; - auto glowEnabled = settingsGlowEnabled; - AddSpecializationConstant(pipelineInfo, prosper::ShaderStageFlags::FragmentBit, 2u /* constantId */, static_cast(glowEnabled)); } void ShaderPPHDR::InitializeShaderResources() @@ -69,7 +64,7 @@ void ShaderPPHDR::InitializeShaderResources() AttachPushConstantRange(0u, sizeof(PushConstants), prosper::ShaderStageFlags::FragmentBit); } -bool ShaderPPHDR::RecordDraw(prosper::ShaderBindState &bindState, prosper::IDescriptorSet &descSetTexture, pragma::rendering::ToneMapping toneMapping, float exposure, float bloomScale, float glowScale, bool flipVertically) const +bool ShaderPPHDR::RecordDraw(prosper::ShaderBindState &bindState, prosper::IDescriptorSet &descSetTexture, pragma::rendering::ToneMapping toneMapping, float exposure, float bloomScale, bool flipVertically) const { - return RecordPushConstants(bindState, PushConstants {exposure, bloomScale, glowScale, toneMapping, flipVertically ? 1u : 0u}) && ShaderPPBase::RecordDraw(bindState, descSetTexture) == true; + return RecordPushConstants(bindState, PushConstants {exposure, bloomScale, toneMapping, flipVertically ? 1u : 0u}) && ShaderPPBase::RecordDraw(bindState, descSetTexture) == true; } diff --git a/core/client/src/rendering/shaders/world/c_shader_glow.cpp b/core/client/src/rendering/shaders/world/c_shader_glow.cpp deleted file mode 100644 index 63b98d51d..000000000 --- a/core/client/src/rendering/shaders/world/c_shader_glow.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (c) 2021 Silverlan - */ - -#include "stdafx_client.h" -#include "pragma/rendering/shaders/world/c_shader_glow.hpp" -#include "cmaterialmanager.h" -#include "pragma/entities/environment/c_env_reflection_probe.hpp" -#include "pragma/entities/environment/c_env_camera.h" -#include "pragma/rendering/renderers/rasterization_renderer.hpp" -#include "pragma/rendering/render_processor.hpp" -#include "pragma/model/vk_mesh.h" -#include "pragma/model/c_modelmesh.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern DLLCLIENT CGame *c_game; -extern DLLCLIENT ClientState *client; -extern DLLCLIENT CEngine *c_engine; - -using namespace pragma; - -decltype(ShaderGlow::DESCRIPTOR_SET_PBR) ShaderGlow::DESCRIPTOR_SET_PBR = { - "PBR", - { - prosper::DescriptorSetInfo::Binding {"IRRADIANCE_MAP", prosper::DescriptorType::CombinedImageSampler, prosper::ShaderStageFlags::FragmentBit, prosper::PrDescriptorSetBindingFlags::Cubemap}, - prosper::DescriptorSetInfo::Binding {"PREFILTER_MAP", prosper::DescriptorType::CombinedImageSampler, prosper::ShaderStageFlags::FragmentBit, prosper::PrDescriptorSetBindingFlags::Cubemap}, - prosper::DescriptorSetInfo::Binding {"BRDF_MAP", prosper::DescriptorType::CombinedImageSampler, prosper::ShaderStageFlags::FragmentBit}, - }, -}; -ShaderGlow::ShaderGlow(prosper::IPrContext &context, const std::string &identifier, const std::string &vsShader, const std::string &fsShader, const std::string &gsShader) : ShaderGameWorldLightingPass {context, identifier, vsShader, fsShader, gsShader} { m_shaderMaterialName = "pbr"; } -ShaderGlow::ShaderGlow(prosper::IPrContext &context, const std::string &identifier) : ShaderGlow {context, identifier, "programs/scene/textured", "programs/scene/glow/glow"} {} - -void ShaderGlow::InitializeRenderPass(std::shared_ptr &outRenderPass, uint32_t pipelineIdx) -{ - auto sampleCount = GetSampleCount(pipelineIdx); - prosper::util::RenderPassCreateInfo rpCreateInfo { - {{RENDER_PASS_FORMAT, prosper::ImageLayout::ColorAttachmentOptimal, prosper::AttachmentLoadOp::DontCare, prosper::AttachmentStoreOp::Store, sampleCount, prosper::ImageLayout::ColorAttachmentOptimal}, - {RENDER_PASS_FORMAT, prosper::ImageLayout::ColorAttachmentOptimal, prosper::AttachmentLoadOp::Clear, prosper::AttachmentStoreOp::Store, sampleCount, prosper::ImageLayout::ColorAttachmentOptimal}, // Bloom Attachment - {RENDER_PASS_DEPTH_FORMAT, prosper::ImageLayout::DepthStencilAttachmentOptimal, prosper::AttachmentLoadOp::Load, prosper::AttachmentStoreOp::Store /* depth values have already been written by prepass */, sampleCount, prosper::ImageLayout::DepthStencilAttachmentOptimal}}, - }; - rpCreateInfo.subPasses.push_back(prosper::util::RenderPassCreateInfo::SubPass {std::vector {0ull, 1ull}, true}); - - CreateCachedRenderPass(rpCreateInfo, outRenderPass, pipelineIdx); -} - -void ShaderGlow::UpdateRenderFlags(CModelSubMesh &mesh, SceneFlags &inOutFlags) -{ - ShaderGameWorldLightingPass::UpdateRenderFlags(mesh, inOutFlags); - inOutFlags |= m_extRenderFlags; -} -void ShaderGlow::InitializeGfxPipelineDescriptorSets() -{ - ShaderGameWorldLightingPass::InitializeGfxPipelineDescriptorSets(); - AddDescriptorSetGroup(DESCRIPTOR_SET_PBR); -} - -bool ShaderGlow::BindDescriptorSetTexture(Material &mat, prosper::IDescriptorSet &ds, TextureInfo *texInfo, uint32_t bindingIndex, Texture *optDefaultTex) -{ - auto &matManager = static_cast(client->GetMaterialManager()); - auto &texManager = matManager.GetTextureManager(); - - std::shared_ptr tex = nullptr; - if(texInfo && texInfo->texture) - tex = std::static_pointer_cast(texInfo->texture); - else if(optDefaultTex == nullptr) - return false; - else - tex = optDefaultTex->shared_from_this(); - if(tex && tex->HasValidVkTexture()) - ds.SetBindingTexture(*tex->GetVkTexture(), bindingIndex); - return true; -} - -static bool bind_default_texture(prosper::IDescriptorSet &ds, const std::string &defaultTexName, uint32_t bindingIndex, Texture **optOutTex) -{ - auto tex = pragma::ShaderGameWorldLightingPass::GetTexture(defaultTexName); - if(!tex) { - Con::cwar << "Attempted to bind texture '" << defaultTexName << "' to material descriptor set, but texture has not been loaded!" << Con::endl; - return false; - } - - if(tex && tex->HasValidVkTexture()) - ds.SetBindingTexture(*tex->GetVkTexture(), bindingIndex); - if(optOutTex) - *optOutTex = tex.get(); - return true; -} - -bool ShaderGlow::BindDescriptorSetTexture(Material &mat, prosper::IDescriptorSet &ds, TextureInfo *texInfo, uint32_t bindingIndex, const std::string &defaultTexName, Texture **optOutTex) -{ - auto &matManager = static_cast(client->GetMaterialManager()); - auto &texManager = matManager.GetTextureManager(); - - std::shared_ptr tex = nullptr; - if(texInfo && texInfo->texture) { - tex = std::static_pointer_cast(texInfo->texture); - if(tex->HasValidVkTexture()) { - ds.SetBindingTexture(*tex->GetVkTexture(), bindingIndex); - if(optOutTex) - *optOutTex = tex.get(); - return true; - } - } - else if(defaultTexName.empty()) - return false; - return bind_default_texture(ds, defaultTexName, bindingIndex, optOutTex); -} - -bool ShaderGlow::BindDescriptorSetBaseTextures(CMaterial &mat, const prosper::DescriptorSetInfo &descSetInfo, prosper::IDescriptorSet &ds) -{ -#if 0 - auto matData = InitializeMaterialBuffer(ds, mat); - if(matData.has_value() == false) - return false; - - Texture *texAlbedo = nullptr; - if(BindDescriptorSetTexture(mat, ds, mat.GetAlbedoMap(), umath::to_integral(MaterialBinding::AlbedoMap), "white", &texAlbedo) == false) - return false; - - if(BindDescriptorSetTexture(mat, ds, mat.GetNormalMap(), umath::to_integral(MaterialBinding::NormalMap), "black") == false) - return false; - - if(BindDescriptorSetTexture(mat, ds, mat.GetRMAMap(), umath::to_integral(MaterialBinding::RMAMap), "pbr/rma_neutral") == false) - return false; - - if(umath::is_flag_set(matData->flags, ShaderGameWorldLightingPass::MaterialFlags::Glow)) - BindDescriptorSetTexture(mat, ds, mat.GetGlowMap(), umath::to_integral(MaterialBinding::EmissionMap), "white"); - else - BindDescriptorSetTexture(mat, ds, mat.GetGlowMap(), umath::to_integral(MaterialBinding::EmissionMap)); - - if(BindDescriptorSetTexture(mat, ds, mat.GetParallaxMap(), umath::to_integral(MaterialBinding::ParallaxMap), "black") == false) - return false; - - if(BindDescriptorSetTexture(mat, ds, mat.GetTextureInfo("wrinkle_stretch_map"), umath::to_integral(MaterialBinding::WrinkleStretchMap), texAlbedo) == false) - return false; - - if(BindDescriptorSetTexture(mat, ds, mat.GetTextureInfo("wrinkle_compress_map"), umath::to_integral(MaterialBinding::WrinkleCompressMap), texAlbedo) == false) - return false; - - if(BindDescriptorSetTexture(mat, ds, mat.GetTextureInfo("exponent_map"), umath::to_integral(MaterialBinding::ExponentMap), "white") == false) - return false; - - if(BindDescriptorSetTexture(mat, ds, mat.GetTextureInfo("glow_map"), umath::to_integral(MaterialBinding::GlowMap), "white") == false) - return false; - - return true; -#endif - return false; -} - -std::shared_ptr ShaderGlow::InitializeMaterialDescriptorSet(CMaterial &mat, const prosper::DescriptorSetInfo &descSetInfo) -{ - auto *albedoMap = mat.GetDiffuseMap(); - if(albedoMap == nullptr || albedoMap->texture == nullptr) - return nullptr; - - auto albedoTexture = std::static_pointer_cast(albedoMap->texture); - if(albedoTexture->HasValidVkTexture() == false) - return nullptr; - - auto descSetGroup = c_engine->GetRenderContext().CreateDescriptorSetGroup(descSetInfo); - mat.SetDescriptorSetGroup(*this, descSetGroup); - auto &descSet = *descSetGroup->GetDescriptorSet(); - - if(BindDescriptorSetBaseTextures(mat, descSetInfo, descSet) == false) - return nullptr; - - // TODO: FIXME: It would probably be a good idea to update the descriptor set lazily (i.e. not update it here), but - // that seems to cause crashes in some cases - if(descSet.Update() == false) - return nullptr; - return descSetGroup; -} -void ShaderGlow::OnPipelinesInitialized() -{ - ShaderGameWorldLightingPass::OnPipelinesInitialized(); - auto &context = c_engine->GetRenderContext(); - m_defaultPbrDsg = context.CreateDescriptorSetGroup(pragma::ShaderGlow::DESCRIPTOR_SET_PBR); - auto &dummyTex = context.GetDummyTexture(); - auto &dummyCubemapTex = context.GetDummyCubemapTexture(); - auto &ds = *m_defaultPbrDsg->GetDescriptorSet(0); - ds.SetBindingTexture(*dummyCubemapTex, umath::to_integral(PBRBinding::IrradianceMap)); - ds.SetBindingTexture(*dummyCubemapTex, umath::to_integral(PBRBinding::PrefilterMap)); - ds.SetBindingTexture(*dummyTex, umath::to_integral(PBRBinding::BRDFMap)); -} -prosper::IDescriptorSet &ShaderGlow::GetDefaultPbrDescriptorSet() const { return *m_defaultPbrDsg->GetDescriptorSet(); } -std::shared_ptr ShaderGlow::InitializeMaterialDescriptorSet(CMaterial &mat) { return InitializeMaterialDescriptorSet(mat, GetMaterialDescriptorSetInfo()); } -void ShaderGlow::InitializeGfxPipeline(prosper::GraphicsPipelineCreateInfo &pipelineInfo, uint32_t pipelineIdx) { ShaderGameWorldLightingPass::InitializeGfxPipeline(pipelineInfo, pipelineIdx); } - -// - -void ShaderGlow::RecordBindSceneDescriptorSets(rendering::ShaderProcessor &shaderProcessor, const pragma::CSceneComponent &scene, const pragma::CRasterizationRendererComponent &renderer, prosper::IDescriptorSet &dsScene, prosper::IDescriptorSet &dsRenderer, - prosper::IDescriptorSet &dsRenderSettings, prosper::IDescriptorSet &dsShadows, ShaderGameWorld::SceneFlags &inOutSceneFlags, float &outIblStrength) const -{ - outIblStrength = 1.f; - std::array descSets {&dsScene, &dsRenderer, &dsRenderSettings, &dsShadows, GetReflectionProbeDescriptorSet(scene, outIblStrength, inOutSceneFlags)}; - - static const std::vector dynamicOffsets {}; - shaderProcessor.GetCommandBuffer().RecordBindDescriptorSets(prosper::PipelineBindPoint::Graphics, shaderProcessor.GetCurrentPipelineLayout(), GetSceneDescriptorSetIndex(), descSets, dynamicOffsets); -} - -prosper::IDescriptorSet *ShaderGlow::GetReflectionProbeDescriptorSet(const pragma::CSceneComponent &scene, float &outIblStrength, ShaderGameWorld::SceneFlags &inOutSceneFlags) const -{ - auto &hCam = scene.GetActiveCamera(); - assert(hCam.valid()); - auto *dsPbr = CReflectionProbeComponent::FindDescriptorSetForClosestProbe(scene, hCam->GetEntity().GetPosition(), outIblStrength); - if(dsPbr == nullptr) // No reflection probe and therefore no IBL available. Fallback to non-IBL rendering. - { - dsPbr = &GetDefaultPbrDescriptorSet(); - inOutSceneFlags |= ShaderGameWorld::SceneFlags::NoIBL; - } - return dsPbr; -} - -void ShaderGlow::RecordBindScene(rendering::ShaderProcessor &shaderProcessor, const pragma::CSceneComponent &scene, const pragma::CRasterizationRendererComponent &renderer, prosper::IDescriptorSet &dsScene, prosper::IDescriptorSet &dsRenderer, prosper::IDescriptorSet &dsRenderSettings, - prosper::IDescriptorSet &dsShadows, const Vector4 &drawOrigin, ShaderGameWorld::SceneFlags &inOutSceneFlags) const -{ - auto iblStrength = 1.f; - RecordBindSceneDescriptorSets(shaderProcessor, scene, renderer, dsScene, dsRenderer, dsRenderSettings, dsShadows, inOutSceneFlags, iblStrength); - - ShaderGameWorldLightingPass::PushConstants pushConstants {}; - pushConstants.Initialize(); - pushConstants.debugMode = scene.GetDebugMode(); - pushConstants.reflectionProbeIntensity = iblStrength; - pushConstants.flags = inOutSceneFlags; - pushConstants.drawOrigin = drawOrigin; - shaderProcessor.GetCommandBuffer().RecordPushConstants(shaderProcessor.GetCurrentPipelineLayout(), prosper::ShaderStageFlags::VertexBit | prosper::ShaderStageFlags::FragmentBit, 0u, sizeof(pushConstants), &pushConstants); -}