TerraForge3D  2.3.1
3D Terrain And Landscape Generator
ShaderNodeEditor.h
1#pragma once
2
3#include "Base/NodeEditor/NodeEditor.h"
4#include "Shading/SharedMemoryManager.h"
5#include "Shading/GLSLHandler.h"
6#include "Utils/Utils.h"
7
8
9// NOTE : These colors were suggested by GitHub Copilot
10
11#define FLOAT_PIN_COLOR 23, 245, 235
12#define FLOAT2_PIN_COLOR 223, 155, 121
13#define FLOAT3_PIN_COLOR 154, 231, 123
14#define BOOL_PIN_COLOR 150, 191, 235
15
16#define SHADER_OUTPUT_NODE_COLOR 152, 54, 12
17#define SHADER_VALUE_NODE_COLOR 144, 124, 255
18#define SHADER_TEXTURE_NODE_COLOR 145, 32, 123
19#define SHADER_MATERIAL_NODE_COLOR 251, 123, 144
20
21#define STR(x) std::to_string(x)
22#define VAR(x) std::string(x) + STR(id) + GenerateId(5)
23#define SDATA(x) std::string("data[") + STR(dataBlobOffset) + "].d[" + STR(x) + "]"
24
25enum SNEPinType
26{
27 SNEPinType_Float = 0,
28 SNEPinType_Float2,
29 SNEPinType_Float3,
30 SNEPinType_Bool
31};
32
33static NodeInputParam GetParams(GLSLFunction *function, GLSLLine *line)
34{
35 NodeInputParam param;
36 param.userData1 = static_cast<void *>(function);
37 param.userData2 = static_cast<void *>(line);
38 return param;
39}
40
41
42class SNEPin : public NodeEditorPin
43{
44public:
45 SNEPin(NodeEditorPinType type = NodeEditorPinType::Input, SNEPinType var = SNEPinType::SNEPinType_Float);
46
47 ~SNEPin();
48
49 SNEPinType GetType();
50 void SetType(SNEPinType type);
51};
52
53class SNENode : public NodeEditorNode
54{
55public:
56 SNENode(GLSLHandler *handler);
57 ~SNENode();
58
59 NodeOutput Evaluate(NodeInputParam input, NodeEditorPin *pin);
60
61 virtual bool OnLink(NodeEditorPin *pin, NodeEditorLink *link);
62
63 virtual void UpdateShaders() = 0;
64 virtual void OnRender() = 0;
65 virtual void OnEvaluate(GLSLFunction *function, GLSLLine *line) = 0;
66 virtual void Load(nlohmann::json data) = 0;
67 virtual nlohmann::json Save() = 0;
68
69public:
70 SharedMemoryItem *sharedData = nullptr;
71 int dataBlobOffset = 0;
72 int callerPinId = 0;
73 GLSLHandler *handler;
74};
75
a class to store JSON values
Definition: json.hpp:17860
SharedMemoryItem ! A data structure to be passed to the GPU.