summaryrefslogtreecommitdiff
path: root/scene/resources/shader_graph.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/shader_graph.cpp')
-rw-r--r--scene/resources/shader_graph.cpp47
1 files changed, 23 insertions, 24 deletions
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp
index c21feb0bf5..49e987727d 100644
--- a/scene/resources/shader_graph.cpp
+++ b/scene/resources/shader_graph.cpp
@@ -397,7 +397,6 @@ void ShaderGraph::_bind_methods() {
ADD_SIGNAL(MethodInfo("updated"));
-
#if 0
ClassDB::bind_method(D_METHOD("node_add"),&ShaderGraph::node_add );
ClassDB::bind_method(D_METHOD("node_remove"),&ShaderGraph::node_remove );
@@ -2076,32 +2075,32 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
const char *typestr[4]={"float","vec3","mat4","texture"};
-#define OUTNAME(id,slot) (String(typestr[get_node_output_slot_type(get_mode(),p_type,p_node->type,slot)])+" "+("nd"+itos(id)+"sl"+itos(slot)))
-#define OUTVAR(id,slot) ("nd"+itos(id)+"sl"+itos(slot))
-#define DEF_VEC(slot)\
- if (p_inputs[slot].ends_with("def")){\
- Vector3 v = p_node->defaults[slot];\
- code+=String(typestr[1])+" "+p_inputs[slot]+"=vec3("+v+");\n";\
+#define OUTNAME(id, slot) (String(typestr[get_node_output_slot_type(get_mode(), p_type, p_node->type, slot)]) + " " + ("nd" + itos(id) + "sl" + itos(slot)))
+#define OUTVAR(id, slot) ("nd" + itos(id) + "sl" + itos(slot))
+#define DEF_VEC(slot) \
+ if (p_inputs[slot].ends_with("def")) { \
+ Vector3 v = p_node->defaults[slot]; \
+ code += String(typestr[1]) + " " + p_inputs[slot] + "=vec3(" + v + ");\n"; \
}
-#define DEF_SCALAR(slot)\
- if (p_inputs[slot].ends_with("def")){\
- double v = p_node->defaults[slot];\
- code+=String(typestr[0])+" "+p_inputs[slot]+"="+rtos(v)+";\n";\
+#define DEF_SCALAR(slot) \
+ if (p_inputs[slot].ends_with("def")) { \
+ double v = p_node->defaults[slot]; \
+ code += String(typestr[0]) + " " + p_inputs[slot] + "=" + rtos(v) + ";\n"; \
}
-#define DEF_COLOR(slot)\
- if (p_inputs[slot].ends_with("def")){\
- Color col = p_node->defaults[slot];\
- code+=String(typestr[1])+" "+p_inputs[slot]+"=vec3("+rtos(col.r)+","+rtos(col.g)+","+rtos(col.b)+");\n";\
+#define DEF_COLOR(slot) \
+ if (p_inputs[slot].ends_with("def")) { \
+ Color col = p_node->defaults[slot]; \
+ code += String(typestr[1]) + " " + p_inputs[slot] + "=vec3(" + rtos(col.r) + "," + rtos(col.g) + "," + rtos(col.b) + ");\n"; \
}
-#define DEF_MATRIX(slot) \
- if (p_inputs[slot].ends_with("def")){\
- Transform xf = p_node->defaults[slot]; \
- code+=String(typestr[2])+" "+p_inputs[slot]+"=mat4(\n";\
- code+="\tvec4(vec3("+rtos(xf.basis.get_axis(0).x)+","+rtos(xf.basis.get_axis(0).y)+","+rtos(xf.basis.get_axis(0).z)+"),0),\n";\
- code+="\tvec4(vec3("+rtos(xf.basis.get_axis(1).x)+","+rtos(xf.basis.get_axis(1).y)+","+rtos(xf.basis.get_axis(1).z)+"),0),\n";\
- code+="\tvec4(vec3("+rtos(xf.basis.get_axis(2).x)+","+rtos(xf.basis.get_axis(2).y)+","+rtos(xf.basis.get_axis(2).z)+"),0),\n";\
- code+="\tvec4(vec3("+rtos(xf.origin.x)+","+rtos(xf.origin.y)+","+rtos(xf.origin.z)+"),1)\n";\
- code+=");\n";\
+#define DEF_MATRIX(slot) \
+ if (p_inputs[slot].ends_with("def")) { \
+ Transform xf = p_node->defaults[slot]; \
+ code += String(typestr[2]) + " " + p_inputs[slot] + "=mat4(\n"; \
+ code += "\tvec4(vec3(" + rtos(xf.basis.get_axis(0).x) + "," + rtos(xf.basis.get_axis(0).y) + "," + rtos(xf.basis.get_axis(0).z) + "),0),\n"; \
+ code += "\tvec4(vec3(" + rtos(xf.basis.get_axis(1).x) + "," + rtos(xf.basis.get_axis(1).y) + "," + rtos(xf.basis.get_axis(1).z) + "),0),\n"; \
+ code += "\tvec4(vec3(" + rtos(xf.basis.get_axis(2).x) + "," + rtos(xf.basis.get_axis(2).y) + "," + rtos(xf.basis.get_axis(2).z) + "),0),\n"; \
+ code += "\tvec4(vec3(" + rtos(xf.origin.x) + "," + rtos(xf.origin.y) + "," + rtos(xf.origin.z) + "),1)\n"; \
+ code += ");\n"; \
}
switch(p_node->type) {