Better visual shader code generation
This commit is contained in:
parent
4e7d75ccd3
commit
bfec48abf1
|
@ -33,6 +33,10 @@
|
||||||
#include "core/vmap.h"
|
#include "core/vmap.h"
|
||||||
#include "servers/visual/shader_types.h"
|
#include "servers/visual/shader_types.h"
|
||||||
|
|
||||||
|
bool VisualShaderNode::is_simple_decl() const {
|
||||||
|
return simple_decl;
|
||||||
|
}
|
||||||
|
|
||||||
void VisualShaderNode::set_output_port_for_preview(int p_index) {
|
void VisualShaderNode::set_output_port_for_preview(int p_index) {
|
||||||
|
|
||||||
port_preview = p_index;
|
port_preview = p_index;
|
||||||
|
@ -132,6 +136,7 @@ void VisualShaderNode::_bind_methods() {
|
||||||
|
|
||||||
VisualShaderNode::VisualShaderNode() {
|
VisualShaderNode::VisualShaderNode() {
|
||||||
port_preview = -1;
|
port_preview = -1;
|
||||||
|
simple_decl = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
|
@ -273,6 +278,7 @@ void VisualShaderNodeCustom::_bind_methods() {
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeCustom::VisualShaderNodeCustom() {
|
VisualShaderNodeCustom::VisualShaderNodeCustom() {
|
||||||
|
simple_decl = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
|
@ -1104,17 +1110,17 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui
|
||||||
} else if (in_type == out_type) {
|
} else if (in_type == out_type) {
|
||||||
inputs[i] = src_var;
|
inputs[i] = src_var;
|
||||||
} else if (in_type == VisualShaderNode::PORT_TYPE_SCALAR && out_type == VisualShaderNode::PORT_TYPE_VECTOR) {
|
} else if (in_type == VisualShaderNode::PORT_TYPE_SCALAR && out_type == VisualShaderNode::PORT_TYPE_VECTOR) {
|
||||||
inputs[i] = "dot(" + src_var + ",vec3(0.333333,0.333333,0.333333))";
|
inputs[i] = "dot(" + src_var + ", vec3(0.333333, 0.333333, 0.333333))";
|
||||||
} else if (in_type == VisualShaderNode::PORT_TYPE_VECTOR && out_type == VisualShaderNode::PORT_TYPE_SCALAR) {
|
} else if (in_type == VisualShaderNode::PORT_TYPE_VECTOR && out_type == VisualShaderNode::PORT_TYPE_SCALAR) {
|
||||||
inputs[i] = "vec3(" + src_var + ")";
|
inputs[i] = "vec3(" + src_var + ")";
|
||||||
} else if (in_type == VisualShaderNode::PORT_TYPE_BOOLEAN && out_type == VisualShaderNode::PORT_TYPE_VECTOR) {
|
} else if (in_type == VisualShaderNode::PORT_TYPE_BOOLEAN && out_type == VisualShaderNode::PORT_TYPE_VECTOR) {
|
||||||
inputs[i] = "all(bvec3(" + src_var + "))";
|
inputs[i] = "all(bvec3(" + src_var + "))";
|
||||||
} else if (in_type == VisualShaderNode::PORT_TYPE_BOOLEAN && out_type == VisualShaderNode::PORT_TYPE_SCALAR) {
|
} else if (in_type == VisualShaderNode::PORT_TYPE_BOOLEAN && out_type == VisualShaderNode::PORT_TYPE_SCALAR) {
|
||||||
inputs[i] = src_var + ">0.0?true:false";
|
inputs[i] = src_var + " > 0.0 ? true : false";
|
||||||
} else if (in_type == VisualShaderNode::PORT_TYPE_SCALAR && out_type == VisualShaderNode::PORT_TYPE_BOOLEAN) {
|
} else if (in_type == VisualShaderNode::PORT_TYPE_SCALAR && out_type == VisualShaderNode::PORT_TYPE_BOOLEAN) {
|
||||||
inputs[i] = src_var + "?1.0:0.0";
|
inputs[i] = src_var + " ? 1.0 : 0.0";
|
||||||
} else if (in_type == VisualShaderNode::PORT_TYPE_VECTOR && out_type == VisualShaderNode::PORT_TYPE_BOOLEAN) {
|
} else if (in_type == VisualShaderNode::PORT_TYPE_VECTOR && out_type == VisualShaderNode::PORT_TYPE_BOOLEAN) {
|
||||||
inputs[i] = "vec3(" + src_var + "?1.0:0.0)";
|
inputs[i] = "vec3(" + src_var + " ? 1.0 : 0.0)";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -1130,7 +1136,7 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui
|
||||||
} else if (defval.get_type() == Variant::VECTOR3) {
|
} else if (defval.get_type() == Variant::VECTOR3) {
|
||||||
Vector3 val = defval;
|
Vector3 val = defval;
|
||||||
inputs[i] = "n_in" + itos(node) + "p" + itos(i);
|
inputs[i] = "n_in" + itos(node) + "p" + itos(i);
|
||||||
code += "\tvec3 " + inputs[i] + " = " + vformat("vec3(%.5f,%.5f,%.5f);\n", val.x, val.y, val.z);
|
code += "\tvec3 " + inputs[i] + " = " + vformat("vec3(%.5f, %.5f, %.5f);\n", val.x, val.y, val.z);
|
||||||
} else if (defval.get_type() == Variant::TRANSFORM) {
|
} else if (defval.get_type() == Variant::TRANSFORM) {
|
||||||
Transform val = defval;
|
Transform val = defval;
|
||||||
val.basis.transpose();
|
val.basis.transpose();
|
||||||
|
@ -1145,7 +1151,7 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui
|
||||||
values.push_back(val.origin.y);
|
values.push_back(val.origin.y);
|
||||||
values.push_back(val.origin.z);
|
values.push_back(val.origin.z);
|
||||||
bool err = false;
|
bool err = false;
|
||||||
code += "\tmat4 " + inputs[i] + " = " + String("mat4( vec4(%.5f,%.5f,%.5f,0.0),vec4(%.5f,%.5f,%.5f,0.0),vec4(%.5f,%.5f,%.5f,0.0),vec4(%.5f,%.5f,%.5f,1.0) );\n").sprintf(values, &err);
|
code += "\tmat4 " + inputs[i] + " = " + String("mat4(vec4(%.5f, %.5f, %.5f, 0.0), vec4(%.5f, %.5f, %.5f, 0.0), vec4(%.5f, %.5f, %.5f, 0.0), vec4(%.5f, %.5f, %.5f, 1.0));\n").sprintf(values, &err);
|
||||||
} else {
|
} else {
|
||||||
//will go empty, node is expected to know what it is doing at this point and handle it
|
//will go empty, node is expected to know what it is doing at this point and handle it
|
||||||
}
|
}
|
||||||
|
@ -1157,15 +1163,29 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui
|
||||||
output_vars.resize(vsnode->get_output_port_count());
|
output_vars.resize(vsnode->get_output_port_count());
|
||||||
String *outputs = output_vars.ptrw();
|
String *outputs = output_vars.ptrw();
|
||||||
|
|
||||||
for (int i = 0; i < output_count; i++) {
|
if (vsnode->is_simple_decl()) { // less code to generate for some simple_decl nodes
|
||||||
|
for (int i = 0; i < output_count; i++) {
|
||||||
|
String var_name = "n_out" + itos(node) + "p" + itos(i);
|
||||||
|
switch (vsnode->get_output_port_type(i)) {
|
||||||
|
case VisualShaderNode::PORT_TYPE_SCALAR: outputs[i] = "float " + var_name; break;
|
||||||
|
case VisualShaderNode::PORT_TYPE_VECTOR: outputs[i] = "vec3 " + var_name; break;
|
||||||
|
case VisualShaderNode::PORT_TYPE_BOOLEAN: outputs[i] = "bool " + var_name; break;
|
||||||
|
case VisualShaderNode::PORT_TYPE_TRANSFORM: outputs[i] = "mat4 " + var_name; break;
|
||||||
|
default: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
outputs[i] = "n_out" + itos(node) + "p" + itos(i);
|
} else {
|
||||||
switch (vsnode->get_output_port_type(i)) {
|
for (int i = 0; i < output_count; i++) {
|
||||||
case VisualShaderNode::PORT_TYPE_SCALAR: code += String() + "\tfloat " + outputs[i] + ";\n"; break;
|
outputs[i] = "n_out" + itos(node) + "p" + itos(i);
|
||||||
case VisualShaderNode::PORT_TYPE_VECTOR: code += String() + "\tvec3 " + outputs[i] + ";\n"; break;
|
switch (vsnode->get_output_port_type(i)) {
|
||||||
case VisualShaderNode::PORT_TYPE_BOOLEAN: code += String() + "\tbool " + outputs[i] + ";\n"; break;
|
case VisualShaderNode::PORT_TYPE_SCALAR: code += String() + "\tfloat " + outputs[i] + ";\n"; break;
|
||||||
case VisualShaderNode::PORT_TYPE_TRANSFORM: code += String() + "\tmat4 " + outputs[i] + ";\n"; break;
|
case VisualShaderNode::PORT_TYPE_VECTOR: code += String() + "\tvec3 " + outputs[i] + ";\n"; break;
|
||||||
default: {
|
case VisualShaderNode::PORT_TYPE_BOOLEAN: code += String() + "\tbool " + outputs[i] + ";\n"; break;
|
||||||
|
case VisualShaderNode::PORT_TYPE_TRANSFORM: code += String() + "\tmat4 " + outputs[i] + ";\n"; break;
|
||||||
|
default: {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1432,8 +1452,8 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::ports[] = {
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "normal", "NORMAL" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "normal", "NORMAL" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "tangent", "TANGENT" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "tangent", "TANGENT" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "binormal", "BINORMAL" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "binormal", "BINORMAL" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV,0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV, 0.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "uv2", "vec3(UV2,0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "uv2", "vec3(UV2, 0.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR.rgb" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR.rgb" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "COLOR.a" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "COLOR.a" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "point_size", "POINT_SIZE" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "point_size", "POINT_SIZE" },
|
||||||
|
@ -1455,13 +1475,13 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::ports[] = {
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "tangent", "TANGENT" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "tangent", "TANGENT" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "binormal", "BINORMAL" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "binormal", "BINORMAL" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "view", "VIEW" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "view", "VIEW" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV,0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV, 0.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "uv2", "vec3(UV2,0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "uv2", "vec3(UV2, 0.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR.rgb" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR.rgb" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "COLOR.a" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "COLOR.a" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "point_coord", "vec3(POINT_COORD,0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "point_coord", "vec3(POINT_COORD, 0.0)" },
|
||||||
|
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV,0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV, 0.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "side", "float(FRONT_FACING ? 1.0 : 0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "side", "float(FRONT_FACING ? 1.0 : 0.0)" },
|
||||||
|
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_TRANSFORM, "world", "WORLD_MATRIX" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_TRANSFORM, "world", "WORLD_MATRIX" },
|
||||||
|
@ -1498,7 +1518,7 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::ports[] = {
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "viewport_size", "vec3(VIEWPORT_SIZE, 0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "viewport_size", "vec3(VIEWPORT_SIZE, 0.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_BOOLEAN, "output_is_srgb", "OUTPUT_IS_SRGB" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_BOOLEAN, "output_is_srgb", "OUTPUT_IS_SRGB" },
|
||||||
// Canvas Item, Vertex
|
// Canvas Item, Vertex
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "vertex", "vec3(VERTEX,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "vertex", "vec3(VERTEX, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV,0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR.rgb" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR.rgb" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "COLOR.a" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "COLOR.a" },
|
||||||
|
@ -1512,13 +1532,13 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::ports[] = {
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "light_pass", "float(AT_LIGHT_PASS ? 1.0 : 0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "light_pass", "float(AT_LIGHT_PASS ? 1.0 : 0.0)" },
|
||||||
// Canvas Item, Fragment
|
// Canvas Item, Fragment
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "fragcoord", "FRAGCOORD.xyz" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "fragcoord", "FRAGCOORD.xyz" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR.rgb" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR.rgb" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "COLOR.a" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "COLOR.a" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "texture_pixel_size", "vec3(TEXTURE_PIXEL_SIZE, 1.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "texture_pixel_size", "vec3(TEXTURE_PIXEL_SIZE, 1.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_pixel_size", "vec3(SCREEN_PIXEL_SIZE, 1.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_pixel_size", "vec3(SCREEN_PIXEL_SIZE, 1.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "point_coord", "vec3(POINT_COORD,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "point_coord", "vec3(POINT_COORD, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "light_pass", "float(AT_LIGHT_PASS ? 1.0 : 0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "light_pass", "float(AT_LIGHT_PASS ? 1.0 : 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SAMPLER, "texture", "TEXTURE" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SAMPLER, "texture", "TEXTURE" },
|
||||||
|
@ -1526,19 +1546,19 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::ports[] = {
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SAMPLER, "screen_texture", "SCREEN_TEXTURE" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SAMPLER, "screen_texture", "SCREEN_TEXTURE" },
|
||||||
// Canvas Item, Light
|
// Canvas Item, Light
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "fragcoord", "FRAGCOORD.xyz" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "fragcoord", "FRAGCOORD.xyz" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "normal", "NORMAL" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "normal", "NORMAL" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR.rgb" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR.rgb" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "COLOR.a" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "COLOR.a" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "light_vec", "vec3(LIGHT_VEC,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "light_vec", "vec3(LIGHT_VEC, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SCALAR, "light_height", "LIGHT_HEIGHT" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SCALAR, "light_height", "LIGHT_HEIGHT" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "light_color", "LIGHT_COLOR.rgb" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "light_color", "LIGHT_COLOR.rgb" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "light_alpha", "LIGHT_COLOR.a" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "light_alpha", "LIGHT_COLOR.a" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "light_uv", "vec3(LIGHT_UV,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "light_uv", "vec3(LIGHT_UV, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "shadow_color", "SHADOW_COLOR.rgb" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "shadow_color", "SHADOW_COLOR.rgb" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "texture_pixel_size", "vec3(TEXTURE_PIXEL_SIZE, 1.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "texture_pixel_size", "vec3(TEXTURE_PIXEL_SIZE, 1.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "point_coord", "vec3(POINT_COORD,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "point_coord", "vec3(POINT_COORD, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SAMPLER, "texture", "TEXTURE" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SAMPLER, "texture", "TEXTURE" },
|
||||||
|
|
||||||
|
@ -1564,48 +1584,48 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::ports[] = {
|
||||||
const VisualShaderNodeInput::Port VisualShaderNodeInput::preview_ports[] = {
|
const VisualShaderNodeInput::Port VisualShaderNodeInput::preview_ports[] = {
|
||||||
|
|
||||||
// Spatial, Fragment
|
// Spatial, Fragment
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "normal", "vec3(0.0,0.0,1.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "normal", "vec3(0.0, 0.0, 1.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "tangent", "vec3(0.0,1.0,0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "tangent", "vec3(0.0, 1.0, 0.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "binormal", "vec3(1.0,0.0,0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "binormal", "vec3(1.0, 0.0, 0.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV,0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV, 0.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "uv2", "vec3(UV,0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "uv2", "vec3(UV, 0.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "vec3(1.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "vec3(1.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "1.0" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "1.0" },
|
||||||
|
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV,0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV, 0.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "side", "1.0" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "side", "1.0" },
|
||||||
|
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "viewport_size", "vec3(1.0,1.0, 0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "viewport_size", "vec3(1.0,1.0, 0.0)" },
|
||||||
|
|
||||||
// Spatial, Light
|
// Spatial, Light
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "normal", "vec3(0.0,0.0,1.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "normal", "vec3(0.0, 0.0, 1.0)" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
||||||
{ Shader::MODE_SPATIAL, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "viewport_size", "vec3(1.0, 1.0, 0.0)" },
|
{ Shader::MODE_SPATIAL, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "viewport_size", "vec3(1.0, 1.0, 0.0)" },
|
||||||
// Canvas Item, Vertex
|
// Canvas Item, Vertex
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "vertex", "vec3(VERTEX,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "vertex", "vec3(VERTEX, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "color", "vec3(1.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "color", "vec3(1.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "1.0" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "1.0" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
||||||
// Canvas Item, Fragment
|
// Canvas Item, Fragment
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "vec3(1.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "vec3(1.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "1.0" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "1.0" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
||||||
// Canvas Item, Light
|
// Canvas Item, Light
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "uv", "vec3(UV, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "normal", "vec3(0.0,0.0,1.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "normal", "vec3(0.0, 0.0, 1.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "vec3(1.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "vec3(1.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "1.0" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "1.0" },
|
||||||
|
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV,0.0)" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV, 0.0)" },
|
||||||
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
||||||
// Particles, Vertex
|
// Particles, Vertex
|
||||||
{ Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "color", "vec3(1.0)" },
|
{ Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "color", "vec3(1.0)" },
|
||||||
{ Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "1.0" },
|
{ Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "1.0" },
|
||||||
{ Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "velocity", "vec3(0.0,0.0,1.0)" },
|
{ Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "velocity", "vec3(0.0, 0.0, 1.0)" },
|
||||||
{ Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
{ Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
|
||||||
{ Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, NULL, NULL },
|
{ Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, NULL, NULL },
|
||||||
};
|
};
|
||||||
|
@ -2514,6 +2534,7 @@ VisualShaderNodeGroupBase::VisualShaderNodeGroupBase() {
|
||||||
inputs = "";
|
inputs = "";
|
||||||
outputs = "";
|
outputs = "";
|
||||||
editable = false;
|
editable = false;
|
||||||
|
simple_decl = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////// Expression
|
////////////// Expression
|
||||||
|
@ -2615,7 +2636,7 @@ String VisualShaderNodeExpression::generate_code(Shader::Mode p_mode, VisualShad
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
output_initializer += "\t" + p_output_vars[i] + "=" + tk + ";\n";
|
output_initializer += "\t" + p_output_vars[i] + " = " + tk + ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
String code;
|
String code;
|
||||||
|
|
|
@ -176,6 +176,7 @@ class VisualShaderNode : public Resource {
|
||||||
Map<int, Variant> default_input_values;
|
Map<int, Variant> default_input_values;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool simple_decl;
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -188,6 +189,8 @@ public:
|
||||||
PORT_TYPE_MAX,
|
PORT_TYPE_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool is_simple_decl() const;
|
||||||
|
|
||||||
virtual String get_caption() const = 0;
|
virtual String get_caption() const = 0;
|
||||||
|
|
||||||
virtual int get_input_port_count() const = 0;
|
virtual int get_input_port_count() const = 0;
|
||||||
|
|
|
@ -187,7 +187,7 @@ String VisualShaderNodeColorConstant::get_output_port_name(int p_port) const {
|
||||||
String VisualShaderNodeColorConstant::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeColorConstant::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
|
|
||||||
String code;
|
String code;
|
||||||
code += "\t" + p_output_vars[0] + " = " + vformat("vec3(%.6f,%.6f,%.6f)", constant.r, constant.g, constant.b) + ";\n";
|
code += "\t" + p_output_vars[0] + " = " + vformat("vec3(%.6f, %.6f, %.6f)", constant.r, constant.g, constant.b) + ";\n";
|
||||||
code += "\t" + p_output_vars[1] + " = " + vformat("%.6f", constant.a) + ";\n";
|
code += "\t" + p_output_vars[1] + " = " + vformat("%.6f", constant.a) + ";\n";
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -253,7 +253,7 @@ String VisualShaderNodeVec3Constant::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeVec3Constant::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeVec3Constant::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = " + vformat("vec3(%.6f,%.6f,%.6f)", constant.x, constant.y, constant.z) + ";\n";
|
return "\t" + p_output_vars[0] + " = " + vformat("vec3(%.6f, %.6f, %.6f)", constant.x, constant.y, constant.z) + ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualShaderNodeVec3Constant::set_constant(Vector3 p_value) {
|
void VisualShaderNodeVec3Constant::set_constant(Vector3 p_value) {
|
||||||
|
@ -319,10 +319,10 @@ String VisualShaderNodeTransformConstant::generate_code(Shader::Mode p_mode, Vis
|
||||||
t.basis.transpose();
|
t.basis.transpose();
|
||||||
|
|
||||||
String code = "\t" + p_output_vars[0] + " = mat4(";
|
String code = "\t" + p_output_vars[0] + " = mat4(";
|
||||||
code += vformat("vec4(%.6f,%.6f,%.6f,0.0),", t.basis[0].x, t.basis[0].y, t.basis[0].z);
|
code += vformat("vec4(%.6f, %.6f, %.6f, 0.0), ", t.basis[0].x, t.basis[0].y, t.basis[0].z);
|
||||||
code += vformat("vec4(%.6f,%.6f,%.6f,0.0),", t.basis[1].x, t.basis[1].y, t.basis[1].z);
|
code += vformat("vec4(%.6f, %.6f, %.6f, 0.0), ", t.basis[1].x, t.basis[1].y, t.basis[1].z);
|
||||||
code += vformat("vec4(%.6f,%.6f,%.6f,0.0),", t.basis[2].x, t.basis[2].y, t.basis[2].z);
|
code += vformat("vec4(%.6f, %.6f, %.6f, 0.0), ", t.basis[2].x, t.basis[2].y, t.basis[2].z);
|
||||||
code += vformat("vec4(%.6f,%.6f,%.6f,1.0) );\n", t.origin.x, t.origin.y, t.origin.z);
|
code += vformat("vec4(%.6f, %.6f, %.6f, 1.0));\n", t.origin.x, t.origin.y, t.origin.z);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,7 +440,7 @@ String VisualShaderNodeTexture::generate_global(Shader::Mode p_mode, VisualShade
|
||||||
case TYPE_COLOR: u += " : hint_albedo"; break;
|
case TYPE_COLOR: u += " : hint_albedo"; break;
|
||||||
case TYPE_NORMALMAP: u += " : hint_normal"; break;
|
case TYPE_NORMALMAP: u += " : hint_normal"; break;
|
||||||
}
|
}
|
||||||
return u + ";";
|
return u + ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return String();
|
return String();
|
||||||
|
@ -454,16 +454,16 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader:
|
||||||
if (p_input_vars[0] == String()) { // Use UV by default.
|
if (p_input_vars[0] == String()) { // Use UV by default.
|
||||||
|
|
||||||
if (p_input_vars[1] == String()) {
|
if (p_input_vars[1] == String()) {
|
||||||
code += "\tvec4 " + id + "_read = texture( " + id + " , UV.xy );\n";
|
code += "\tvec4 " + id + "_read = texture(" + id + ", UV.xy);\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\tvec4 " + id + "_read = textureLod( " + id + " , UV.xy , " + p_input_vars[1] + " );\n";
|
code += "\tvec4 " + id + "_read = textureLod(" + id + ", UV.xy, " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (p_input_vars[1] == String()) {
|
} else if (p_input_vars[1] == String()) {
|
||||||
//no lod
|
//no lod
|
||||||
code += "\tvec4 " + id + "_read = texture( " + id + " , " + p_input_vars[0] + ".xy );\n";
|
code += "\tvec4 " + id + "_read = texture(" + id + ", " + p_input_vars[0] + ".xy);\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\tvec4 " + id + "_read = textureLod( " + id + " , " + p_input_vars[0] + ".xy , " + p_input_vars[1] + " );\n";
|
code += "\tvec4 " + id + "_read = textureLod(" + id + ", " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
code += "\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n";
|
code += "\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n";
|
||||||
|
@ -482,16 +482,16 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader:
|
||||||
if (p_input_vars[0] == String()) { // Use UV by default.
|
if (p_input_vars[0] == String()) { // Use UV by default.
|
||||||
|
|
||||||
if (p_input_vars[1] == String()) {
|
if (p_input_vars[1] == String()) {
|
||||||
code += "\t\tvec4 " + id + "_tex_read = texture( " + id + " , UV.xy );\n";
|
code += "\t\tvec4 " + id + "_tex_read = texture(" + id + ", UV.xy);\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tvec4 " + id + "_tex_read = textureLod( " + id + " , UV.xy , " + p_input_vars[1] + " );\n";
|
code += "\t\tvec4 " + id + "_tex_read = textureLod(" + id + ", UV.xy, " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (p_input_vars[1] == String()) {
|
} else if (p_input_vars[1] == String()) {
|
||||||
//no lod
|
//no lod
|
||||||
code += "\t\tvec4 " + id + "_tex_read = texture( " + id + " , " + p_input_vars[0] + ".xy );\n";
|
code += "\t\tvec4 " + id + "_tex_read = texture(" + id + ", " + p_input_vars[0] + ".xy);\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tvec4 " + id + "_tex_read = textureLod( " + id + " , " + p_input_vars[0] + ".xy , " + p_input_vars[1] + " );\n";
|
code += "\t\tvec4 " + id + "_tex_read = textureLod(" + id + ", " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
code += "\t\t" + p_output_vars[0] + " = " + id + "_tex_read.rgb;\n";
|
code += "\t\t" + p_output_vars[0] + " = " + id + "_tex_read.rgb;\n";
|
||||||
|
@ -507,16 +507,16 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader:
|
||||||
if (p_input_vars[0] == String() || p_for_preview) { // Use UV by default.
|
if (p_input_vars[0] == String() || p_for_preview) { // Use UV by default.
|
||||||
|
|
||||||
if (p_input_vars[1] == String()) {
|
if (p_input_vars[1] == String()) {
|
||||||
code += "\t\tvec4 _tex_read = textureLod( SCREEN_TEXTURE , UV.xy , 0.0 );\n";
|
code += "\t\tvec4 _tex_read = textureLod(SCREEN_TEXTURE, UV.xy, 0.0 );\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tvec4 _tex_read = textureLod( SCREEN_TEXTURE , UV.xy , " + p_input_vars[1] + ");\n";
|
code += "\t\tvec4 _tex_read = textureLod(SCREEN_TEXTURE, UV.xy, " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (p_input_vars[1] == String()) {
|
} else if (p_input_vars[1] == String()) {
|
||||||
//no lod
|
//no lod
|
||||||
code += "\t\tvec4 _tex_read = textureLod( SCREEN_TEXTURE , " + p_input_vars[0] + ".xy , 0.0 );\n";
|
code += "\t\tvec4 _tex_read = textureLod(SCREEN_TEXTURE, " + p_input_vars[0] + ".xy, 0.0);\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tvec4 _tex_read = textureLod( SCREEN_TEXTURE , " + p_input_vars[0] + ".xy , " + p_input_vars[1] + " );\n";
|
code += "\t\tvec4 _tex_read = textureLod(SCREEN_TEXTURE, " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
code += "\t\t" + p_output_vars[0] + " = _tex_read.rgb;\n";
|
code += "\t\t" + p_output_vars[0] + " = _tex_read.rgb;\n";
|
||||||
|
@ -531,16 +531,16 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader:
|
||||||
if (p_input_vars[0] == String()) { // Use UV by default.
|
if (p_input_vars[0] == String()) { // Use UV by default.
|
||||||
|
|
||||||
if (p_input_vars[1] == String()) {
|
if (p_input_vars[1] == String()) {
|
||||||
code += "\t\tvec4 _tex_read = texture( TEXTURE , UV.xy );\n";
|
code += "\t\tvec4 _tex_read = texture(TEXTURE , UV.xy);\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tvec4 _tex_read = textureLod( TEXTURE , UV.xy , " + p_input_vars[1] + " );\n";
|
code += "\t\tvec4 _tex_read = textureLod(TEXTURE, UV.xy, " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (p_input_vars[1] == String()) {
|
} else if (p_input_vars[1] == String()) {
|
||||||
//no lod
|
//no lod
|
||||||
code += "\t\tvec4 _tex_read = texture( TEXTURE , " + p_input_vars[0] + ".xy );\n";
|
code += "\t\tvec4 _tex_read = texture(TEXTURE, " + p_input_vars[0] + ".xy);\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tvec4 _tex_read = textureLod( TEXTURE , " + p_input_vars[0] + ".xy , " + p_input_vars[1] + " );\n";
|
code += "\t\tvec4 _tex_read = textureLod(TEXTURE, " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
code += "\t\t" + p_output_vars[0] + " = _tex_read.rgb;\n";
|
code += "\t\t" + p_output_vars[0] + " = _tex_read.rgb;\n";
|
||||||
|
@ -555,16 +555,16 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader:
|
||||||
if (p_input_vars[0] == String()) { // Use UV by default.
|
if (p_input_vars[0] == String()) { // Use UV by default.
|
||||||
|
|
||||||
if (p_input_vars[1] == String()) {
|
if (p_input_vars[1] == String()) {
|
||||||
code += "\t\tvec4 _tex_read = texture( NORMAL_TEXTURE , UV.xy );\n";
|
code += "\t\tvec4 _tex_read = texture(NORMAL_TEXTURE, UV.xy);\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tvec4 _tex_read = textureLod( NORMAL_TEXTURE , UV.xy , " + p_input_vars[1] + " );\n";
|
code += "\t\tvec4 _tex_read = textureLod(NORMAL_TEXTURE, UV.xy, " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (p_input_vars[1] == String()) {
|
} else if (p_input_vars[1] == String()) {
|
||||||
//no lod
|
//no lod
|
||||||
code += "\t\tvec4 _tex_read = texture( NORMAL_TEXTURE , " + p_input_vars[0] + ".xy );\n";
|
code += "\t\tvec4 _tex_read = texture(NORMAL_TEXTURE, " + p_input_vars[0] + ".xy);\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tvec4 _tex_read = textureLod( NORMAL_TEXTURE , " + p_input_vars[0] + ".xy , " + p_input_vars[1] + " );\n";
|
code += "\t\tvec4 _tex_read = textureLod(NORMAL_TEXTURE, " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
code += "\t\t" + p_output_vars[0] + " = _tex_read.rgb;\n";
|
code += "\t\t" + p_output_vars[0] + " = _tex_read.rgb;\n";
|
||||||
|
@ -589,16 +589,16 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader:
|
||||||
if (p_input_vars[0] == String()) { // Use UV by default.
|
if (p_input_vars[0] == String()) { // Use UV by default.
|
||||||
|
|
||||||
if (p_input_vars[1] == String()) {
|
if (p_input_vars[1] == String()) {
|
||||||
code += "\t\tfloat _depth = texture( DEPTH_TEXTURE , UV.xy ).r;\n";
|
code += "\t\tfloat _depth = texture(DEPTH_TEXTURE, UV.xy).r;\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tfloat _depth = textureLod( DEPTH_TEXTURE , UV.xy , " + p_input_vars[1] + " ).r;\n";
|
code += "\t\tfloat _depth = textureLod(DEPTH_TEXTURE, UV.xy, " + p_input_vars[1] + ").r;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (p_input_vars[1] == String()) {
|
} else if (p_input_vars[1] == String()) {
|
||||||
//no lod
|
//no lod
|
||||||
code += "\t\tfloat _depth = texture( DEPTH_TEXTURE , " + p_input_vars[0] + ".xy ).r;\n";
|
code += "\t\tfloat _depth = texture(DEPTH_TEXTURE, " + p_input_vars[0] + ".xy).r;\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tfloat _depth = textureLod( DEPTH_TEXTURE , " + p_input_vars[0] + ".xy , " + p_input_vars[1] + " ).r;\n";
|
code += "\t\tfloat _depth = textureLod(DEPTH_TEXTURE, " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ").r;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
code += "\t\t" + p_output_vars[0] + " = _depth;\n";
|
code += "\t\t" + p_output_vars[0] + " = _depth;\n";
|
||||||
|
@ -621,6 +621,26 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader:
|
||||||
|
|
||||||
void VisualShaderNodeTexture::set_source(Source p_source) {
|
void VisualShaderNodeTexture::set_source(Source p_source) {
|
||||||
source = p_source;
|
source = p_source;
|
||||||
|
switch (source) {
|
||||||
|
case SOURCE_TEXTURE:
|
||||||
|
simple_decl = true;
|
||||||
|
break;
|
||||||
|
case SOURCE_SCREEN:
|
||||||
|
simple_decl = false;
|
||||||
|
break;
|
||||||
|
case SOURCE_2D_TEXTURE:
|
||||||
|
simple_decl = false;
|
||||||
|
break;
|
||||||
|
case SOURCE_2D_NORMAL:
|
||||||
|
simple_decl = false;
|
||||||
|
break;
|
||||||
|
case SOURCE_DEPTH:
|
||||||
|
simple_decl = false;
|
||||||
|
break;
|
||||||
|
case SOURCE_PORT:
|
||||||
|
simple_decl = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
emit_changed();
|
emit_changed();
|
||||||
emit_signal("editor_refresh_request");
|
emit_signal("editor_refresh_request");
|
||||||
}
|
}
|
||||||
|
@ -822,16 +842,16 @@ String VisualShaderNodeCubeMap::generate_code(Shader::Mode p_mode, VisualShader:
|
||||||
if (p_input_vars[0] == String()) { // Use UV by default.
|
if (p_input_vars[0] == String()) { // Use UV by default.
|
||||||
|
|
||||||
if (p_input_vars[1] == String()) {
|
if (p_input_vars[1] == String()) {
|
||||||
code += "\t\tvec4 " + id + "_read = texture( " + id + " , vec3( UV, 0.0 ) );\n";
|
code += "\t\tvec4 " + id + "_read = texture(" + id + " , vec3(UV, 0.0));\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tvec4 " + id + "_read = textureLod( " + id + " , vec3( UV, 0.0 )" + " , " + p_input_vars[1] + " );\n";
|
code += "\t\tvec4 " + id + "_read = textureLod(" + id + " , vec3(UV, 0.0)" + " , " + p_input_vars[1] + " );\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (p_input_vars[1] == String()) {
|
} else if (p_input_vars[1] == String()) {
|
||||||
//no lod
|
//no lod
|
||||||
code += "\t\tvec4 " + id + "_read = texture( " + id + " , " + p_input_vars[0] + " );\n";
|
code += "\t\tvec4 " + id + "_read = texture(" + id + ", " + p_input_vars[0] + ");\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tvec4 " + id + "_read = textureLod( " + id + " , " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n";
|
code += "\t\tvec4 " + id + "_read = textureLod(" + id + ", " + p_input_vars[0] + ", " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
code += "\t\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n";
|
code += "\t\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n";
|
||||||
code += "\t\t" + p_output_vars[1] + " = " + id + "_read.a;\n";
|
code += "\t\t" + p_output_vars[1] + " = " + id + "_read.a;\n";
|
||||||
|
@ -913,6 +933,7 @@ void VisualShaderNodeCubeMap::_bind_methods() {
|
||||||
VisualShaderNodeCubeMap::VisualShaderNodeCubeMap() {
|
VisualShaderNodeCubeMap::VisualShaderNodeCubeMap() {
|
||||||
texture_type = TYPE_DATA;
|
texture_type = TYPE_DATA;
|
||||||
source = SOURCE_TEXTURE;
|
source = SOURCE_TEXTURE;
|
||||||
|
simple_decl = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////// Scalar Op
|
////////////// Scalar Op
|
||||||
|
@ -954,12 +975,12 @@ String VisualShaderNodeScalarOp::generate_code(Shader::Mode p_mode, VisualShader
|
||||||
case OP_SUB: code += p_input_vars[0] + " - " + p_input_vars[1] + ";\n"; break;
|
case OP_SUB: code += p_input_vars[0] + " - " + p_input_vars[1] + ";\n"; break;
|
||||||
case OP_MUL: code += p_input_vars[0] + " * " + p_input_vars[1] + ";\n"; break;
|
case OP_MUL: code += p_input_vars[0] + " * " + p_input_vars[1] + ";\n"; break;
|
||||||
case OP_DIV: code += p_input_vars[0] + " / " + p_input_vars[1] + ";\n"; break;
|
case OP_DIV: code += p_input_vars[0] + " / " + p_input_vars[1] + ";\n"; break;
|
||||||
case OP_MOD: code += "mod( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_MOD: code += "mod(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
case OP_POW: code += "pow( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_POW: code += "pow(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
case OP_MAX: code += "max( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_MAX: code += "max(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
case OP_MIN: code += "min( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_MIN: code += "min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
case OP_ATAN2: code += "atan( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_ATAN2: code += "atan(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
case OP_STEP: code += "step( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_STEP: code += "step(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1046,14 +1067,14 @@ String VisualShaderNodeVectorOp::generate_code(Shader::Mode p_mode, VisualShader
|
||||||
case OP_SUB: code += p_input_vars[0] + " - " + p_input_vars[1] + ";\n"; break;
|
case OP_SUB: code += p_input_vars[0] + " - " + p_input_vars[1] + ";\n"; break;
|
||||||
case OP_MUL: code += p_input_vars[0] + " * " + p_input_vars[1] + ";\n"; break;
|
case OP_MUL: code += p_input_vars[0] + " * " + p_input_vars[1] + ";\n"; break;
|
||||||
case OP_DIV: code += p_input_vars[0] + " / " + p_input_vars[1] + ";\n"; break;
|
case OP_DIV: code += p_input_vars[0] + " / " + p_input_vars[1] + ";\n"; break;
|
||||||
case OP_MOD: code += "mod( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_MOD: code += "mod(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
case OP_POW: code += "pow( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_POW: code += "pow(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
case OP_MAX: code += "max( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_MAX: code += "max(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
case OP_MIN: code += "min( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_MIN: code += "min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
case OP_CROSS: code += "cross( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_CROSS: code += "cross(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
case OP_ATAN2: code += "atan( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_ATAN2: code += "atan(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
case OP_REFLECT: code += "reflect( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_REFLECT: code += "reflect(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
case OP_STEP: code += "step( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; break;
|
case OP_STEP: code += "step(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1140,27 +1161,27 @@ String VisualShaderNodeColorOp::generate_code(Shader::Mode p_mode, VisualShader:
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OP_SCREEN: {
|
case OP_SCREEN: {
|
||||||
|
|
||||||
code += "\t" + p_output_vars[0] + "=vec3(1.0)-(vec3(1.0)-" + p_input_vars[0] + ")*(vec3(1.0)-" + p_input_vars[1] + ");\n";
|
code += "\t" + p_output_vars[0] + " = vec3(1.0) - (vec3(1.0) - " + p_input_vars[0] + ") * (vec3(1.0) - " + p_input_vars[1] + ");\n";
|
||||||
} break;
|
} break;
|
||||||
case OP_DIFFERENCE: {
|
case OP_DIFFERENCE: {
|
||||||
|
|
||||||
code += "\t" + p_output_vars[0] + "=abs(" + p_input_vars[0] + "-" + p_input_vars[1] + ");\n";
|
code += "\t" + p_output_vars[0] + " = abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ");\n";
|
||||||
} break;
|
} break;
|
||||||
case OP_DARKEN: {
|
case OP_DARKEN: {
|
||||||
|
|
||||||
code += "\t" + p_output_vars[0] + "=min(" + p_input_vars[0] + "," + p_input_vars[1] + ");\n";
|
code += "\t" + p_output_vars[0] + " = min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n";
|
||||||
} break;
|
} break;
|
||||||
case OP_LIGHTEN: {
|
case OP_LIGHTEN: {
|
||||||
|
|
||||||
code += "\t" + p_output_vars[0] + "=max(" + p_input_vars[0] + "," + p_input_vars[1] + ");\n";
|
code += "\t" + p_output_vars[0] + " = max(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n";
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case OP_OVERLAY: {
|
case OP_OVERLAY: {
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
code += "\t{\n";
|
code += "\t{\n";
|
||||||
code += "\t\tfloat base=" + p_input_vars[0] + "." + axisn[i] + ";\n";
|
code += "\t\tfloat base = " + p_input_vars[0] + "." + axisn[i] + ";\n";
|
||||||
code += "\t\tfloat blend=" + p_input_vars[1] + "." + axisn[i] + ";\n";
|
code += "\t\tfloat blend = " + p_input_vars[1] + "." + axisn[i] + ";\n";
|
||||||
code += "\t\tif (base < 0.5) {\n";
|
code += "\t\tif (base < 0.5) {\n";
|
||||||
code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = 2.0 * base * blend;\n";
|
code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = 2.0 * base * blend;\n";
|
||||||
code += "\t\t} else {\n";
|
code += "\t\t} else {\n";
|
||||||
|
@ -1172,23 +1193,23 @@ String VisualShaderNodeColorOp::generate_code(Shader::Mode p_mode, VisualShader:
|
||||||
} break;
|
} break;
|
||||||
case OP_DODGE: {
|
case OP_DODGE: {
|
||||||
|
|
||||||
code += "\t" + p_output_vars[0] + "=(" + p_input_vars[0] + ")/(vec3(1.0)-" + p_input_vars[1] + ");\n";
|
code += "\t" + p_output_vars[0] + " = (" + p_input_vars[0] + ") / (vec3(1.0) - " + p_input_vars[1] + ");\n";
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case OP_BURN: {
|
case OP_BURN: {
|
||||||
|
|
||||||
code += "\t" + p_output_vars[0] + "=vec3(1.0)-(vec3(1.0)-" + p_input_vars[0] + ")/(" + p_input_vars[1] + ");\n";
|
code += "\t" + p_output_vars[0] + " = vec3(1.0) - (vec3(1.0) - " + p_input_vars[0] + ") / (" + p_input_vars[1] + ");\n";
|
||||||
} break;
|
} break;
|
||||||
case OP_SOFT_LIGHT: {
|
case OP_SOFT_LIGHT: {
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
code += "\t{\n";
|
code += "\t{\n";
|
||||||
code += "\t\tfloat base=" + p_input_vars[0] + "." + axisn[i] + ";\n";
|
code += "\t\tfloat base = " + p_input_vars[0] + "." + axisn[i] + ";\n";
|
||||||
code += "\t\tfloat blend=" + p_input_vars[1] + "." + axisn[i] + ";\n";
|
code += "\t\tfloat blend = " + p_input_vars[1] + "." + axisn[i] + ";\n";
|
||||||
code += "\t\tif (base < 0.5) {\n";
|
code += "\t\tif (base < 0.5) {\n";
|
||||||
code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = (base * (blend+0.5));\n";
|
code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = (base * (blend + 0.5));\n";
|
||||||
code += "\t\t} else {\n";
|
code += "\t\t} else {\n";
|
||||||
code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = (1.0 - (1.0-base) * (1.0-(blend-0.5)));\n";
|
code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = (1.0 - (1.0 - base) * (1.0 - (blend - 0.5)));\n";
|
||||||
code += "\t\t}\n";
|
code += "\t\t}\n";
|
||||||
code += "\t}\n";
|
code += "\t}\n";
|
||||||
}
|
}
|
||||||
|
@ -1198,12 +1219,12 @@ String VisualShaderNodeColorOp::generate_code(Shader::Mode p_mode, VisualShader:
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
code += "\t{\n";
|
code += "\t{\n";
|
||||||
code += "\t\tfloat base=" + p_input_vars[0] + "." + axisn[i] + ";\n";
|
code += "\t\tfloat base = " + p_input_vars[0] + "." + axisn[i] + ";\n";
|
||||||
code += "\t\tfloat blend=" + p_input_vars[1] + "." + axisn[i] + ";\n";
|
code += "\t\tfloat blend = " + p_input_vars[1] + "." + axisn[i] + ";\n";
|
||||||
code += "\t\tif (base < 0.5) {\n";
|
code += "\t\tif (base < 0.5) {\n";
|
||||||
code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = (base * (2.0*blend));\n";
|
code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = (base * (2.0 * blend));\n";
|
||||||
code += "\t\t} else {\n";
|
code += "\t\t} else {\n";
|
||||||
code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = (1.0 - (1.0-base) * (1.0-2.0*(blend-0.5)));\n";
|
code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = (1.0 - (1.0 - base) * (1.0 - 2.0 * (blend - 0.5)));\n";
|
||||||
code += "\t\t}\n";
|
code += "\t\t}\n";
|
||||||
code += "\t}\n";
|
code += "\t}\n";
|
||||||
}
|
}
|
||||||
|
@ -1217,6 +1238,35 @@ String VisualShaderNodeColorOp::generate_code(Shader::Mode p_mode, VisualShader:
|
||||||
void VisualShaderNodeColorOp::set_operator(Operator p_op) {
|
void VisualShaderNodeColorOp::set_operator(Operator p_op) {
|
||||||
|
|
||||||
op = p_op;
|
op = p_op;
|
||||||
|
switch (op) {
|
||||||
|
case OP_SCREEN:
|
||||||
|
simple_decl = true;
|
||||||
|
break;
|
||||||
|
case OP_DIFFERENCE:
|
||||||
|
simple_decl = true;
|
||||||
|
break;
|
||||||
|
case OP_DARKEN:
|
||||||
|
simple_decl = true;
|
||||||
|
break;
|
||||||
|
case OP_LIGHTEN:
|
||||||
|
simple_decl = true;
|
||||||
|
break;
|
||||||
|
case OP_OVERLAY:
|
||||||
|
simple_decl = false;
|
||||||
|
break;
|
||||||
|
case OP_DODGE:
|
||||||
|
simple_decl = true;
|
||||||
|
break;
|
||||||
|
case OP_BURN:
|
||||||
|
simple_decl = true;
|
||||||
|
break;
|
||||||
|
case OP_SOFT_LIGHT:
|
||||||
|
simple_decl = false;
|
||||||
|
break;
|
||||||
|
case OP_HARD_LIGHT:
|
||||||
|
simple_decl = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
emit_changed();
|
emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1292,9 +1342,9 @@ String VisualShaderNodeTransformMult::generate_code(Shader::Mode p_mode, VisualS
|
||||||
} else if (op == OP_BxA) {
|
} else if (op == OP_BxA) {
|
||||||
return "\t" + p_output_vars[0] + " = " + p_input_vars[1] + " * " + p_input_vars[0] + ";\n";
|
return "\t" + p_output_vars[0] + " = " + p_input_vars[1] + " * " + p_input_vars[0] + ";\n";
|
||||||
} else if (op == OP_AxB_COMP) {
|
} else if (op == OP_AxB_COMP) {
|
||||||
return "\t" + p_output_vars[0] + " = matrixCompMult( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n";
|
return "\t" + p_output_vars[0] + " = matrixCompMult(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n";
|
||||||
} else {
|
} else {
|
||||||
return "\t" + p_output_vars[0] + " = matrixCompMult( " + p_input_vars[1] + " , " + p_input_vars[0] + " );\n";
|
return "\t" + p_output_vars[0] + " = matrixCompMult(" + p_input_vars[1] + ", " + p_input_vars[0] + ");\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1366,13 +1416,13 @@ String VisualShaderNodeTransformVecMult::get_output_port_name(int p_port) const
|
||||||
|
|
||||||
String VisualShaderNodeTransformVecMult::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeTransformVecMult::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
if (op == OP_AxB) {
|
if (op == OP_AxB) {
|
||||||
return "\t" + p_output_vars[0] + " = ( " + p_input_vars[0] + " * vec4(" + p_input_vars[1] + ", 1.0) ).xyz;\n";
|
return "\t" + p_output_vars[0] + " = (" + p_input_vars[0] + " * vec4(" + p_input_vars[1] + ", 1.0)).xyz;\n";
|
||||||
} else if (op == OP_BxA) {
|
} else if (op == OP_BxA) {
|
||||||
return "\t" + p_output_vars[0] + " = ( vec4(" + p_input_vars[1] + ", 1.0) * " + p_input_vars[0] + " ).xyz;\n";
|
return "\t" + p_output_vars[0] + " = (vec4(" + p_input_vars[1] + ", 1.0) * " + p_input_vars[0] + ").xyz;\n";
|
||||||
} else if (op == OP_3x3_AxB) {
|
} else if (op == OP_3x3_AxB) {
|
||||||
return "\t" + p_output_vars[0] + " = ( " + p_input_vars[0] + " * vec4(" + p_input_vars[1] + ", 0.0) ).xyz;\n";
|
return "\t" + p_output_vars[0] + " = (" + p_input_vars[0] + " * vec4(" + p_input_vars[1] + ", 0.0)).xyz;\n";
|
||||||
} else {
|
} else {
|
||||||
return "\t" + p_output_vars[0] + " = ( vec4(" + p_input_vars[1] + ", 0.0) * " + p_input_vars[0] + " ).xyz;\n";
|
return "\t" + p_output_vars[0] + " = (vec4(" + p_input_vars[1] + ", 0.0) * " + p_input_vars[0] + ").xyz;\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1463,7 +1513,7 @@ String VisualShaderNodeScalarFunc::generate_code(Shader::Mode p_mode, VisualShad
|
||||||
"round($)",
|
"round($)",
|
||||||
"ceil($)",
|
"ceil($)",
|
||||||
"fract($)",
|
"fract($)",
|
||||||
"min(max($,0.0),1.0)",
|
"min(max($, 0.0), 1.0)",
|
||||||
"-($)",
|
"-($)",
|
||||||
"acosh($)",
|
"acosh($)",
|
||||||
"asinh($)",
|
"asinh($)",
|
||||||
|
@ -1473,10 +1523,10 @@ String VisualShaderNodeScalarFunc::generate_code(Shader::Mode p_mode, VisualShad
|
||||||
"inversesqrt($)",
|
"inversesqrt($)",
|
||||||
"log2($)",
|
"log2($)",
|
||||||
"radians($)",
|
"radians($)",
|
||||||
"1.0/($)",
|
"1.0 / ($)",
|
||||||
"roundEven($)",
|
"roundEven($)",
|
||||||
"trunc($)",
|
"trunc($)",
|
||||||
"1.0-$"
|
"1.0 - $"
|
||||||
};
|
};
|
||||||
|
|
||||||
return "\t" + p_output_vars[0] + " = " + String(scalar_func_id[func]).replace("$", p_input_vars[0]) + ";\n";
|
return "\t" + p_output_vars[0] + " = " + String(scalar_func_id[func]).replace("$", p_input_vars[0]) + ";\n";
|
||||||
|
@ -1579,9 +1629,9 @@ String VisualShaderNodeVectorFunc::generate_code(Shader::Mode p_mode, VisualShad
|
||||||
|
|
||||||
static const char *vec_func_id[FUNC_ONEMINUS + 1] = {
|
static const char *vec_func_id[FUNC_ONEMINUS + 1] = {
|
||||||
"normalize($)",
|
"normalize($)",
|
||||||
"max(min($,vec3(1.0)),vec3(0.0))",
|
"max(min($, vec3(1.0)), vec3(0.0))",
|
||||||
"-($)",
|
"-($)",
|
||||||
"1.0/($)",
|
"1.0 / ($)",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"abs($)",
|
"abs($)",
|
||||||
|
@ -1612,7 +1662,7 @@ String VisualShaderNodeVectorFunc::generate_code(Shader::Mode p_mode, VisualShad
|
||||||
"tan($)",
|
"tan($)",
|
||||||
"tanh($)",
|
"tanh($)",
|
||||||
"trunc($)",
|
"trunc($)",
|
||||||
"vec3(1.0, 1.0, 1.0)-$"
|
"vec3(1.0, 1.0, 1.0) - $"
|
||||||
};
|
};
|
||||||
|
|
||||||
String code;
|
String code;
|
||||||
|
@ -1625,18 +1675,18 @@ String VisualShaderNodeVectorFunc::generate_code(Shader::Mode p_mode, VisualShad
|
||||||
code += "\t\tvec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n";
|
code += "\t\tvec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n";
|
||||||
code += "\t\tfloat d = q.x - min(q.w, q.y);\n";
|
code += "\t\tfloat d = q.x - min(q.w, q.y);\n";
|
||||||
code += "\t\tfloat e = 1.0e-10;\n";
|
code += "\t\tfloat e = 1.0e-10;\n";
|
||||||
code += "\t\t" + p_output_vars[0] + "=vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n";
|
code += "\t\t" + p_output_vars[0] + " = vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n";
|
||||||
code += "\t}\n";
|
code += "\t}\n";
|
||||||
} else if (func == FUNC_HSV2RGB) {
|
} else if (func == FUNC_HSV2RGB) {
|
||||||
code += "\t{\n";
|
code += "\t{\n";
|
||||||
code += "\t\tvec3 c = " + p_input_vars[0] + ";\n";
|
code += "\t\tvec3 c = " + p_input_vars[0] + ";\n";
|
||||||
code += "\t\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n";
|
code += "\t\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n";
|
||||||
code += "\t\tvec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n";
|
code += "\t\tvec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n";
|
||||||
code += "\t\t" + p_output_vars[0] + "=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n";
|
code += "\t\t" + p_output_vars[0] + " = c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n";
|
||||||
code += "\t}\n";
|
code += "\t}\n";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
code += "\t" + p_output_vars[0] + "=" + String(vec_func_id[func]).replace("$", p_input_vars[0]) + ";\n";
|
code += "\t" + p_output_vars[0] + " = " + String(vec_func_id[func]).replace("$", p_input_vars[0]) + ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1645,6 +1695,13 @@ String VisualShaderNodeVectorFunc::generate_code(Shader::Mode p_mode, VisualShad
|
||||||
void VisualShaderNodeVectorFunc::set_function(Function p_func) {
|
void VisualShaderNodeVectorFunc::set_function(Function p_func) {
|
||||||
|
|
||||||
func = p_func;
|
func = p_func;
|
||||||
|
if (func == FUNC_RGB2HSV) {
|
||||||
|
simple_decl = false;
|
||||||
|
} else if (func == FUNC_HSV2RGB) {
|
||||||
|
simple_decl = false;
|
||||||
|
} else {
|
||||||
|
simple_decl = true;
|
||||||
|
}
|
||||||
emit_changed();
|
emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1797,6 +1854,7 @@ void VisualShaderNodeColorFunc::_bind_methods() {
|
||||||
VisualShaderNodeColorFunc::VisualShaderNodeColorFunc() {
|
VisualShaderNodeColorFunc::VisualShaderNodeColorFunc() {
|
||||||
func = FUNC_GRAYSCALE;
|
func = FUNC_GRAYSCALE;
|
||||||
set_input_port_default_value(0, Vector3());
|
set_input_port_default_value(0, Vector3());
|
||||||
|
simple_decl = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////// Transform Func
|
////////////// Transform Func
|
||||||
|
@ -1837,7 +1895,7 @@ String VisualShaderNodeTransformFunc::generate_code(Shader::Mode p_mode, VisualS
|
||||||
};
|
};
|
||||||
|
|
||||||
String code;
|
String code;
|
||||||
code += "\t" + p_output_vars[0] + "=" + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n";
|
code += "\t" + p_output_vars[0] + " = " + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n";
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1905,7 +1963,7 @@ String VisualShaderNodeDotProduct::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeDotProduct::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeDotProduct::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = dot( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n";
|
return "\t" + p_output_vars[0] + " = dot(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeDotProduct::VisualShaderNodeDotProduct() {
|
VisualShaderNodeDotProduct::VisualShaderNodeDotProduct() {
|
||||||
|
@ -1944,7 +2002,7 @@ String VisualShaderNodeVectorLen::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeVectorLen::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeVectorLen::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = length( " + p_input_vars[0] + " );\n";
|
return "\t" + p_output_vars[0] + " = length(" + p_input_vars[0] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeVectorLen::VisualShaderNodeVectorLen() {
|
VisualShaderNodeVectorLen::VisualShaderNodeVectorLen() {
|
||||||
|
@ -1982,7 +2040,7 @@ String VisualShaderNodeDeterminant::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeDeterminant::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeDeterminant::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = determinant( " + p_input_vars[0] + " );\n";
|
return "\t" + p_output_vars[0] + " = determinant(" + p_input_vars[0] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeDeterminant::VisualShaderNodeDeterminant() {
|
VisualShaderNodeDeterminant::VisualShaderNodeDeterminant() {
|
||||||
|
@ -2028,7 +2086,7 @@ String VisualShaderNodeScalarDerivativeFunc::generate_code(Shader::Mode p_mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
String code;
|
String code;
|
||||||
code += "\t" + p_output_vars[0] + "=" + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n";
|
code += "\t" + p_output_vars[0] + " = " + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n";
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2105,7 +2163,7 @@ String VisualShaderNodeVectorDerivativeFunc::generate_code(Shader::Mode p_mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
String code;
|
String code;
|
||||||
code += "\t" + p_output_vars[0] + "=" + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n";
|
code += "\t" + p_output_vars[0] + " = " + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n";
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2180,7 +2238,7 @@ String VisualShaderNodeScalarClamp::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeScalarClamp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeScalarClamp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = clamp( " + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + " );\n";
|
return "\t" + p_output_vars[0] + " = clamp(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeScalarClamp::VisualShaderNodeScalarClamp() {
|
VisualShaderNodeScalarClamp::VisualShaderNodeScalarClamp() {
|
||||||
|
@ -2226,7 +2284,7 @@ String VisualShaderNodeVectorClamp::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeVectorClamp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeVectorClamp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = clamp( " + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + " );\n";
|
return "\t" + p_output_vars[0] + " = clamp(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeVectorClamp::VisualShaderNodeVectorClamp() {
|
VisualShaderNodeVectorClamp::VisualShaderNodeVectorClamp() {
|
||||||
|
@ -2275,7 +2333,7 @@ String VisualShaderNodeFaceForward::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeFaceForward::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeFaceForward::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = faceforward( " + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + " );\n";
|
return "\t" + p_output_vars[0] + " = faceforward(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeFaceForward::VisualShaderNodeFaceForward() {
|
VisualShaderNodeFaceForward::VisualShaderNodeFaceForward() {
|
||||||
|
@ -2322,7 +2380,7 @@ String VisualShaderNodeOuterProduct::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeOuterProduct::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeOuterProduct::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = outerProduct( vec4(" + p_input_vars[0] + ", 0.0), vec4(" + p_input_vars[1] + ", 0.0) );\n";
|
return "\t" + p_output_vars[0] + " = outerProduct(vec4(" + p_input_vars[0] + ", 0.0), vec4(" + p_input_vars[1] + ", 0.0));\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeOuterProduct::VisualShaderNodeOuterProduct() {
|
VisualShaderNodeOuterProduct::VisualShaderNodeOuterProduct() {
|
||||||
|
@ -2368,7 +2426,7 @@ String VisualShaderNodeVectorScalarStep::get_output_port_name(int p_port) const
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeVectorScalarStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeVectorScalarStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = step( " + p_input_vars[0] + ", " + p_input_vars[1] + " );\n";
|
return "\t" + p_output_vars[0] + " = step(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeVectorScalarStep::VisualShaderNodeVectorScalarStep() {
|
VisualShaderNodeVectorScalarStep::VisualShaderNodeVectorScalarStep() {
|
||||||
|
@ -2413,7 +2471,7 @@ String VisualShaderNodeScalarSmoothStep::get_output_port_name(int p_port) const
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeScalarSmoothStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeScalarSmoothStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = smoothstep( " + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + " );\n";
|
return "\t" + p_output_vars[0] + " = smoothstep(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeScalarSmoothStep::VisualShaderNodeScalarSmoothStep() {
|
VisualShaderNodeScalarSmoothStep::VisualShaderNodeScalarSmoothStep() {
|
||||||
|
@ -2459,7 +2517,7 @@ String VisualShaderNodeVectorSmoothStep::get_output_port_name(int p_port) const
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeVectorSmoothStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeVectorSmoothStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = smoothstep( " + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + " );\n";
|
return "\t" + p_output_vars[0] + " = smoothstep(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeVectorSmoothStep::VisualShaderNodeVectorSmoothStep() {
|
VisualShaderNodeVectorSmoothStep::VisualShaderNodeVectorSmoothStep() {
|
||||||
|
@ -2510,7 +2568,7 @@ String VisualShaderNodeVectorScalarSmoothStep::get_output_port_name(int p_port)
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeVectorScalarSmoothStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeVectorScalarSmoothStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = smoothstep( " + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + " );\n";
|
return "\t" + p_output_vars[0] + " = smoothstep(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeVectorScalarSmoothStep::VisualShaderNodeVectorScalarSmoothStep() {
|
VisualShaderNodeVectorScalarSmoothStep::VisualShaderNodeVectorScalarSmoothStep() {
|
||||||
|
@ -2555,7 +2613,7 @@ String VisualShaderNodeVectorDistance::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeVectorDistance::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeVectorDistance::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = distance( " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n";
|
return "\t" + p_output_vars[0] + " = distance(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeVectorDistance::VisualShaderNodeVectorDistance() {
|
VisualShaderNodeVectorDistance::VisualShaderNodeVectorDistance() {
|
||||||
|
@ -2606,7 +2664,7 @@ String VisualShaderNodeVectorRefract::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeVectorRefract::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeVectorRefract::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = refract( " + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + " );\n";
|
return "\t" + p_output_vars[0] + " = refract(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeVectorRefract::VisualShaderNodeVectorRefract() {
|
VisualShaderNodeVectorRefract::VisualShaderNodeVectorRefract() {
|
||||||
|
@ -2652,7 +2710,7 @@ String VisualShaderNodeScalarInterp::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeScalarInterp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeScalarInterp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = mix( " + p_input_vars[0] + " , " + p_input_vars[1] + " , " + p_input_vars[2] + " );\n";
|
return "\t" + p_output_vars[0] + " = mix(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeScalarInterp::VisualShaderNodeScalarInterp() {
|
VisualShaderNodeScalarInterp::VisualShaderNodeScalarInterp() {
|
||||||
|
@ -2698,7 +2756,7 @@ String VisualShaderNodeVectorInterp::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeVectorInterp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeVectorInterp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = mix( " + p_input_vars[0] + " , " + p_input_vars[1] + " , " + p_input_vars[2] + " );\n";
|
return "\t" + p_output_vars[0] + " = mix(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeVectorInterp::VisualShaderNodeVectorInterp() {
|
VisualShaderNodeVectorInterp::VisualShaderNodeVectorInterp() {
|
||||||
|
@ -2746,7 +2804,7 @@ String VisualShaderNodeVectorScalarMix::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeVectorScalarMix::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeVectorScalarMix::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = mix( " + p_input_vars[0] + " , " + p_input_vars[1] + " , " + p_input_vars[2] + " );\n";
|
return "\t" + p_output_vars[0] + " = mix(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeVectorScalarMix::VisualShaderNodeVectorScalarMix() {
|
VisualShaderNodeVectorScalarMix::VisualShaderNodeVectorScalarMix() {
|
||||||
|
@ -2792,7 +2850,7 @@ String VisualShaderNodeVectorCompose::get_output_port_name(int p_port) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeVectorCompose::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeVectorCompose::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = vec3( " + p_input_vars[0] + " , " + p_input_vars[1] + " , " + p_input_vars[2] + " );\n";
|
return "\t" + p_output_vars[0] + " = vec3(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeVectorCompose::VisualShaderNodeVectorCompose() {
|
VisualShaderNodeVectorCompose::VisualShaderNodeVectorCompose() {
|
||||||
|
@ -2841,7 +2899,7 @@ String VisualShaderNodeTransformCompose::get_output_port_name(int p_port) const
|
||||||
}
|
}
|
||||||
|
|
||||||
String VisualShaderNodeTransformCompose::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
String VisualShaderNodeTransformCompose::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||||
return "\t" + p_output_vars[0] + " = mat4( vec4(" + p_input_vars[0] + ", 0.0) , vec4(" + p_input_vars[1] + ", 0.0) , vec4(" + p_input_vars[2] + ",0.0), vec4(" + p_input_vars[3] + ",1.0) );\n";
|
return "\t" + p_output_vars[0] + " = mat4(vec4(" + p_input_vars[0] + ", 0.0), vec4(" + p_input_vars[1] + ", 0.0), vec4(" + p_input_vars[2] + ", 0.0), vec4(" + p_input_vars[3] + ", 1.0));\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualShaderNodeTransformCompose::VisualShaderNodeTransformCompose() {
|
VisualShaderNodeTransformCompose::VisualShaderNodeTransformCompose() {
|
||||||
|
@ -3237,15 +3295,15 @@ String VisualShaderNodeTextureUniform::generate_code(Shader::Mode p_mode, Visual
|
||||||
String code = "\t{\n";
|
String code = "\t{\n";
|
||||||
if (p_input_vars[0] == String()) { // Use UV by default.
|
if (p_input_vars[0] == String()) { // Use UV by default.
|
||||||
if (p_input_vars[1] == String()) {
|
if (p_input_vars[1] == String()) {
|
||||||
code += "\t\tvec4 n_tex_read = texture( " + id + " , UV.xy );\n";
|
code += "\t\tvec4 n_tex_read = texture(" + id + ", UV.xy);\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tvec4 n_tex_read = textureLod( " + id + " , UV.xy , " + p_input_vars[1] + " );\n";
|
code += "\t\tvec4 n_tex_read = textureLod(" + id + ", UV.xy, " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
} else if (p_input_vars[1] == String()) {
|
} else if (p_input_vars[1] == String()) {
|
||||||
//no lod
|
//no lod
|
||||||
code += "\t\tvec4 n_tex_read = texture( " + id + " , " + p_input_vars[0] + ".xy );\n";
|
code += "\t\tvec4 n_tex_read = texture(" + id + ", " + p_input_vars[0] + ".xy);\n";
|
||||||
} else {
|
} else {
|
||||||
code += "\t\tvec4 n_tex_read = textureLod( " + id + " , " + p_input_vars[0] + ".xy , " + p_input_vars[1] + " );\n";
|
code += "\t\tvec4 n_tex_read = textureLod(" + id + ", " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
code += "\t\t" + p_output_vars[0] + " = n_tex_read.rgb;\n";
|
code += "\t\t" + p_output_vars[0] + " = n_tex_read.rgb;\n";
|
||||||
|
@ -3309,6 +3367,7 @@ String VisualShaderNodeTextureUniform::get_input_port_default_hint(int p_port) c
|
||||||
VisualShaderNodeTextureUniform::VisualShaderNodeTextureUniform() {
|
VisualShaderNodeTextureUniform::VisualShaderNodeTextureUniform() {
|
||||||
texture_type = TYPE_DATA;
|
texture_type = TYPE_DATA;
|
||||||
color_default = COLOR_DEFAULT_WHITE;
|
color_default = COLOR_DEFAULT_WHITE;
|
||||||
|
simple_decl = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////// Texture Uniform (Triplanar)
|
////////////// Texture Uniform (Triplanar)
|
||||||
|
@ -3549,6 +3608,7 @@ VisualShaderNodeIf::VisualShaderNodeIf() {
|
||||||
set_input_port_default_value(3, Vector3(0.0, 0.0, 0.0));
|
set_input_port_default_value(3, Vector3(0.0, 0.0, 0.0));
|
||||||
set_input_port_default_value(4, Vector3(0.0, 0.0, 0.0));
|
set_input_port_default_value(4, Vector3(0.0, 0.0, 0.0));
|
||||||
set_input_port_default_value(5, Vector3(0.0, 0.0, 0.0));
|
set_input_port_default_value(5, Vector3(0.0, 0.0, 0.0));
|
||||||
|
simple_decl = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////// Switch
|
////////////// Switch
|
||||||
|
@ -3611,6 +3671,7 @@ VisualShaderNodeSwitch::VisualShaderNodeSwitch() {
|
||||||
set_input_port_default_value(0, false);
|
set_input_port_default_value(0, false);
|
||||||
set_input_port_default_value(1, Vector3(1.0, 1.0, 1.0));
|
set_input_port_default_value(1, Vector3(1.0, 1.0, 1.0));
|
||||||
set_input_port_default_value(2, Vector3(0.0, 0.0, 0.0));
|
set_input_port_default_value(2, Vector3(0.0, 0.0, 0.0));
|
||||||
|
simple_decl = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////// Switch(scalar)
|
////////////// Switch(scalar)
|
||||||
|
@ -3765,7 +3826,7 @@ String VisualShaderNodeIs::generate_code(Shader::Mode p_mode, VisualShader::Type
|
||||||
};
|
};
|
||||||
|
|
||||||
String code;
|
String code;
|
||||||
code += "\t" + p_output_vars[0] + "=" + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n";
|
code += "\t" + p_output_vars[0] + " = " + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n";
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3900,31 +3961,31 @@ String VisualShaderNodeCompare::generate_code(Shader::Mode p_mode, VisualShader:
|
||||||
switch (ctype) {
|
switch (ctype) {
|
||||||
case CTYPE_SCALAR:
|
case CTYPE_SCALAR:
|
||||||
if (func == FUNC_EQUAL) {
|
if (func == FUNC_EQUAL) {
|
||||||
code += "\t" + p_output_vars[0] + "=(abs(" + p_input_vars[0] + "-" + p_input_vars[1] + ")<" + p_input_vars[2] + ");";
|
code += "\t" + p_output_vars[0] + " = (abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ") < " + p_input_vars[2] + ");";
|
||||||
} else if (func == FUNC_NOT_EQUAL) {
|
} else if (func == FUNC_NOT_EQUAL) {
|
||||||
code += "\t" + p_output_vars[0] + "=!(abs(" + p_input_vars[0] + "-" + p_input_vars[1] + ")<" + p_input_vars[2] + ");";
|
code += "\t" + p_output_vars[0] + " = !(abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ") < " + p_input_vars[2] + ");";
|
||||||
} else {
|
} else {
|
||||||
code += "\t" + p_output_vars[0] + "=" + (p_input_vars[0] + "$" + p_input_vars[1]).replace("$", ops[func]) + ";\n";
|
code += "\t" + p_output_vars[0] + " = " + (p_input_vars[0] + "$" + p_input_vars[1]).replace("$", ops[func]) + ";\n";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CTYPE_VECTOR:
|
case CTYPE_VECTOR:
|
||||||
code += "\t{\n";
|
code += "\t{\n";
|
||||||
code += "\t\tbvec3 _bv=" + String(funcs[func]).replace("$", p_input_vars[0] + ", " + p_input_vars[1]) + ";\n";
|
code += "\t\tbvec3 _bv = " + String(funcs[func]).replace("$", p_input_vars[0] + ", " + p_input_vars[1]) + ";\n";
|
||||||
code += "\t\t" + p_output_vars[0] + "=" + String(conds[condition]).replace("$", "_bv") + ";\n";
|
code += "\t\t" + p_output_vars[0] + " = " + String(conds[condition]).replace("$", "_bv") + ";\n";
|
||||||
code += "\t}\n";
|
code += "\t}\n";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CTYPE_BOOLEAN:
|
case CTYPE_BOOLEAN:
|
||||||
if (func > FUNC_NOT_EQUAL)
|
if (func > FUNC_NOT_EQUAL)
|
||||||
return "\t" + p_output_vars[0] + "=false;\n";
|
return "\t" + p_output_vars[0] + " = false;\n";
|
||||||
code += "\t" + p_output_vars[0] + "=" + (p_input_vars[0] + "$" + p_input_vars[1]).replace("$", ops[func]) + ";\n";
|
code += "\t" + p_output_vars[0] + " = " + (p_input_vars[0] + " $ " + p_input_vars[1]).replace("$", ops[func]) + ";\n";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CTYPE_TRANSFORM:
|
case CTYPE_TRANSFORM:
|
||||||
if (func > FUNC_NOT_EQUAL)
|
if (func > FUNC_NOT_EQUAL)
|
||||||
return "\t" + p_output_vars[0] + "=false;\n";
|
return "\t" + p_output_vars[0] + " = false;\n";
|
||||||
code += "\t" + p_output_vars[0] + "=" + (p_input_vars[0] + "$" + p_input_vars[1]).replace("$", ops[func]) + ";\n";
|
code += "\t" + p_output_vars[0] + " = " + (p_input_vars[0] + " $ " + p_input_vars[1]).replace("$", ops[func]) + ";\n";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -3941,18 +4002,22 @@ void VisualShaderNodeCompare::set_comparison_type(ComparisonType p_type) {
|
||||||
case CTYPE_SCALAR:
|
case CTYPE_SCALAR:
|
||||||
set_input_port_default_value(0, 0.0);
|
set_input_port_default_value(0, 0.0);
|
||||||
set_input_port_default_value(1, 0.0);
|
set_input_port_default_value(1, 0.0);
|
||||||
|
simple_decl = true;
|
||||||
break;
|
break;
|
||||||
case CTYPE_VECTOR:
|
case CTYPE_VECTOR:
|
||||||
set_input_port_default_value(0, Vector3(0.0, 0.0, 0.0));
|
set_input_port_default_value(0, Vector3(0.0, 0.0, 0.0));
|
||||||
set_input_port_default_value(1, Vector3(0.0, 0.0, 0.0));
|
set_input_port_default_value(1, Vector3(0.0, 0.0, 0.0));
|
||||||
|
simple_decl = false;
|
||||||
break;
|
break;
|
||||||
case CTYPE_BOOLEAN:
|
case CTYPE_BOOLEAN:
|
||||||
set_input_port_default_value(0, false);
|
set_input_port_default_value(0, false);
|
||||||
set_input_port_default_value(1, false);
|
set_input_port_default_value(1, false);
|
||||||
|
simple_decl = true;
|
||||||
break;
|
break;
|
||||||
case CTYPE_TRANSFORM:
|
case CTYPE_TRANSFORM:
|
||||||
set_input_port_default_value(0, Transform());
|
set_input_port_default_value(0, Transform());
|
||||||
set_input_port_default_value(1, Transform());
|
set_input_port_default_value(1, Transform());
|
||||||
|
simple_decl = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
emit_changed();
|
emit_changed();
|
||||||
|
|
Loading…
Reference in New Issue