-
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 base scene graph shader and node implementation
- Loading branch information
Showing
23 changed files
with
950 additions
and
7 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
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
32 changes: 32 additions & 0 deletions
32
core/client/include/pragma/rendering/shader_graph/nodes/camera.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,32 @@ | ||
/* 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_CAMERA_HPP__ | ||
#define __PRAGMA_SHADER_GRAPH_NODES_CAMERA_HPP__ | ||
|
||
#include "pragma/clientdefinitions.h" | ||
|
||
import pragma.shadergraph; | ||
|
||
namespace pragma::rendering::shader_graph { | ||
class DLLCLIENT CameraNode : public pragma::shadergraph::Node { | ||
public: | ||
static constexpr const char *OUT_POSITION = "position"; | ||
static constexpr const char *OUT_FOV = "fov"; | ||
static constexpr const char *OUT_NEARZ = "nearZ"; | ||
static constexpr const char *OUT_FARZ = "farZ"; | ||
static constexpr const char *OUT_VIEW_MATRIX = "viewMatrix"; | ||
static constexpr const char *OUT_PROJECTION_MATRIX = "projectionMatrix"; | ||
static constexpr const char *OUT_VIEW_PROJECTION_MATRIX = "viewProjectionMatrix"; | ||
|
||
CameraNode(const std::string_view &type); | ||
|
||
virtual std::string DoEvaluate(const pragma::shadergraph::Graph &graph, const pragma::shadergraph::GraphNode &instance) const override; | ||
}; | ||
}; | ||
|
||
#endif |
29 changes: 29 additions & 0 deletions
29
core/client/include/pragma/rendering/shader_graph/nodes/fog.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,29 @@ | ||
/* 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_FOG_HPP__ | ||
#define __PRAGMA_SHADER_GRAPH_NODES_FOG_HPP__ | ||
|
||
#include "pragma/clientdefinitions.h" | ||
|
||
import pragma.shadergraph; | ||
|
||
namespace pragma::rendering::shader_graph { | ||
class DLLCLIENT FogNode : public pragma::shadergraph::Node { | ||
public: | ||
static constexpr const char *OUT_COLOR = "color"; | ||
static constexpr const char *OUT_START_DISTANCE = "startDistance"; | ||
static constexpr const char *OUT_END_DISTANCE = "endDistance"; | ||
static constexpr const char *OUT_DENSITY = "density"; | ||
|
||
FogNode(const std::string_view &type); | ||
|
||
virtual std::string DoEvaluate(const pragma::shadergraph::Graph &graph, const pragma::shadergraph::GraphNode &instance) const override; | ||
}; | ||
}; | ||
|
||
#endif |
28 changes: 28 additions & 0 deletions
28
core/client/include/pragma/rendering/shader_graph/nodes/lightmap.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,28 @@ | ||
/* 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_LIGHTMAP_HPP__ | ||
#define __PRAGMA_SHADER_GRAPH_NODES_LIGHTMAP_HPP__ | ||
|
||
#include "pragma/clientdefinitions.h" | ||
|
||
import pragma.shadergraph; | ||
|
||
namespace pragma::rendering::shader_graph { | ||
class DLLCLIENT LightmapNode : public pragma::shadergraph::Node { | ||
public: | ||
static constexpr const char *OUT_LIGHT_MAP = "lightMap"; | ||
static constexpr const char *OUT_LIGHT_MAP_INDIRECT = "lightMapIndirect"; | ||
static constexpr const char *OUT_LIGHT_MAP_DOMINANT = "lightMapDominant"; | ||
|
||
LightmapNode(const std::string_view &type); | ||
|
||
virtual std::string DoEvaluate(const pragma::shadergraph::Graph &graph, const pragma::shadergraph::GraphNode &instance) const override; | ||
}; | ||
}; | ||
|
||
#endif |
27 changes: 27 additions & 0 deletions
27
core/client/include/pragma/rendering/shader_graph/nodes/object.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,27 @@ | ||
/* 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_OBJECT_HPP__ | ||
#define __PRAGMA_SHADER_GRAPH_NODES_OBJECT_HPP__ | ||
|
||
#include "pragma/clientdefinitions.h" | ||
|
||
import pragma.shadergraph; | ||
|
||
namespace pragma::rendering::shader_graph { | ||
class DLLCLIENT ObjectNode : public pragma::shadergraph::Node { | ||
public: | ||
static constexpr const char *OUT_MODEL_MATRIX = "modelMatrix"; | ||
static constexpr const char *OUT_COLOR = "color"; | ||
|
||
ObjectNode(const std::string_view &type); | ||
|
||
virtual std::string DoEvaluate(const pragma::shadergraph::Graph &graph, const pragma::shadergraph::GraphNode &instance) const override; | ||
}; | ||
}; | ||
|
||
#endif |
28 changes: 28 additions & 0 deletions
28
core/client/include/pragma/rendering/shader_graph/nodes/scene_output.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,28 @@ | ||
/* 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_SCENE_OUTPUT_HPP__ | ||
#define __PRAGMA_SHADER_GRAPH_NODES_SCENE_OUTPUT_HPP__ | ||
|
||
#include "pragma/clientdefinitions.h" | ||
|
||
import pragma.shadergraph; | ||
|
||
namespace pragma::rendering::shader_graph { | ||
class DLLCLIENT SceneOutputNode : public pragma::shadergraph::Node { | ||
public: | ||
static constexpr const char *IN_COLOR = "color"; | ||
static constexpr const char *IN_ALPHA = "alpha"; | ||
static constexpr const char *IN_BLOOM_COLOR = "bloomColor"; | ||
// TODO: Only allow one of these! | ||
SceneOutputNode(const std::string_view &type); | ||
|
||
virtual std::string DoEvaluate(const pragma::shadergraph::Graph &graph, const pragma::shadergraph::GraphNode &instance) const override; | ||
}; | ||
}; | ||
|
||
#endif |
27 changes: 27 additions & 0 deletions
27
core/client/include/pragma/rendering/shader_graph/nodes/shader_material.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,27 @@ | ||
/* 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_SHADER_MATERIAL_HPP__ | ||
#define __PRAGMA_SHADER_GRAPH_NODES_SHADER_MATERIAL_HPP__ | ||
|
||
#include "pragma/clientdefinitions.h" | ||
#include "pragma/rendering/shader_material/shader_material.hpp" | ||
|
||
import pragma.shadergraph; | ||
|
||
namespace pragma::rendering::shader_graph { | ||
class DLLCLIENT ShaderMaterialNode : public pragma::shadergraph::Node { | ||
public: | ||
ShaderMaterialNode(const std::string_view &type, const pragma::rendering::shader_material::ShaderMaterial &shaderMaterial); | ||
|
||
virtual std::string DoEvaluate(const pragma::shadergraph::Graph &graph, const pragma::shadergraph::GraphNode &instance) const override; | ||
private: | ||
const pragma::rendering::shader_material::ShaderMaterial &m_shaderMaterial; | ||
}; | ||
}; | ||
|
||
#endif |
29 changes: 29 additions & 0 deletions
29
core/client/include/pragma/rendering/shader_graph/nodes/time.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,29 @@ | ||
/* 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_TIME_HPP__ | ||
#define __PRAGMA_SHADER_GRAPH_NODES_TIME_HPP__ | ||
|
||
#include "pragma/clientdefinitions.h" | ||
|
||
import pragma.shadergraph; | ||
|
||
namespace pragma::rendering::shader_graph { | ||
class DLLCLIENT TimeNode : public pragma::shadergraph::Node { | ||
public: | ||
static constexpr const char *OUT_TIME = "time"; | ||
static constexpr const char *OUT_DELTA_TIME = "deltaTime"; | ||
static constexpr const char *OUT_REAL_TIME = "realTime"; | ||
static constexpr const char *OUT_DELTA_REAL_TIME = "deltaRealTime"; | ||
|
||
TimeNode(const std::string_view &type); | ||
|
||
virtual std::string DoEvaluate(const pragma::shadergraph::Graph &graph, const pragma::shadergraph::GraphNode &instance) const override; | ||
}; | ||
}; | ||
|
||
#endif |
68 changes: 68 additions & 0 deletions
68
core/client/include/pragma/rendering/shader_graph_manager.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,68 @@ | ||
/* 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_MANAGER_HPP__ | ||
#define __SHADER_GRAPH_MANAGER_HPP__ | ||
|
||
#include <pragma/clientdefinitions.h> | ||
#include <string> | ||
#include <unordered_map> | ||
#include <memory> | ||
|
||
import pragma.shadergraph; | ||
|
||
namespace pragma::rendering { | ||
class DLLCLIENT ShaderGraphData { | ||
public: | ||
ShaderGraphData(const std::string &typeName, const std::string &identifier, const std::shared_ptr<pragma::shadergraph::Graph> &graph) : m_typeName {typeName}, m_identifier {identifier}, m_graph {graph} {} | ||
const std::string &GetIdentifier() const { return m_identifier; } | ||
void GenerateGlsl(); | ||
private: | ||
std::string m_typeName; | ||
std::string m_identifier; | ||
std::shared_ptr<pragma::shadergraph::Graph> m_graph; | ||
}; | ||
|
||
class ShaderGraphManager; | ||
class DLLCLIENT ShaderGraphTypeManager { | ||
public: | ||
ShaderGraphTypeManager(const std::string &typeName, std::shared_ptr<pragma::shadergraph::NodeRegistry> nodeRegistry) : m_typeName {typeName}, m_nodeRegistry {nodeRegistry} {} | ||
void ReloadShader(const std::string &identifier); | ||
std::shared_ptr<ShaderGraphData> GetGraph(const std::string &identifier) const; | ||
const std::shared_ptr<pragma::shadergraph::NodeRegistry> &GetNodeRegistry() const { return m_nodeRegistry; } | ||
private: | ||
friend ShaderGraphManager; | ||
void RegisterGraph(const std::string &identifier, std::shared_ptr<pragma::shadergraph::Graph> graph); | ||
std::shared_ptr<pragma::shadergraph::Graph> RegisterGraph(const std::string &identifier); | ||
std::shared_ptr<pragma::shadergraph::Graph> CreateGraph() const; | ||
std::string m_typeName; | ||
std::unordered_map<std::string, std::shared_ptr<ShaderGraphData>> m_graphs; | ||
std::shared_ptr<pragma::shadergraph::NodeRegistry> m_nodeRegistry; | ||
}; | ||
|
||
class DLLCLIENT ShaderGraphManager { | ||
public: | ||
static constexpr const char *ROOT_GRAPH_PATH = "scripts/shader_data/graphs/"; | ||
static std::string GetShaderFilePath(const std::string &type, const std::string &identifier); | ||
static std::string GetShaderGraphFilePath(const std::string &type, const std::string &identifier); | ||
|
||
ShaderGraphManager() {} | ||
~ShaderGraphManager() {} | ||
const std::unordered_map<std::string, std::shared_ptr<ShaderGraphTypeManager>> &GetShaderGraphTypeManagers() const { return m_shaderGraphTypeManagers; } | ||
void RegisterGraphTypeManager(const std::string &type, std::shared_ptr<pragma::shadergraph::NodeRegistry> nodeRegistry); | ||
std::shared_ptr<pragma::shadergraph::Graph> RegisterGraph(const std::string &type, const std::string &identifier); | ||
std::shared_ptr<pragma::shadergraph::Graph> CreateGraph(const std::string &type) const; | ||
void ReloadShader(const std::string &identifier); | ||
std::shared_ptr<ShaderGraphData> GetGraph(const std::string &identifier) const; | ||
std::shared_ptr<pragma::shadergraph::NodeRegistry> GetNodeRegistry(const std::string &type) const; | ||
private: | ||
std::unordered_map<std::string, std::shared_ptr<ShaderGraphTypeManager>> m_shaderGraphTypeManagers; | ||
std::unordered_map<std::string, std::string> m_shaderNameToType; | ||
}; | ||
} | ||
|
||
#endif |
37 changes: 37 additions & 0 deletions
37
core/client/include/pragma/rendering/shaders/world/c_shader_graph.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,37 @@ | ||
/* 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 __C_SHADER_GRAPH_HPP__ | ||
#define __C_SHADER_GRAPH_HPP__ | ||
|
||
#include "pragma/rendering/shaders/world/c_shader_textured.hpp" | ||
|
||
class Texture; | ||
namespace pragma { | ||
class DLLCLIENT ShaderGraph : public ShaderGameWorldLightingPass { | ||
public: | ||
ShaderGraph(prosper::IPrContext &context, const std::string &identifier, const std::string &fsShader); | ||
|
||
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 &dsLights, prosper::IDescriptorSet &dsShadows, const Vector4 &drawOrigin, ShaderGameWorld::SceneFlags &inOutSceneFlags) const override; | ||
protected: | ||
using ShaderGameWorldLightingPass::RecordDraw; | ||
void RecordBindSceneDescriptorSets(rendering::ShaderProcessor &shaderProcessor, const pragma::CSceneComponent &scene, const pragma::CRasterizationRendererComponent &renderer, prosper::IDescriptorSet &dsScene, prosper::IDescriptorSet &dsRenderer, | ||
prosper::IDescriptorSet &dsRenderSettings, prosper::IDescriptorSet &dsLights, 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 InitializeMaterialData(const CMaterial &mat, const rendering::shader_material::ShaderMaterial &shaderMat, pragma::rendering::shader_material::ShaderMaterialData &inOutMatData) override; | ||
virtual void UpdateRenderFlags(CModelSubMesh &mesh, SceneFlags &inOutFlags) override; | ||
virtual void InitializeGfxPipelineDescriptorSets() override; | ||
std::shared_ptr<prosper::IDescriptorSetGroup> InitializeMaterialDescriptorSet(CMaterial &mat, const prosper::DescriptorSetInfo &descSetInfo); | ||
|
||
SceneFlags m_extRenderFlags = SceneFlags::None; | ||
std::shared_ptr<prosper::IDescriptorSetGroup> m_defaultPbrDsg = nullptr; | ||
}; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.