-
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(graph_shader): add vec3 global input parameter node
- Loading branch information
Showing
11 changed files
with
185 additions
and
47 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
39 changes: 39 additions & 0 deletions
39
core/client/include/pragma/rendering/shader_graph/nodes/base_input_parameter.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,39 @@ | ||
/* 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_BASE_SHADER_GRAPH_NODES_INPUT_PARAMETER_HPP__ | ||
#define __PRAGMA_BASE_SHADER_GRAPH_NODES_INPUT_PARAMETER_HPP__ | ||
|
||
#include "pragma/clientdefinitions.h" | ||
#include <cinttypes> | ||
#include <string_view> | ||
#include <string> | ||
|
||
import pragma.shadergraph; | ||
|
||
namespace pragma::rendering::shader_graph { | ||
class DLLCLIENT BaseInputParameterNode : public pragma::shadergraph::Node { | ||
public: | ||
enum class Scope : uint32_t { | ||
Global = 0, | ||
Object, | ||
Material, | ||
}; | ||
|
||
static constexpr const char *CONST_NAME = "name"; | ||
static constexpr const char *CONST_SCOPE = "scope"; | ||
static constexpr const char *CONST_DEFAULT = "default"; | ||
|
||
static constexpr const char *OUT_VALUE = "value"; | ||
|
||
BaseInputParameterNode(const std::string_view &type); | ||
virtual pragma::shadergraph::DataType GetParameterType() const = 0; | ||
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
24 changes: 24 additions & 0 deletions
24
core/client/include/pragma/rendering/shader_graph/nodes/input_parameter_vec3.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,24 @@ | ||
/* 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_INPUT_PARAMETER_VEC3_HPP__ | ||
#define __PRAGMA_SHADER_GRAPH_NODES_INPUT_PARAMETER_VEC3_HPP__ | ||
|
||
#include "pragma/rendering/shader_graph/nodes/base_input_parameter.hpp" | ||
|
||
import pragma.shadergraph; | ||
|
||
namespace pragma::rendering::shader_graph { | ||
class DLLCLIENT InputParameterVec3Node : public BaseInputParameterNode { | ||
public: | ||
InputParameterVec3Node(const std::string_view &type); | ||
virtual pragma::shadergraph::DataType GetParameterType() const override { return pragma::shadergraph::DataType::Vector; } | ||
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
36 changes: 36 additions & 0 deletions
36
core/client/src/rendering/shader_graph/nodes/base_input_parameter.cpp
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,36 @@ | ||
/* 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 | ||
*/ | ||
|
||
#include "stdafx_client.h" | ||
#include "pragma/rendering/shader_graph/nodes/base_input_parameter.hpp" | ||
|
||
using namespace pragma::rendering::shader_graph; | ||
|
||
BaseInputParameterNode::BaseInputParameterNode(const std::string_view &type) : Node {type} | ||
{ | ||
AddInput(CONST_NAME, pragma::shadergraph::DataType::String, ""); | ||
AddSocketEnum<Scope>(CONST_SCOPE, Scope::Global); | ||
|
||
AddModuleDependency("input_data"); | ||
} | ||
|
||
std::string BaseInputParameterNode::DoEvaluate(const pragma::shadergraph::Graph &graph, const pragma::shadergraph::GraphNode &gn) const | ||
{ | ||
std::ostringstream code; | ||
|
||
std::string name; | ||
gn.GetInputValue<std::string>(CONST_NAME, name); | ||
|
||
code << gn.GetGlslOutputDeclaration(OUT_VALUE) << " = "; | ||
// TODO: Check if name exists in global input data | ||
if(!name.empty()) | ||
code << "u_globalInputData." << name << ";\n"; | ||
else | ||
code << "0.0;\n"; | ||
|
||
return code.str(); | ||
} |
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
35 changes: 35 additions & 0 deletions
35
core/client/src/rendering/shader_graph/nodes/input_parameter_vec3.cpp
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,35 @@ | ||
/* 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 | ||
*/ | ||
|
||
#include "stdafx_client.h" | ||
#include "pragma/rendering/shader_graph/nodes/input_parameter_vec3.hpp" | ||
|
||
using namespace pragma::rendering::shader_graph; | ||
|
||
InputParameterVec3Node::InputParameterVec3Node(const std::string_view &type) : BaseInputParameterNode {type} | ||
{ | ||
AddInput(CONST_DEFAULT, pragma::shadergraph::DataType::Vector, Vector3 {0.f, 0.f, 0.f}); | ||
|
||
AddOutput(OUT_VALUE, pragma::shadergraph::DataType::Vector); | ||
} | ||
|
||
std::string InputParameterVec3Node::DoEvaluate(const pragma::shadergraph::Graph &graph, const pragma::shadergraph::GraphNode &gn) const | ||
{ | ||
std::ostringstream code; | ||
|
||
std::string name; | ||
gn.GetInputValue<std::string>(CONST_NAME, name); | ||
|
||
code << gn.GetGlslOutputDeclaration(OUT_VALUE) << " = "; | ||
// TODO: Check if name exists in global input data | ||
if(!name.empty()) | ||
code << "u_globalInputData." << name << ";\n"; | ||
else | ||
code << "0.0;\n"; | ||
|
||
return code.str(); | ||
} |