diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-11-18 19:36:47 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-11-18 19:36:47 -0300 |
commit | f0aeb036d1662b45f009e6ad1836dfd8a21c1181 (patch) | |
tree | baad0b34180e43ff9f78ba7771809d15c43ee432 /scene/resources | |
parent | fce4c6eecbb094d3e64fc6b3ffa3b0b292fc4f0e (diff) | |
parent | b54d96ceba19801f3ec59e1a611f74b428cdebe2 (diff) |
Merge pull request #2715 from SaracenOne/shader_fix_and_enhancement
Write to 4-dimensional position access and shader graph code generation fix.
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/shader_graph.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index 49a1bdccb1..d5204f45d5 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -2083,7 +2083,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";\ @@ -2393,15 +2393,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); |