-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shader_graph): add module system
- Loading branch information
Showing
13 changed files
with
411 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "/common/pbr/fs_pbr.glsl" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
core/client/include/pragma/rendering/shader_graph/module.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* 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 __SHADER_GRAPH_MODULE_HPP__ | ||
#define __SHADER_GRAPH_MODULE_HPP__ | ||
|
||
#include <pragma/clientdefinitions.h> | ||
#include "pragma/rendering/shaders/world/c_shader_scene.hpp" | ||
|
||
namespace prosper { | ||
class Shader; | ||
} | ||
|
||
namespace pragma { | ||
class CSceneComponent; | ||
class CRasterizationRendererComponent; | ||
}; | ||
|
||
class CModelSubMesh; | ||
namespace pragma::rendering { | ||
class ShaderProcessor; | ||
class DLLCLIENT ShaderGraphModule { | ||
public: | ||
ShaderGraphModule(prosper::Shader &shader) : m_shader(shader) {} | ||
virtual ~ShaderGraphModule() {} | ||
virtual void InitializeGfxPipelineDescriptorSets() = 0; | ||
virtual void UpdateRenderFlags(CModelSubMesh &mesh, ShaderGameWorld::SceneFlags &inOutFlags) {} | ||
virtual void RecordBindScene(ShaderProcessor &shaderProcessor, const pragma::CSceneComponent &scene, const pragma::CRasterizationRendererComponent &renderer, ShaderGameWorld::SceneFlags &inOutSceneFlags) const = 0; | ||
protected: | ||
prosper::Shader &m_shader; | ||
}; | ||
|
||
class DLLCLIENT ShaderGraphModuleManager { | ||
public: | ||
using Factory = std::function<std::unique_ptr<ShaderGraphModule>(prosper::Shader &shader)>; | ||
ShaderGraphModuleManager() {} | ||
void RegisterFactory(const std::string &name, const Factory &factory); | ||
std::unique_ptr<ShaderGraphModule> CreateModule(const std::string &name, prosper::Shader &shader) const; | ||
const std::unordered_map<std::string, Factory> &GetFactories() const { return m_factories; } | ||
private: | ||
std::unordered_map<std::string, Factory> m_factories; | ||
}; | ||
} | ||
|
||
#endif |
40 changes: 40 additions & 0 deletions
40
core/client/include/pragma/rendering/shader_graph/modules/pbr.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* 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) 2024 Silverlan | ||
*/ | ||
|
||
#ifndef __PRAGMA_SHADER_GRAPH_MODULES_PBR_HPP__ | ||
#define __PRAGMA_SHADER_GRAPH_MODULES_PBR_HPP__ | ||
|
||
#include "pragma/clientdefinitions.h" | ||
#include "pragma/rendering/shader_graph/module.hpp" | ||
|
||
import pragma.shadergraph; | ||
|
||
namespace pragma::rendering::shader_graph { | ||
class DLLCLIENT PbrModule : public pragma::rendering::ShaderGraphModule { | ||
public: | ||
public: | ||
enum class PBRBinding : uint32_t { | ||
IrradianceMap = 0u, | ||
PrefilterMap, | ||
BRDFMap, | ||
|
||
Count | ||
}; | ||
PbrModule(prosper::Shader &shader); | ||
virtual ~PbrModule() override; | ||
virtual void InitializeGfxPipelineDescriptorSets() override; | ||
virtual void RecordBindScene(rendering::ShaderProcessor &shaderProcessor, const pragma::CSceneComponent &scene, const pragma::CRasterizationRendererComponent &renderer, ShaderGameWorld::SceneFlags &inOutSceneFlags) const override; | ||
prosper::IDescriptorSet *GetReflectionProbeDescriptorSet(const pragma::CSceneComponent &scene, float &outIblStrength, ShaderGameWorld::SceneFlags &inOutSceneFlags) const; | ||
prosper::IDescriptorSet &GetDefaultPbrDescriptorSet() const; | ||
private: | ||
prosper::DescriptorSetInfo m_pbrDescSetInfo; | ||
static std::shared_ptr<prosper::IDescriptorSetGroup> g_defaultPbrDsg; | ||
static size_t g_instanceCount; | ||
}; | ||
}; | ||
|
||
#endif |
31 changes: 31 additions & 0 deletions
31
core/client/include/pragma/rendering/shader_graph/nodes/pbr.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* 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) 2024 Silverlan | ||
*/ | ||
|
||
#ifndef __PRAGMA_SHADER_GRAPH_NODES_PBR_HPP__ | ||
#define __PRAGMA_SHADER_GRAPH_NODES_PBR_HPP__ | ||
|
||
#include "pragma/clientdefinitions.h" | ||
|
||
import pragma.shadergraph; | ||
|
||
namespace pragma::rendering::shader_graph { | ||
class DLLCLIENT PbrNode : public pragma::shadergraph::Node { | ||
public: | ||
static constexpr const char *IN_ALBEDO_COLOR = "albedoColor"; | ||
static constexpr const char *IN_METALNESS = "metalness"; | ||
static constexpr const char *IN_ROUGHNESS = "roughness"; | ||
static constexpr const char *IN_AMBIENT_OCCLUSION = "ambientOcclusion"; | ||
|
||
static constexpr const char *OUT_COLOR = "color"; | ||
|
||
PbrNode(const std::string_view &type); | ||
|
||
virtual std::string DoEvaluate(const pragma::shadergraph::Graph &graph, const pragma::shadergraph::GraphNode &instance) const override; | ||
}; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.