summaryrefslogtreecommitdiff
path: root/scene/resources/shader_graph.cpp
diff options
context:
space:
mode:
authorSaracen <SaracenOne@gmail.com>2015-11-18 23:18:10 +0000
committerSaracen <SaracenOne@gmail.com>2015-11-18 23:18:10 +0000
commitdd00452997122029dd2f74a278574d781fd2bf5f (patch)
treee36f0c62cac499500724c2929100c042972d1a5c /scene/resources/shader_graph.cpp
parentc1d19ad258139c73e7aa81cf6e1fbd99e1bfe38b (diff)
parent94fdd01241749cb7a575ed5f9fa4c7bbb286901a (diff)
Merge branch 'master' of https://github.com/okamstudio/godot into shadow_color
Conflicts: drivers/gles2/shader_compiler_gles2.cpp
Diffstat (limited to 'scene/resources/shader_graph.cpp')
-rw-r--r--scene/resources/shader_graph.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp
index da4857ccca..7b67eaeda8 100644
--- a/scene/resources/shader_graph.cpp
+++ b/scene/resources/shader_graph.cpp
@@ -2084,7 +2084,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
#define DEF_MATRIX(slot) \
if (p_inputs[slot].ends_with("def")){\
Transform xf = p_node->defaults[slot]; \
- code+=String(typestr[3])+" "+p_inputs[slot]+"=mat4(\n";\
+ 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";\
@@ -2394,15 +2394,29 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
DEF_VEC(1);
DEF_VEC(2);
DEF_VEC(3);
- code += OUTNAME(p_node->id,0)+"=xform("+p_inputs[0]+","+p_inputs[1]+","+p_inputs[2]+","+","+p_inputs[3]+");\n";
+ code += OUTNAME(p_node->id, 0) + "=mat4(" +
+ "vec4(" + p_inputs[0] + ".x," + p_inputs[0] + ".y," + p_inputs[0] + ".z, 0.0),"
+ "vec4(" + p_inputs[1] + ".x," + p_inputs[1] + ".y," + p_inputs[1] + ".z, 0.0),"
+ "vec4(" + p_inputs[2] + ".x," + p_inputs[2] + ".y," + p_inputs[2] + ".z, 0.0),"
+ "vec4(" + p_inputs[3] + ".x," + p_inputs[3] + ".y," + p_inputs[3] + ".z, 1.0));\n";
}break;
case NODE_XFORM_TO_VEC: {
DEF_MATRIX(0);
- code += OUTNAME(p_node->id,0)+"="+p_inputs[0]+".x;\n";
- code += OUTNAME(p_node->id,1)+"="+p_inputs[0]+".y;\n";
- code += OUTNAME(p_node->id,2)+"="+p_inputs[0]+".z;\n";
- code += OUTNAME(p_node->id,3)+"="+p_inputs[0]+".o;\n";
+ code += OUTNAME(p_node->id, 0) + ";\n";
+ code += OUTNAME(p_node->id, 1) + ";\n";
+ code += OUTNAME(p_node->id, 2) + ";\n";
+ code += OUTNAME(p_node->id, 3) + ";\n";
+ code += "{\n";
+ code += "\tvec4 xform_row_01=" + p_inputs[0] + ".x;\n";
+ code += "\tvec4 xform_row_02=" + p_inputs[0] + ".y;\n";
+ code += "\tvec4 xform_row_03=" + p_inputs[0] + ".z;\n";
+ code += "\tvec4 xform_row_04=" + p_inputs[0] + ".w;\n";
+ code += "\t" + OUTVAR(p_node->id, 0) + "=vec3(xform_row_01.x, xform_row_01.y, xform_row_01.z);\n";
+ code += "\t" + OUTVAR(p_node->id, 1) + "=vec3(xform_row_02.x, xform_row_02.y, xform_row_02.z);\n";
+ code += "\t" + OUTVAR(p_node->id, 2) + "=vec3(xform_row_03.x, xform_row_03.y, xform_row_03.z);\n";
+ code += "\t" + OUTVAR(p_node->id, 3) + "=vec3(xform_row_04.x, xform_row_04.y, xform_row_04.z);\n";
+ code += "}\n";
}break;
case NODE_SCALAR_INTERP: {
DEF_SCALAR(0);