diff options
Diffstat (limited to 'scene/resources/visual_shader_nodes.cpp')
-rw-r--r-- | scene/resources/visual_shader_nodes.cpp | 138 |
1 files changed, 0 insertions, 138 deletions
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 03db8c3ac5..b89f069211 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -65,13 +65,11 @@ String VisualShaderNodeFloatConstant::generate_code(Shader::Mode p_mode, VisualS } void VisualShaderNodeFloatConstant::set_constant(float p_value) { - constant = p_value; emit_changed(); } float VisualShaderNodeFloatConstant::get_constant() const { - return constant; } @@ -82,7 +80,6 @@ Vector<StringName> VisualShaderNodeFloatConstant::get_editable_properties() cons } void VisualShaderNodeFloatConstant::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_constant", "value"), &VisualShaderNodeFloatConstant::set_constant); ClassDB::bind_method(D_METHOD("get_constant"), &VisualShaderNodeFloatConstant::get_constant); @@ -143,7 +140,6 @@ Vector<StringName> VisualShaderNodeIntConstant::get_editable_properties() const } void VisualShaderNodeIntConstant::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_constant", "value"), &VisualShaderNodeIntConstant::set_constant); ClassDB::bind_method(D_METHOD("get_constant"), &VisualShaderNodeIntConstant::get_constant); @@ -204,7 +200,6 @@ Vector<StringName> VisualShaderNodeBooleanConstant::get_editable_properties() co } void VisualShaderNodeBooleanConstant::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_constant", "value"), &VisualShaderNodeBooleanConstant::set_constant); ClassDB::bind_method(D_METHOD("get_constant"), &VisualShaderNodeBooleanConstant::get_constant); @@ -246,7 +241,6 @@ 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 code; 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"; @@ -255,13 +249,11 @@ String VisualShaderNodeColorConstant::generate_code(Shader::Mode p_mode, VisualS } void VisualShaderNodeColorConstant::set_constant(Color p_value) { - constant = p_value; emit_changed(); } Color VisualShaderNodeColorConstant::get_constant() const { - return constant; } @@ -272,7 +264,6 @@ Vector<StringName> VisualShaderNodeColorConstant::get_editable_properties() cons } void VisualShaderNodeColorConstant::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_constant", "value"), &VisualShaderNodeColorConstant::set_constant); ClassDB::bind_method(D_METHOD("get_constant"), &VisualShaderNodeColorConstant::get_constant); @@ -318,13 +309,11 @@ String VisualShaderNodeVec3Constant::generate_code(Shader::Mode p_mode, VisualSh } void VisualShaderNodeVec3Constant::set_constant(Vector3 p_value) { - constant = p_value; emit_changed(); } Vector3 VisualShaderNodeVec3Constant::get_constant() const { - return constant; } @@ -335,7 +324,6 @@ Vector<StringName> VisualShaderNodeVec3Constant::get_editable_properties() const } void VisualShaderNodeVec3Constant::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_constant", "value"), &VisualShaderNodeVec3Constant::set_constant); ClassDB::bind_method(D_METHOD("get_constant"), &VisualShaderNodeVec3Constant::get_constant); @@ -388,13 +376,11 @@ String VisualShaderNodeTransformConstant::generate_code(Shader::Mode p_mode, Vis } void VisualShaderNodeTransformConstant::set_constant(Transform p_value) { - constant = p_value; emit_changed(); } Transform VisualShaderNodeTransformConstant::get_constant() const { - return constant; } @@ -405,7 +391,6 @@ Vector<StringName> VisualShaderNodeTransformConstant::get_editable_properties() } void VisualShaderNodeTransformConstant::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_constant", "value"), &VisualShaderNodeTransformConstant::set_constant); ClassDB::bind_method(D_METHOD("get_constant"), &VisualShaderNodeTransformConstant::get_constant); @@ -426,7 +411,6 @@ int VisualShaderNodeTexture::get_input_port_count() const { } VisualShaderNodeTexture::PortType VisualShaderNodeTexture::get_input_port_type(int p_port) const { - switch (p_port) { case 0: return PORT_TYPE_VECTOR; @@ -440,7 +424,6 @@ VisualShaderNodeTexture::PortType VisualShaderNodeTexture::get_input_port_type(i } String VisualShaderNodeTexture::get_input_port_name(int p_port) const { - switch (p_port) { case 0: return "uv"; @@ -477,7 +460,6 @@ String VisualShaderNodeTexture::get_input_port_default_hint(int p_port) const { } static String make_unique_id(VisualShader::Type p_type, int p_id, const String &p_name) { - static const char *typepf[VisualShader::TYPE_MAX] = { "vtx", "frg", "lgt" }; return p_name + "_" + String(typepf[p_type]) + "_" + itos(p_id); } @@ -492,9 +474,7 @@ Vector<VisualShader::DefaultTextureParam> VisualShaderNodeTexture::get_default_t } String VisualShaderNodeTexture::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { - if (source == SOURCE_TEXTURE) { - String u = "uniform sampler2D " + make_unique_id(p_type, p_id, "tex"); switch (texture_type) { case TYPE_DATA: @@ -513,7 +493,6 @@ String VisualShaderNodeTexture::generate_global(Shader::Mode p_mode, VisualShade } String VisualShaderNodeTexture::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 (source == SOURCE_TEXTURE) { String id = make_unique_id(p_type, p_id, "tex"); String code; @@ -568,7 +547,6 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader: } if (source == SOURCE_SCREEN && (p_mode == Shader::MODE_SPATIAL || p_mode == Shader::MODE_CANVAS_ITEM) && p_type == VisualShader::TYPE_FRAGMENT) { - String code = "\t{\n"; if (p_input_vars[0] == String() || p_for_preview) { // Use UV by default. @@ -592,7 +570,6 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader: } if (source == SOURCE_2D_TEXTURE && p_mode == Shader::MODE_CANVAS_ITEM && p_type == VisualShader::TYPE_FRAGMENT) { - String code = "\t{\n"; if (p_input_vars[0] == String()) { // Use UV by default. @@ -616,7 +593,6 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader: } if (source == SOURCE_2D_NORMAL && p_mode == Shader::MODE_CANVAS_ITEM && p_type == VisualShader::TYPE_FRAGMENT) { - String code = "\t{\n"; if (p_input_vars[0] == String()) { // Use UV by default. @@ -650,7 +626,6 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader: } if (source == SOURCE_DEPTH && p_mode == Shader::MODE_SPATIAL && p_type == VisualShader::TYPE_FRAGMENT) { - String code = "\t{\n"; if (p_input_vars[0] == String()) { // Use UV by default. @@ -716,13 +691,11 @@ VisualShaderNodeTexture::Source VisualShaderNodeTexture::get_source() const { } void VisualShaderNodeTexture::set_texture(Ref<Texture2D> p_value) { - texture = p_value; emit_changed(); } Ref<Texture2D> VisualShaderNodeTexture::get_texture() const { - return texture; } @@ -746,7 +719,6 @@ Vector<StringName> VisualShaderNodeTexture::get_editable_properties() const { } String VisualShaderNodeTexture::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const { - if (source == SOURCE_TEXTURE) { return String(); // all good } @@ -756,22 +728,18 @@ String VisualShaderNodeTexture::get_warning(Shader::Mode p_mode, VisualShader::T } if (source == SOURCE_SCREEN && (p_mode == Shader::MODE_SPATIAL || p_mode == Shader::MODE_CANVAS_ITEM) && p_type == VisualShader::TYPE_FRAGMENT) { - return String(); // all good } if (source == SOURCE_2D_TEXTURE && p_mode == Shader::MODE_CANVAS_ITEM && p_type == VisualShader::TYPE_FRAGMENT) { - return String(); // all good } if (source == SOURCE_2D_NORMAL && p_mode == Shader::MODE_CANVAS_ITEM) { - return String(); // all good } if (source == SOURCE_DEPTH && p_mode == Shader::MODE_SPATIAL && p_type == VisualShader::TYPE_FRAGMENT) { - if (get_output_port_for_preview() == 0) { // DEPTH_TEXTURE is not supported in preview(canvas_item) shader return TTR("Invalid source for preview."); } @@ -782,7 +750,6 @@ String VisualShaderNodeTexture::get_warning(Shader::Mode p_mode, VisualShader::T } void VisualShaderNodeTexture::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_source", "value"), &VisualShaderNodeTexture::set_source); ClassDB::bind_method(D_METHOD("get_source"), &VisualShaderNodeTexture::get_source); @@ -870,7 +837,6 @@ Vector<VisualShader::DefaultTextureParam> VisualShaderNodeCubemap::get_default_t } String VisualShaderNodeCubemap::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { - if (source == SOURCE_TEXTURE) { String u = "uniform samplerCube " + make_unique_id(p_type, p_id, "cube"); switch (texture_type) { @@ -889,7 +855,6 @@ String VisualShaderNodeCubemap::generate_global(Shader::Mode p_mode, VisualShade } String VisualShaderNodeCubemap::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 id; if (source == SOURCE_TEXTURE) { @@ -949,13 +914,11 @@ VisualShaderNodeCubemap::Source VisualShaderNodeCubemap::get_source() const { } void VisualShaderNodeCubemap::set_cube_map(Ref<Cubemap> p_value) { - cube_map = p_value; emit_changed(); } Ref<Cubemap> VisualShaderNodeCubemap::get_cube_map() const { - return cube_map; } @@ -979,7 +942,6 @@ Vector<StringName> VisualShaderNodeCubemap::get_editable_properties() const { } void VisualShaderNodeCubemap::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_source", "value"), &VisualShaderNodeCubemap::set_source); ClassDB::bind_method(D_METHOD("get_source"), &VisualShaderNodeCubemap::get_source); @@ -1038,10 +1000,8 @@ String VisualShaderNodeFloatOp::get_output_port_name(int p_port) const { } String VisualShaderNodeFloatOp::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 = "\t" + p_output_vars[0] + " = "; switch (op) { - case OP_ADD: code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n"; break; @@ -1078,13 +1038,11 @@ String VisualShaderNodeFloatOp::generate_code(Shader::Mode p_mode, VisualShader: } void VisualShaderNodeFloatOp::set_operator(Operator p_op) { - op = p_op; emit_changed(); } VisualShaderNodeFloatOp::Operator VisualShaderNodeFloatOp::get_operator() const { - return op; } @@ -1095,7 +1053,6 @@ Vector<StringName> VisualShaderNodeFloatOp::get_editable_properties() const { } void VisualShaderNodeFloatOp::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeFloatOp::set_operator); ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeFloatOp::get_operator); @@ -1150,10 +1107,8 @@ String VisualShaderNodeIntOp::get_output_port_name(int p_port) const { } String VisualShaderNodeIntOp::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 = "\t" + p_output_vars[0] + " = "; switch (op) { - case OP_ADD: code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n"; break; @@ -1181,7 +1136,6 @@ String VisualShaderNodeIntOp::generate_code(Shader::Mode p_mode, VisualShader::T } void VisualShaderNodeIntOp::set_operator(Operator p_op) { - op = p_op; emit_changed(); } @@ -1197,7 +1151,6 @@ Vector<StringName> VisualShaderNodeIntOp::get_editable_properties() const { } void VisualShaderNodeIntOp::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeIntOp::set_operator); ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeIntOp::get_operator); @@ -1249,10 +1202,8 @@ String VisualShaderNodeVectorOp::get_output_port_name(int p_port) const { } String VisualShaderNodeVectorOp::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 = "\t" + p_output_vars[0] + " = "; switch (op) { - case OP_ADD: code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n"; break; @@ -1295,13 +1246,11 @@ String VisualShaderNodeVectorOp::generate_code(Shader::Mode p_mode, VisualShader } void VisualShaderNodeVectorOp::set_operator(Operator p_op) { - op = p_op; emit_changed(); } VisualShaderNodeVectorOp::Operator VisualShaderNodeVectorOp::get_operator() const { - return op; } @@ -1312,7 +1261,6 @@ Vector<StringName> VisualShaderNodeVectorOp::get_editable_properties() const { } void VisualShaderNodeVectorOp::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeVectorOp::set_operator); ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeVectorOp::get_operator); @@ -1369,29 +1317,23 @@ String VisualShaderNodeColorOp::get_output_port_name(int p_port) const { } String VisualShaderNodeColorOp::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; static const char *axisn[3] = { "x", "y", "z" }; switch (op) { 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"; } break; case OP_DIFFERENCE: { - code += "\t" + p_output_vars[0] + " = abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ");\n"; } break; case OP_DARKEN: { - code += "\t" + p_output_vars[0] + " = min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; } break; case OP_LIGHTEN: { - code += "\t" + p_output_vars[0] + " = max(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; } break; case OP_OVERLAY: { - for (int i = 0; i < 3; i++) { code += "\t{\n"; code += "\t\tfloat base = " + p_input_vars[0] + "." + axisn[i] + ";\n"; @@ -1406,16 +1348,13 @@ String VisualShaderNodeColorOp::generate_code(Shader::Mode p_mode, VisualShader: } break; case OP_DODGE: { - code += "\t" + p_output_vars[0] + " = (" + p_input_vars[0] + ") / (vec3(1.0) - " + p_input_vars[1] + ");\n"; } break; case OP_BURN: { - code += "\t" + p_output_vars[0] + " = vec3(1.0) - (vec3(1.0) - " + p_input_vars[0] + ") / (" + p_input_vars[1] + ");\n"; } break; case OP_SOFT_LIGHT: { - for (int i = 0; i < 3; i++) { code += "\t{\n"; code += "\t\tfloat base = " + p_input_vars[0] + "." + axisn[i] + ";\n"; @@ -1430,7 +1369,6 @@ String VisualShaderNodeColorOp::generate_code(Shader::Mode p_mode, VisualShader: } break; case OP_HARD_LIGHT: { - for (int i = 0; i < 3; i++) { code += "\t{\n"; code += "\t\tfloat base = " + p_input_vars[0] + "." + axisn[i] + ";\n"; @@ -1450,7 +1388,6 @@ String VisualShaderNodeColorOp::generate_code(Shader::Mode p_mode, VisualShader: } void VisualShaderNodeColorOp::set_operator(Operator p_op) { - op = p_op; switch (op) { case OP_SCREEN: @@ -1485,7 +1422,6 @@ void VisualShaderNodeColorOp::set_operator(Operator p_op) { } VisualShaderNodeColorOp::Operator VisualShaderNodeColorOp::get_operator() const { - return op; } @@ -1496,7 +1432,6 @@ Vector<StringName> VisualShaderNodeColorOp::get_editable_properties() const { } void VisualShaderNodeColorOp::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeColorOp::set_operator); ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeColorOp::get_operator); @@ -1550,7 +1485,6 @@ String VisualShaderNodeTransformMult::get_output_port_name(int p_port) const { } String VisualShaderNodeTransformMult::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) { return "\t" + p_output_vars[0] + " = " + p_input_vars[0] + " * " + p_input_vars[1] + ";\n"; } else if (op == OP_BxA) { @@ -1563,13 +1497,11 @@ String VisualShaderNodeTransformMult::generate_code(Shader::Mode p_mode, VisualS } void VisualShaderNodeTransformMult::set_operator(Operator p_op) { - op = p_op; emit_changed(); } VisualShaderNodeTransformMult::Operator VisualShaderNodeTransformMult::get_operator() const { - return op; } @@ -1580,7 +1512,6 @@ Vector<StringName> VisualShaderNodeTransformMult::get_editable_properties() cons } void VisualShaderNodeTransformMult::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeTransformMult::set_operator); ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeTransformMult::get_operator); @@ -1641,13 +1572,11 @@ String VisualShaderNodeTransformVecMult::generate_code(Shader::Mode p_mode, Visu } void VisualShaderNodeTransformVecMult::set_operator(Operator p_op) { - op = p_op; emit_changed(); } VisualShaderNodeTransformVecMult::Operator VisualShaderNodeTransformVecMult::get_operator() const { - return op; } @@ -1658,7 +1587,6 @@ Vector<StringName> VisualShaderNodeTransformVecMult::get_editable_properties() c } void VisualShaderNodeTransformVecMult::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeTransformVecMult::set_operator); ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeTransformVecMult::get_operator); @@ -1707,7 +1635,6 @@ String VisualShaderNodeFloatFunc::get_output_port_name(int p_port) const { } String VisualShaderNodeFloatFunc::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 { - static const char *scalar_func_id[FUNC_ONEMINUS + 1] = { "sin($)", "cos($)", @@ -1747,13 +1674,11 @@ String VisualShaderNodeFloatFunc::generate_code(Shader::Mode p_mode, VisualShade } void VisualShaderNodeFloatFunc::set_function(Function p_func) { - func = p_func; emit_changed(); } VisualShaderNodeFloatFunc::Function VisualShaderNodeFloatFunc::get_function() const { - return func; } @@ -1764,7 +1689,6 @@ Vector<StringName> VisualShaderNodeFloatFunc::get_editable_properties() const { } void VisualShaderNodeFloatFunc::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeFloatFunc::set_function); ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeFloatFunc::get_function); @@ -1878,7 +1802,6 @@ void VisualShaderNodeIntFunc::set_function(Function p_func) { } VisualShaderNodeIntFunc::Function VisualShaderNodeIntFunc::get_function() const { - return func; } @@ -1889,7 +1812,6 @@ Vector<StringName> VisualShaderNodeIntFunc::get_editable_properties() const { } void VisualShaderNodeIntFunc::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeIntFunc::set_function); ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeIntFunc::get_function); @@ -1937,7 +1859,6 @@ String VisualShaderNodeVectorFunc::get_output_port_name(int p_port) const { } String VisualShaderNodeVectorFunc::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 { - static const char *vec_func_id[FUNC_ONEMINUS + 1] = { "normalize($)", "max(min($, vec3(1.0)), vec3(0.0))", @@ -2004,7 +1925,6 @@ String VisualShaderNodeVectorFunc::generate_code(Shader::Mode p_mode, VisualShad } void VisualShaderNodeVectorFunc::set_function(Function p_func) { - func = p_func; if (func == FUNC_RGB2HSV) { simple_decl = false; @@ -2017,7 +1937,6 @@ void VisualShaderNodeVectorFunc::set_function(Function p_func) { } VisualShaderNodeVectorFunc::Function VisualShaderNodeVectorFunc::get_function() const { - return func; } @@ -2028,7 +1947,6 @@ Vector<StringName> VisualShaderNodeVectorFunc::get_editable_properties() const { } void VisualShaderNodeVectorFunc::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeVectorFunc::set_function); ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeVectorFunc::get_function); @@ -2107,7 +2025,6 @@ String VisualShaderNodeColorFunc::get_output_port_name(int p_port) const { } String VisualShaderNodeColorFunc::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; switch (func) { @@ -2135,13 +2052,11 @@ String VisualShaderNodeColorFunc::generate_code(Shader::Mode p_mode, VisualShade } void VisualShaderNodeColorFunc::set_function(Function p_func) { - func = p_func; emit_changed(); } VisualShaderNodeColorFunc::Function VisualShaderNodeColorFunc::get_function() const { - return func; } @@ -2152,7 +2067,6 @@ Vector<StringName> VisualShaderNodeColorFunc::get_editable_properties() const { } void VisualShaderNodeColorFunc::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeColorFunc::set_function); ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeColorFunc::get_function); @@ -2199,7 +2113,6 @@ String VisualShaderNodeTransformFunc::get_output_port_name(int p_port) const { } String VisualShaderNodeTransformFunc::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 { - static const char *funcs[FUNC_TRANSPOSE + 1] = { "inverse($)", "transpose($)" @@ -2211,13 +2124,11 @@ String VisualShaderNodeTransformFunc::generate_code(Shader::Mode p_mode, VisualS } void VisualShaderNodeTransformFunc::set_function(Function p_func) { - func = p_func; emit_changed(); } VisualShaderNodeTransformFunc::Function VisualShaderNodeTransformFunc::get_function() const { - return func; } @@ -2228,7 +2139,6 @@ Vector<StringName> VisualShaderNodeTransformFunc::get_editable_properties() cons } void VisualShaderNodeTransformFunc::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeTransformFunc::set_function); ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeTransformFunc::get_function); @@ -2389,7 +2299,6 @@ String VisualShaderNodeScalarDerivativeFunc::get_output_port_name(int p_port) co } String VisualShaderNodeScalarDerivativeFunc::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 { - static const char *funcs[FUNC_Y + 1] = { "fwidth($)", "dFdx($)", @@ -2402,13 +2311,11 @@ String VisualShaderNodeScalarDerivativeFunc::generate_code(Shader::Mode p_mode, } void VisualShaderNodeScalarDerivativeFunc::set_function(Function p_func) { - func = p_func; emit_changed(); } VisualShaderNodeScalarDerivativeFunc::Function VisualShaderNodeScalarDerivativeFunc::get_function() const { - return func; } @@ -2419,7 +2326,6 @@ Vector<StringName> VisualShaderNodeScalarDerivativeFunc::get_editable_properties } void VisualShaderNodeScalarDerivativeFunc::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeScalarDerivativeFunc::set_function); ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeScalarDerivativeFunc::get_function); @@ -2466,7 +2372,6 @@ String VisualShaderNodeVectorDerivativeFunc::get_output_port_name(int p_port) co } String VisualShaderNodeVectorDerivativeFunc::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 { - static const char *funcs[FUNC_Y + 1] = { "fwidth($)", "dFdx($)", @@ -2479,13 +2384,11 @@ String VisualShaderNodeVectorDerivativeFunc::generate_code(Shader::Mode p_mode, } void VisualShaderNodeVectorDerivativeFunc::set_function(Function p_func) { - func = p_func; emit_changed(); } VisualShaderNodeVectorDerivativeFunc::Function VisualShaderNodeVectorDerivativeFunc::get_function() const { - return func; } @@ -2496,7 +2399,6 @@ Vector<StringName> VisualShaderNodeVectorDerivativeFunc::get_editable_properties } void VisualShaderNodeVectorDerivativeFunc::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeVectorDerivativeFunc::set_function); ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeVectorDerivativeFunc::get_function); @@ -2943,7 +2845,6 @@ int VisualShaderNodeVectorRefract::get_input_port_count() const { } VisualShaderNodeVectorRefract::PortType VisualShaderNodeVectorRefract::get_input_port_type(int p_port) const { - if (p_port == 2) { return PORT_TYPE_SCALAR; } @@ -3165,7 +3066,6 @@ String VisualShaderNodeVectorCompose::generate_code(Shader::Mode p_mode, VisualS } VisualShaderNodeVectorCompose::VisualShaderNodeVectorCompose() { - set_input_port_default_value(0, 0.0); set_input_port_default_value(1, 0.0); set_input_port_default_value(2, 0.0); @@ -3214,7 +3114,6 @@ String VisualShaderNodeTransformCompose::generate_code(Shader::Mode p_mode, Visu } VisualShaderNodeTransformCompose::VisualShaderNodeTransformCompose() { - set_input_port_default_value(0, Vector3()); set_input_port_default_value(1, Vector3()); set_input_port_default_value(2, Vector3()); @@ -3647,7 +3546,6 @@ String VisualShaderNodeColorUniform::get_output_port_name(int p_port) const { } String VisualShaderNodeColorUniform::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { - return _get_qual_str() + "uniform vec4 " + get_uniform_name() + " : hint_color;\n"; } @@ -3777,7 +3675,6 @@ int VisualShaderNodeTextureUniform::get_output_port_count() const { } VisualShaderNodeTextureUniform::PortType VisualShaderNodeTextureUniform::get_output_port_type(int p_port) const { - switch (p_port) { case 0: return PORT_TYPE_VECTOR; @@ -3791,7 +3688,6 @@ VisualShaderNodeTextureUniform::PortType VisualShaderNodeTextureUniform::get_out } String VisualShaderNodeTextureUniform::get_output_port_name(int p_port) const { - switch (p_port) { case 0: return "rgb"; @@ -3832,7 +3728,6 @@ String VisualShaderNodeTextureUniform::generate_global(Shader::Mode p_mode, Visu } String VisualShaderNodeTextureUniform::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 id = get_uniform_name(); String code = "\t{\n"; if (p_input_vars[0] == String()) { // Use UV by default. @@ -3855,7 +3750,6 @@ String VisualShaderNodeTextureUniform::generate_code(Shader::Mode p_mode, Visual } void VisualShaderNodeTextureUniform::set_texture_type(TextureType p_type) { - texture_type = p_type; emit_changed(); } @@ -3953,7 +3847,6 @@ String VisualShaderNodeTextureUniformTriplanar::get_input_port_name(int p_port) } String VisualShaderNodeTextureUniformTriplanar::generate_global_per_node(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { - String code; code += "// TRIPLANAR FUNCTION GLOBAL CODE\n"; @@ -3976,11 +3869,9 @@ String VisualShaderNodeTextureUniformTriplanar::generate_global_per_node(Shader: } String VisualShaderNodeTextureUniformTriplanar::generate_global_per_func(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { - String code; if (p_type == VisualShader::TYPE_VERTEX) { - code += "\t// TRIPLANAR FUNCTION VERTEX CODE\n"; code += "\t\ttriplanar_power_normal = pow(abs(NORMAL), vec3(triplanar_sharpness));\n"; code += "\t\ttriplanar_power_normal /= dot(triplanar_power_normal, vec3(1.0));\n"; @@ -3992,7 +3883,6 @@ String VisualShaderNodeTextureUniformTriplanar::generate_global_per_func(Shader: } String VisualShaderNodeTextureUniformTriplanar::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 id = get_uniform_name(); String code = "\t{\n"; @@ -4142,7 +4032,6 @@ String VisualShaderNodeIf::get_output_port_name(int p_port) const { } String VisualShaderNodeIf::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; code += "\tif(abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ") < " + p_input_vars[2] + ")\n"; // abs(a - b) < tolerance eg. a == b code += "\t{\n"; @@ -4212,7 +4101,6 @@ String VisualShaderNodeSwitch::get_output_port_name(int p_port) const { } String VisualShaderNodeSwitch::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; code += "\tif(" + p_input_vars[0] + ")\n"; code += "\t{\n"; @@ -4308,7 +4196,6 @@ String VisualShaderNodeFresnel::get_output_port_name(int p_port) const { } String VisualShaderNodeFresnel::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 normal; String view; if (p_input_vars[0] == String()) { @@ -4342,42 +4229,34 @@ VisualShaderNodeFresnel::VisualShaderNodeFresnel() { ////////////// Is String VisualShaderNodeIs::get_caption() const { - return "Is"; } int VisualShaderNodeIs::get_input_port_count() const { - return 1; } VisualShaderNodeIs::PortType VisualShaderNodeIs::get_input_port_type(int p_port) const { - return PORT_TYPE_SCALAR; } String VisualShaderNodeIs::get_input_port_name(int p_port) const { - return ""; } int VisualShaderNodeIs::get_output_port_count() const { - return 1; } VisualShaderNodeIs::PortType VisualShaderNodeIs::get_output_port_type(int p_port) const { - return PORT_TYPE_BOOLEAN; } String VisualShaderNodeIs::get_output_port_name(int p_port) const { - return ""; } String VisualShaderNodeIs::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 { - static const char *funcs[FUNC_IS_NAN + 1] = { "isinf($)", "isnan($)" @@ -4389,25 +4268,21 @@ String VisualShaderNodeIs::generate_code(Shader::Mode p_mode, VisualShader::Type } void VisualShaderNodeIs::set_function(Function p_func) { - func = p_func; emit_changed(); } VisualShaderNodeIs::Function VisualShaderNodeIs::get_function() const { - return func; } Vector<StringName> VisualShaderNodeIs::get_editable_properties() const { - Vector<StringName> props; props.push_back("function"); return props; } void VisualShaderNodeIs::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeIs::set_function); ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeIs::get_function); @@ -4418,7 +4293,6 @@ void VisualShaderNodeIs::_bind_methods() { } VisualShaderNodeIs::VisualShaderNodeIs() { - func = FUNC_IS_INF; set_input_port_default_value(0, 0.0); } @@ -4426,12 +4300,10 @@ VisualShaderNodeIs::VisualShaderNodeIs() { ////////////// Compare String VisualShaderNodeCompare::get_caption() const { - return "Compare"; } int VisualShaderNodeCompare::get_input_port_count() const { - if (ctype == CTYPE_SCALAR && (func == FUNC_EQUAL || func == FUNC_NOT_EQUAL)) { return 3; } @@ -4439,7 +4311,6 @@ int VisualShaderNodeCompare::get_input_port_count() const { } VisualShaderNodeCompare::PortType VisualShaderNodeCompare::get_input_port_type(int p_port) const { - if (p_port == 2) return PORT_TYPE_SCALAR; switch (ctype) { @@ -4482,7 +4353,6 @@ String VisualShaderNodeCompare::get_output_port_name(int p_port) const { } String VisualShaderNodeCompare::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const { - if (ctype == CTYPE_BOOLEAN || ctype == CTYPE_TRANSFORM) { if (func > FUNC_NOT_EQUAL) { return TTR("Invalid comparison function for that type."); @@ -4493,7 +4363,6 @@ String VisualShaderNodeCompare::get_warning(Shader::Mode p_mode, VisualShader::T } String VisualShaderNodeCompare::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 { - static const char *ops[FUNC_LESS_THAN_EQUAL + 1] = { "==", "!=", @@ -4559,7 +4428,6 @@ String VisualShaderNodeCompare::generate_code(Shader::Mode p_mode, VisualShader: } void VisualShaderNodeCompare::set_comparison_type(ComparisonType p_type) { - ctype = p_type; switch (ctype) { @@ -4593,29 +4461,24 @@ void VisualShaderNodeCompare::set_comparison_type(ComparisonType p_type) { } VisualShaderNodeCompare::ComparisonType VisualShaderNodeCompare::get_comparison_type() const { - return ctype; } void VisualShaderNodeCompare::set_function(Function p_func) { - func = p_func; emit_changed(); } VisualShaderNodeCompare::Function VisualShaderNodeCompare::get_function() const { - return func; } void VisualShaderNodeCompare::set_condition(Condition p_cond) { - condition = p_cond; emit_changed(); } VisualShaderNodeCompare::Condition VisualShaderNodeCompare::get_condition() const { - return condition; } @@ -4629,7 +4492,6 @@ Vector<StringName> VisualShaderNodeCompare::get_editable_properties() const { } void VisualShaderNodeCompare::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_comparison_type", "type"), &VisualShaderNodeCompare::set_comparison_type); ClassDB::bind_method(D_METHOD("get_comparison_type"), &VisualShaderNodeCompare::get_comparison_type); |