Cleaned up the filter nodes aswell.

This commit is contained in:
Relintai 2022-06-18 23:03:34 +02:00
parent 627d070373
commit d6bf1b281a
47 changed files with 2936 additions and 4155 deletions

View File

@ -135,6 +135,29 @@ sources = [
"nodes/gradient/radial_gradient.cpp",
"nodes/gradient/gradient.cpp",
"nodes/gradient/circular_gradient.cpp",
"nodes/filter/tonality.cpp",
"nodes/filter/swap_channels.cpp",
"nodes/filter/quantize.cpp",
"nodes/filter/math.cpp",
"nodes/filter/make_tileable.cpp",
"nodes/filter/invert.cpp",
"nodes/filter/greyscale.cpp",
"nodes/filter/fill_to_uv.cpp",
"nodes/filter/fill_to_size.cpp",
"nodes/filter/fill_to_random_grey.cpp",
"nodes/filter/fill_to_random_color.cpp",
"nodes/filter/fill_to_position.cpp",
"nodes/filter/fill_to_color.cpp",
"nodes/filter/fill_channel.cpp",
"nodes/filter/emboss.cpp",
"nodes/filter/decompose.cpp",
"nodes/filter/combine.cpp",
"nodes/filter/colorize.cpp",
"nodes/filter/brightness_contrast.cpp",
"nodes/filter/blur_gaussian.cpp",
"nodes/filter/blend.cpp",
"nodes/filter/adjust_hsv.cpp",
]
if env["tools"]:

View File

@ -105,6 +105,29 @@ def get_doc_classes():
"MMRadialGradient",
"MMGradient",
"MMCircularGradient",
"MMTonality",
"MMSwapChannels",
"MMQuantize",
"MMMath",
"MMMakeTileable",
"MMInvert",
"MMGreyscale",
"MMFillToUv",
"MMFillToSize",
"MMFillToRandomGrey",
"MMFillToRandomColor",
"MMFillToPosition",
"MMFillToColor",
"MMFillChannel",
"MMEmboss",
"MMDecompose",
"MMCombine",
"MMColorize",
"MMBrightnessContrast",
"MMBlurGaussian",
"MMBlend",
"MMAdjustHsv",
]
def get_doc_path():

View File

@ -1,197 +1,121 @@
#include "adjust_hsv.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> AdjustHsv::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMAdjustHsv::get_image() {
return image;
}
void AdjustHsv::set_image(const Ref<Resource> &val) {
image = val;
void MMAdjustHsv::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> AdjustHsv::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMAdjustHsv::get_input() {
return input;
}
void AdjustHsv::set_input(const Ref<Resource> &val) {
input = val;
void MMAdjustHsv::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
float AdjustHsv::get_hue() const {
return hue;
float MMAdjustHsv::get_hue() const {
return hue;
}
void AdjustHsv::set_hue(const float val) {
hue = val;
void MMAdjustHsv::set_hue(const float val) {
hue = val;
set_dirty(true);
}
float AdjustHsv::get_saturation() const {
return saturation;
float MMAdjustHsv::get_saturation() const {
return saturation;
}
void AdjustHsv::set_saturation(const float val) {
saturation = val;
void MMAdjustHsv::set_saturation(const float val) {
saturation = val;
set_dirty(true);
}
float AdjustHsv::get_value() const {
return value;
float MMAdjustHsv::get_value() const {
return value;
}
void AdjustHsv::set_value(const float val) {
value = val;
void MMAdjustHsv::set_value(const float val) {
value = val;
set_dirty(true);
}
void MMAdjustHsv::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color(0, 0, 0, 1));
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input1 ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(float) ;
float hue = 0;
//export(float) ;
float saturation = 1;
//export(float) ;
float value = 1;
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void AdjustHsv::_init_properties() {
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
register_input_property(input);
register_output_property(image);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
void MMAdjustHsv::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_float("get_hue", "set_hue", "Hue", 0.01);
mm_graph_node->add_slot_float("get_saturation", "set_saturation", "Saturation", 0.01);
mm_graph_node->add_slot_float("get_value", "set_value", "Value", 0.01);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_output_property(image);
void MMAdjustHsv::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
void AdjustHsv::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_float("get_hue", "set_hue", "Hue", 0.01);
mm_graph_node.add_slot_float("get_saturation", "set_saturation", "Saturation", 0.01);
mm_graph_node.add_slot_float("get_value", "set_value", "Value", 0.01);
Color MMAdjustHsv::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input->get_value(uv);
return MMAlgos::adjust_hsv(c, hue, saturation, value);
}
void AdjustHsv::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
MMAdjustHsv::MMAdjustHsv() {
hue = 0;
saturation = 1;
value = 1;
}
Color AdjustHsv::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input.get_value(uv);
return MMAlgos.adjust_hsv(c, hue, saturation, value);
MMAdjustHsv::~MMAdjustHsv() {
}
//hue;
void MMAdjustHsv::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMAdjustHsv::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMAdjustHsv::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
float AdjustHsv::get_hue() {
return hue;
ClassDB::bind_method(D_METHOD("get_input"), &MMAdjustHsv::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMAdjustHsv::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_hue"), &MMAdjustHsv::get_hue);
ClassDB::bind_method(D_METHOD("set_hue", "value"), &MMAdjustHsv::set_hue);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "hue"), "set_hue", "get_hue");
ClassDB::bind_method(D_METHOD("get_saturation"), &MMAdjustHsv::get_saturation);
ClassDB::bind_method(D_METHOD("set_saturation", "value"), &MMAdjustHsv::set_saturation);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "saturation"), "set_saturation", "get_saturation");
ClassDB::bind_method(D_METHOD("get_value"), &MMAdjustHsv::get_value);
ClassDB::bind_method(D_METHOD("set_value", "value"), &MMAdjustHsv::set_value);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "value"), "set_value", "get_value");
}
void AdjustHsv::set_hue(const float val) {
hue = val;
set_dirty(true);
}
//saturation;
float AdjustHsv::get_saturation() {
return saturation;
}
void AdjustHsv::set_saturation(const float val) {
saturation = val;
set_dirty(true);
}
//value;
float AdjustHsv::get_value() {
return value;
}
void AdjustHsv::set_value(const float val) {
value = val;
set_dirty(true);
}
}
AdjustHsv::AdjustHsv() {
image;
input;
hue = 0;
saturation = 1;
value = 1;
}
AdjustHsv::~AdjustHsv() {
}
static void AdjustHsv::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &AdjustHsv::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &AdjustHsv::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &AdjustHsv::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &AdjustHsv::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_hue"), &AdjustHsv::get_hue);
ClassDB::bind_method(D_METHOD("set_hue", "value"), &AdjustHsv::set_hue);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "hue"), "set_hue", "get_hue");
ClassDB::bind_method(D_METHOD("get_saturation"), &AdjustHsv::get_saturation);
ClassDB::bind_method(D_METHOD("set_saturation", "value"), &AdjustHsv::set_saturation);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "saturation"), "set_saturation", "get_saturation");
ClassDB::bind_method(D_METHOD("get_value"), &AdjustHsv::get_value);
ClassDB::bind_method(D_METHOD("set_value", "value"), &AdjustHsv::set_value);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "value"), "set_value", "get_value");
ClassDB::bind_method(D_METHOD("_init_properties"), &AdjustHsv::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &AdjustHsv::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &AdjustHsv::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &AdjustHsv::_get_value_for);
ClassDB::bind_method(D_METHOD("get_hue"), &AdjustHsv::get_hue);
ClassDB::bind_method(D_METHOD("set_hue", "val"), &AdjustHsv::set_hue);
ClassDB::bind_method(D_METHOD("get_saturation"), &AdjustHsv::get_saturation);
ClassDB::bind_method(D_METHOD("set_saturation", "val"), &AdjustHsv::set_saturation);
ClassDB::bind_method(D_METHOD("get_value"), &AdjustHsv::get_value);
ClassDB::bind_method(D_METHOD("set_value", "val"), &AdjustHsv::set_value);
}

View File

@ -1,59 +1,44 @@
#ifndef ADJUST_HSV_H
#define ADJUST_HSV_H
#ifndef MM_ADJUST_HSV_H
#define MM_ADJUST_HSV_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class AdjustHsv : public MMNode {
GDCLASS(AdjustHsv, MMNode);
class MMAdjustHsv : public MMNode {
GDCLASS(MMAdjustHsv, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
float get_hue() const;
void set_hue(const float val);
float get_hue() const;
void set_hue(const float val);
float get_saturation() const;
void set_saturation(const float val);
float get_saturation() const;
void set_saturation(const float val);
float get_value() const;
void set_value(const float val);
float get_value() const;
void set_value(const float val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
float get_hue();
void set_hue(const float val);
float get_saturation();
void set_saturation(const float val);
float get_value();
void set_value(const float val);
MMAdjustHsv();
~MMAdjustHsv();
AdjustHsv();
~AdjustHsv();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(float)
float hue = 0;
//export(float)
float saturation = 1;
//export(float)
float value = 1;
//hue
//saturation
//value
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
float hue;
float saturation;
float value;
};
#endif

View File

@ -1,257 +1,187 @@
#include "blend.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Blend::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMBlend::get_image() {
return image;
}
void Blend::set_image(const Ref<Resource> &val) {
image = val;
void MMBlend::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> Blend::get_input1() {
return input1;
Ref<MMNodeUniversalProperty> MMBlend::get_input1() {
return input1;
}
void Blend::set_input1(const Ref<Resource> &val) {
input1 = val;
void MMBlend::set_input1(const Ref<MMNodeUniversalProperty> &val) {
input1 = val;
}
Ref<Resource> Blend::get_input2() {
return input2;
Ref<MMNodeUniversalProperty> MMBlend::get_input2() {
return input2;
}
void Blend::set_input2(const Ref<Resource> &val) {
input2 = val;
void MMBlend::set_input2(const Ref<MMNodeUniversalProperty> &val) {
input2 = val;
}
int Blend::get_blend_type() const {
return blend_type;
int MMBlend::get_blend_type() const {
return blend_type;
}
void Blend::set_blend_type(const int val) {
blend_type = val;
void MMBlend::set_blend_type(const int val) {
blend_type = val;
set_dirty(true);
}
Ref<Resource> Blend::get_opacity() {
return opacity;
Ref<MMNodeUniversalProperty> MMBlend::get_opacity() {
return opacity;
}
void Blend::set_opacity(const Ref<Resource> &val) {
opacity = val;
void MMBlend::set_opacity(const Ref<MMNodeUniversalProperty> &val) {
opacity = val;
}
void MMBlend::_init_properties() {
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool;
};
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input1;
//export(Resource) ;
Ref<Resource> input2;
//export(int, "Normal,Dissolve,Multiply,Screen,Overlay,Hard Light,Soft Light,Burn,Dodge,Lighten,Darken,Difference") ;
int blend_type = 0;
//export(Resource) ;
Ref<Resource> opacity;
if (!input1.is_valid()) {
input1.instance();
input1->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input1->set_default_value(Color(1, 1, 1, 1));
}
void Blend::_init_properties() {
input1->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input1->set_slot_name(">>> Input1 ");
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
if (!input2.is_valid()) {
input2.instance();
input2->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input2->set_default_value(Color(1, 1, 1, 1));
}
input2->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input2->set_slot_name(">>> Input2 ");
if (!opacity.is_valid()) {
opacity.instance();
opacity->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
opacity->set_default_value(0.5);
opacity->set_value_range(Vector2(0, 1));
opacity->set_value_step(0.01);
}
opacity->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
opacity->set_slot_name("opacity");
register_input_property(input1);
register_input_property(input2);
register_output_property(image);
register_input_property(opacity);
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
void MMBlend::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_texture_universal(image);
if (!input1) {
input1 = MMNodeUniversalProperty.new();
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input1.set_default_value(Color(1, 1, 1, 1));
Array arr;
arr.push_back("Normal");
arr.push_back("Dissolve");
arr.push_back("Multiply");
arr.push_back("Screen");
arr.push_back("Overlay");
arr.push_back("Hard Light");
arr.push_back("Soft Light");
arr.push_back("Burn");
arr.push_back("Dodge");
arr.push_back("Lighten");
arr.push_back("Darken");
arr.push_back("Difference");
mm_graph_node->add_slot_enum("get_blend_type", "set_blend_type", "blend_type", arr);
mm_graph_node->add_slot_label_universal(input1);
mm_graph_node->add_slot_label_universal(input2);
mm_graph_node->add_slot_float_universal(opacity);
}
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input1.slot_name = ">>> Input1 ";
if (!input2) {
input2 = MMNodeUniversalProperty.new();
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input2.set_default_value(Color(1, 1, 1, 1));
void MMBlend::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input2.slot_name = ">>> Input2 ";
Color MMBlend::_get_value_for(const Vector2 &uv, const int pseed) {
Vector3 b = Vector3();
//vec4 $(name_uv)_s1 = $s1($uv);
Color s1 = input1->get_value(uv);
//vec4 $(name_uv)_s2 = $s2($uv);
Color s2 = input2->get_value(uv);
//float $(name_uv)_a = $amount*$a($uv);
float a = opacity->get_value(uv);
//vec4(blend_$blend_type($uv, $(name_uv)_s1.rgb, $(name_uv)_s2.rgb, $(name_uv)_a*$(name_uv)_s1.a), min(1.0, $(name_uv)_s2.a+$(name_uv)_a*$(name_uv)_s1.a));
//"Normal,Dissolve,Multiply,Screen,Overlay,Hard Light,Soft Light,Burn,Dodge,Lighten,Darken,Difference";
if (!opacity) {
opacity = MMNodeUniversalProperty.new();
opacity.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
opacity.set_default_value(0.5);
opacity.value_range = Vector2(0, 1);
opacity.value_step = 0.01;
if (blend_type == BLEND_TYPE_NORMAL) {
b = MMAlgos::blend_normal(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
} else if (blend_type == BLEND_TYPE_DISSOLVE) {
b = MMAlgos::blend_dissolve(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
} else if (blend_type == BLEND_TYPE_MULTIPLY) {
b = MMAlgos::blend_multiply(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
} else if (blend_type == BLEND_TYPE_SCREEN) {
b = MMAlgos::blend_screen(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
} else if (blend_type == BLEND_TYPE_OVERLAY) {
b = MMAlgos::blend_overlay(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
} else if (blend_type == BLEND_TYPE_HARD_LIGHT) {
b = MMAlgos::blend_hard_light(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
} else if (blend_type == BLEND_TYPE_SOFT_LIGHT) {
b = MMAlgos::blend_soft_light(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
} else if (blend_type == BLEND_TYPE_BURN) {
b = MMAlgos::blend_burn(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
} else if (blend_type == BLEND_TYPE_DODGE) {
b = MMAlgos::blend_dodge(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
} else if (blend_type == BLEND_TYPE_LIGHTEN) {
b = MMAlgos::blend_lighten(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
} else if (blend_type == BLEND_TYPE_DARKEN) {
b = MMAlgos::blend_darken(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
} else if (blend_type == BLEND_TYPE_DIFFRENCE) {
b = MMAlgos::blend_difference(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
}
return Color(b.x, b.y, b.z, MIN(1, s2.a + a * s1.a));
}
opacity.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
opacity.slot_name = "opacity";
register_input_property(input1);
register_input_property(input2);
register_output_property(image);
register_input_property(opacity);
MMBlend::MMBlend() {
blend_type = 0;
}
void Blend::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_enum("get_blend_type", "set_blend_type", "blend_type", [ "Normal", "Dissolve", "Multiply", "Screen", "Overlay", "Hard Light", "Soft Light", "Burn", "Dodge", "Lighten", "Darken", "Difference" ]);
mm_graph_node.add_slot_label_universal(input1);
mm_graph_node.add_slot_label_universal(input2);
mm_graph_node.add_slot_float_universal(opacity);
MMBlend::~MMBlend() {
}
void MMBlend::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMBlend::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMBlend::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
void Blend::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
ClassDB::bind_method(D_METHOD("get_input1"), &MMBlend::get_input1);
ClassDB::bind_method(D_METHOD("set_input1", "value"), &MMBlend::set_input1);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input1", "get_input1");
ClassDB::bind_method(D_METHOD("get_input2"), &MMBlend::get_input2);
ClassDB::bind_method(D_METHOD("set_input2", "value"), &MMBlend::set_input2);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input2", "get_input2");
ClassDB::bind_method(D_METHOD("get_blend_type"), &MMBlend::get_blend_type);
ClassDB::bind_method(D_METHOD("set_blend_type", "value"), &MMBlend::set_blend_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "blend_type"), "set_blend_type", "get_blend_type");
ClassDB::bind_method(D_METHOD("get_opacity"), &MMBlend::get_opacity);
ClassDB::bind_method(D_METHOD("set_opacity", "value"), &MMBlend::set_opacity);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "opacity", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_opacity", "get_opacity");
}
Color Blend::_get_value_for(const Vector2 &uv, const int pseed) {
Vector3 b = Vector3();
//vec4 $(name_uv)_s1 = $s1($uv);
Color s1 = input1.get_value(uv);
//vec4 $(name_uv)_s2 = $s2($uv);
Color s2 = input2.get_value(uv);
//float $(name_uv)_a = $amount*$a($uv);
float a = opacity.get_value(uv);
//vec4(blend_$blend_type($uv, $(name_uv)_s1.rgb, $(name_uv)_s2.rgb, $(name_uv)_a*$(name_uv)_s1.a), min(1.0, $(name_uv)_s2.a+$(name_uv)_a*$(name_uv)_s1.a));
//"Normal,Dissolve,Multiply,Screen,Overlay,Hard Light,Soft Light,Burn,Dodge,Lighten,Darken,Difference";
if (blend_type == BlendType.NORMAL) {
b = MMAlgos.blend_normal(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
}
else if (blend_type == BlendType.DISSOLVE) {
b = MMAlgos.blend_dissolve(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
}
else if (blend_type == BlendType.MULTIPLY) {
b = MMAlgos.blend_multiply(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
}
else if (blend_type == BlendType.SCREEN) {
b = MMAlgos.blend_screen(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
}
else if (blend_type == BlendType.OVERLAY) {
b = MMAlgos.blend_overlay(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
}
else if (blend_type == BlendType.HARD_LIGHT) {
b = MMAlgos.blend_hard_light(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
}
else if (blend_type == BlendType.SOFT_LIGHT) {
b = MMAlgos.blend_soft_light(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
}
else if (blend_type == BlendType.BURN) {
b = MMAlgos.blend_burn(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
}
else if (blend_type == BlendType.DODGE) {
b = MMAlgos.blend_dodge(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
}
else if (blend_type == BlendType.LIGHTEN) {
b = MMAlgos.blend_lighten(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
}
else if (blend_type == BlendType.DARKEN) {
b = MMAlgos.blend_darken(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
}
else if (blend_type == BlendType.DIFFRENCE) {
b = MMAlgos.blend_difference(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a);
}
return Color(b.x, b.y, b.z, min(1, s2.a + a * s1.a));
}
int Blend::get_blend_type() {
return blend_type;
}
void Blend::set_blend_type(const int val) {
blend_type = val;
set_dirty(true);
}
}
Blend::Blend() {
image;
input1;
input2;
blend_type = 0;
opacity;
}
Blend::~Blend() {
}
static void Blend::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Blend::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Blend::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input1"), &Blend::get_input1);
ClassDB::bind_method(D_METHOD("set_input1", "value"), &Blend::set_input1);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input1", "get_input1");
ClassDB::bind_method(D_METHOD("get_input2"), &Blend::get_input2);
ClassDB::bind_method(D_METHOD("set_input2", "value"), &Blend::set_input2);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input2", "get_input2");
ClassDB::bind_method(D_METHOD("get_blend_type"), &Blend::get_blend_type);
ClassDB::bind_method(D_METHOD("set_blend_type", "value"), &Blend::set_blend_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "blend_type"), "set_blend_type", "get_blend_type");
ClassDB::bind_method(D_METHOD("get_opacity"), &Blend::get_opacity);
ClassDB::bind_method(D_METHOD("set_opacity", "value"), &Blend::set_opacity);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "opacity", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_opacity", "get_opacity");
ClassDB::bind_method(D_METHOD("_init_properties"), &Blend::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Blend::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Blend::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Blend::_get_value_for);
ClassDB::bind_method(D_METHOD("get_blend_type"), &Blend::get_blend_type);
ClassDB::bind_method(D_METHOD("set_blend_type", "val"), &Blend::set_blend_type);
}

View File

@ -1,69 +1,60 @@
#ifndef BLEND_H
#define BLEND_H
#ifndef MM_BLEND_H
#define MM_BLEND_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Blend : public MMNode {
GDCLASS(Blend, MMNode);
class MMBlend : public MMNode {
GDCLASS(MMBlend, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input1();
void set_input1(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input1();
void set_input1(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input2();
void set_input2(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input2();
void set_input2(const Ref<Resource> &val);
int get_blend_type() const;
void set_blend_type(const int val);
int get_blend_type() const;
void set_blend_type(const int val);
Ref<MMNodeUniversalProperty> get_opacity();
void set_opacity(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_opacity();
void set_opacity(const Ref<Resource> &val);
enum MMBlendType {
BLEND_TYPE_NORMAL = 0,
BLEND_TYPE_DISSOLVE,
BLEND_TYPE_MULTIPLY,
BLEND_TYPE_SCREEN,
BLEND_TYPE_OVERLAY,
BLEND_TYPE_HARD_LIGHT,
BLEND_TYPE_SOFT_LIGHT,
BLEND_TYPE_BURN,
BLEND_TYPE_DODGE,
BLEND_TYPE_LIGHTEN,
BLEND_TYPE_DARKEN,
BLEND_TYPE_DIFFRENCE
};
enum BlendType {
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
NORMAL = 0,
DISSOLVE,
MULTIPLY,
SCREEN,
OVERLAY,
HARD_LIGHT,
SOFT_LIGHT,
BURN,
DODGE,
LIGHTEN,
DARKEN,
DIFFRENCE
MMBlend();
~MMBlend();
protected:
static void _bind_methods();
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input1;
Ref<MMNodeUniversalProperty> input2;
//export(int, "Normal,Dissolve,Multiply,Screen,Overlay,Hard Light,Soft Light,Burn,Dodge,Lighten,Darken,Difference")
int blend_type;
Ref<MMNodeUniversalProperty> opacity;
};
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
int get_blend_type();
void set_blend_type(const int val);
Blend();
~Blend();
protected:
static void _bind_methods();
//tool
};
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input1;
//export(Resource)
Ref<Resource> input2;
//export(int, "Normal,Dissolve,Multiply,Screen,Overlay,Hard Light,Soft Light,Burn,Dodge,Lighten,Darken,Difference")
int blend_type = 0;
//export(Resource)
Ref<Resource> opacity;
};
#endif

View File

@ -1,362 +1,314 @@
#include "blur_gaussian.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> BlurGaussian::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMBlurGaussian::get_image() {
return image;
}
void BlurGaussian::set_image(const Ref<Resource> &val) {
image = val;
void MMBlurGaussian::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> BlurGaussian::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMBlurGaussian::get_input() {
return input;
}
void BlurGaussian::set_input(const Ref<Resource> &val) {
input = val;
void MMBlurGaussian::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
Ref<Resource> BlurGaussian::get_sigma() {
return sigma;
Ref<MMNodeUniversalProperty> MMBlurGaussian::get_sigma() {
return sigma;
}
void BlurGaussian::set_sigma(const Ref<Resource> &val) {
sigma = val;
void MMBlurGaussian::set_sigma(const Ref<MMNodeUniversalProperty> &val) {
sigma = val;
}
int BlurGaussian::get_direction() const {
return direction;
int MMBlurGaussian::get_direction() const {
return direction;
}
void BlurGaussian::set_direction(const int val) {
direction = val;
void MMBlurGaussian::set_direction(const int val) {
direction = val;
set_dirty(true);
}
int BlurGaussian::get_size() const {
return size;
int MMBlurGaussian::get_size() const {
return size;
}
void BlurGaussian::set_size(const int val) {
size = val;
void MMBlurGaussian::set_size(const int val) {
size = val;
set_dirty(true);
}
void MMBlurGaussian::_init_properties() {
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(Resource) ;
Ref<Resource> sigma;
//export(int, "Both,X,Y") ;
int direction = 0;
int size = 0;
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color());
}
void BlurGaussian::_init_properties() {
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input1 ");
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
if (!sigma.is_valid()) {
sigma.instance();
sigma->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
sigma->set_default_value(50);
}
sigma->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
sigma->set_slot_name("Sigma");
register_input_property(input);
register_output_property(image);
register_input_property(sigma);
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
void MMBlurGaussian::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_int_universal(sigma);
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color());
Array arr;
arr.push_back("Both");
arr.push_back("X");
arr.push_back("Y");
mm_graph_node->add_slot_enum("get_direction", "set_direction", "Direction", arr);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
if (!sigma) {
sigma = MMNodeUniversalProperty.new();
sigma.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
sigma.set_default_value(50);
void MMBlurGaussian::_render(const Ref<MMMaterial> &material) {
size = MAX(material->image_size.x, material->image_size.y);
Ref<Image> img = render_image(material);
image->set_value(img);
}
sigma.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
sigma.slot_name = "Sigma";
register_input_property(input);
register_output_property(image);
register_input_property(sigma);
Ref<Image> MMBlurGaussian::_render_image(const Ref<MMMaterial> &material) {
Ref<Image> img;
img.instance();
img->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
img->lock();
float w = img->get_width();
float h = img->get_width();
float pseed = Math::randf() + Math::rand();
if (direction == 0) {
for (int x = 0; x < img->get_width(); ++x) { //x in range(img.get_width())
for (int y = 0; y < img->get_height(); ++y) { //y in range(img.get_height())
Vector2 v = Vector2(x / w, y / h);
Color col = get_value_x(v, pseed);
img->set_pixel(x, y, col);
}
}
img->unlock();
image->set_value(img);
Ref<Image> image2;
image2.instance();
image2->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
image2->lock();
for (int x = 0; x < img->get_width(); ++x) { //x in range(img.get_width())
for (int y = 0; y < img->get_height(); ++y) { //y in range(img.get_height())
Vector2 v = Vector2(x / w, y / h);
Color col = get_value_y_img(v, pseed);
image2->set_pixel(x, y, col);
}
}
image2->unlock();
return image2;
}
if (direction == 1) {
for (int x = 0; x < img->get_width(); ++x) { //x in range(img.get_width())
for (int y = 0; y < img->get_height(); ++y) { //y in range(img.get_height())
Vector2 v = Vector2(x / w, y / h);
Color col = get_value_x(v, pseed);
img->set_pixel(x, y, col);
}
}
}
if (direction == 2) {
for (int x = 0; x < img->get_width(); ++x) { //x in range(img.get_width())
for (int y = 0; y < img->get_height(); ++y) { //y in range(img.get_height())
Vector2 v = Vector2(x / w, y / h);
Color col = get_value_y(v, pseed);
img->set_pixel(x, y, col);
}
}
}
img->unlock();
return img;
}
void BlurGaussian::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_int_universal(sigma);
mm_graph_node.add_slot_enum("get_direction", "set_direction", "Direction", [ "Both", "X", "Y" ]);
Color MMBlurGaussian::get_value_x(const Vector2 &uv, const int pseed) {
float sig_def = sigma->get_default_value(uv);
float sig = sigma->get_value(uv);
return gaussian_blur_x(uv, size, sig_def, sig);
}
void BlurGaussian::_render(const Variant &material) {
size = max(material.image_size.x, material.image_size.y);
Ref<Image> img = render_image(material);
image.set_value(img);
Color MMBlurGaussian::get_value_y(const Vector2 &uv, const int pseed) {
float sig_def = sigma->get_default_value(uv);
float sig = sigma->get_value(uv);
return gaussian_blur_y(uv, size, sig_def, sig);
}
Image BlurGaussian::_render_image(const Variant &material) {
Ref<Image> img = Image.new();
img.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
img.lock();
float w = img.get_width();
float h = img.get_width();
float pseed = randf() + randi();
if (direction == 0) {
for (int x = 0; x < img.get_width(); ++x) { //x in range(img.get_width())
for (int y = 0; y < img.get_height(); ++y) { //y in range(img.get_height())
Vector2 v = Vector2(x / w, y / h);
Color col = get_value_x(v, pseed);
img.set_pixel(x, y, col);
Color MMBlurGaussian::get_value_y_img(const Vector2 &uv, const int pseed) {
float sig_def = sigma->get_default_value(uv);
float sig = sigma->get_value(uv);
return gaussian_blur_y_img(uv, size, sig_def, sig);
}
//----------------------;
//gaussian_blur_x.mmg;
//vec4 $(name)_fct(vec2 uv) {;
// float e = 1.0 / $size;
// vec4 rv = vec4(0.0);
// float sum = 0.0;
// float sigma = max(0.000001, $sigma * $amount(uv));
//;
// for (float i = -50.0; i <= 50.0; i += 1.0) {;
// float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718 * sigma * sigma);
// rv += $in(uv+vec2(i*e, 0.0))*coef;
// sum += coef;
// };
//;
// return rv/sum;
//};
Color MMBlurGaussian::gaussian_blur_x(const Vector2 &uv, const float psize, const float psigma, const float pamount) {
float e = 1.0 / psize;
Color rv = Color();
float sum = 0.0;
//pamount(uv));
float sigma = MAX(0.000001, psigma * pamount);
float i = -50;
//for (float i = -50.0; i <= 50.0; i += 1.0) {;
while (i <= 50) {
float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718 * sigma * sigma);
rv += Color(input->get_value(uv + Vector2(i * e, 0.0))) * coef;
sum += coef;
i += 1;
}
return rv / sum;
}
img.unlock();
image.set_value(img);
Ref<Image> image2 = Image.new();
image2.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
image2.lock();
//----------------------;
//gaussian_blur_y.mmg;
//vec4 $(name)_fct(vec2 uv) {;
// float e = 1.0/$size;
// vec4 rv = vec4(0.0);
// float sum = 0.0;
// float sigma = max(0.000001, $sigma*$amount(uv));
// for (float i = -50.0; i <= 50.0; i += 1.0) {;
// float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718*sigma*sigma);
// rv += $in(uv+vec2(0.0, i*e))*coef;
// sum += coef;
// };
//;
// return rv/sum;
//};
for (int x = 0; x < img.get_width(); ++x) { //x in range(img.get_width())
Color MMBlurGaussian::gaussian_blur_y(const Vector2 &uv, const float psize, const float psigma, const float pamount) {
float e = 1.0 / psize;
Color rv = Color();
float sum = 0.0;
//pamount(uv));
float sigma = MAX(0.000001, psigma * pamount);
float i = -50;
//for (float i = -50.0; i <= 50.0; i += 1.0) {;
for (int y = 0; y < img.get_height(); ++y) { //y in range(img.get_height())
Vector2 v = Vector2(x / w, y / h);
Color col = get_value_y_img(v, pseed);
image2.set_pixel(x, y, col);
while (i <= 50) {
float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718 * sigma * sigma);
rv += Color(input->get_value(uv + Vector2(0.0, i * e))) * coef;
sum += coef;
i += 1;
}
return rv / sum;
}
Color MMBlurGaussian::gaussian_blur_y_img(const Vector2 &uv, const float psize, const float psigma, const float pamount) {
float e = 1.0 / psize;
Color rv = Color();
float sum = 0.0;
//pamount(uv));
float sigma = MAX(0.000001, psigma * pamount);
float i = -50;
//for (float i = -50.0; i <= 50.0; i += 1.0) {;
while (i <= 50) {
float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718 * sigma * sigma);
rv += Color(image->get_value(uv + Vector2(0.0, i * e))) * coef;
sum += coef;
i += 1;
}
return rv / sum;
}
image2.unlock();
return image2;
MMBlurGaussian::MMBlurGaussian() {
direction = 0;
size = 0;
}
if (direction == 1) {
for (int x = 0; x < img.get_width(); ++x) { //x in range(img.get_width())
for (int y = 0; y < img.get_height(); ++y) { //y in range(img.get_height())
Vector2 v = Vector2(x / w, y / h);
Color col = get_value_x(v, pseed);
img.set_pixel(x, y, col);
MMBlurGaussian::~MMBlurGaussian() {
}
void MMBlurGaussian::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMBlurGaussian::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMBlurGaussian::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &MMBlurGaussian::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMBlurGaussian::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_sigma"), &MMBlurGaussian::get_sigma);
ClassDB::bind_method(D_METHOD("set_sigma", "value"), &MMBlurGaussian::set_sigma);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "sigma", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_sigma", "get_sigma");
ClassDB::bind_method(D_METHOD("get_direction"), &MMBlurGaussian::get_direction);
ClassDB::bind_method(D_METHOD("set_direction", "value"), &MMBlurGaussian::set_direction);
ADD_PROPERTY(PropertyInfo(Variant::INT, "direction"), "set_direction", "get_direction");
ClassDB::bind_method(D_METHOD("get_size"), &MMBlurGaussian::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &MMBlurGaussian::set_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("get_value_x", "uv", "pseed"), &MMBlurGaussian::get_value_x);
ClassDB::bind_method(D_METHOD("get_value_y", "uv", "pseed"), &MMBlurGaussian::get_value_y);
ClassDB::bind_method(D_METHOD("get_value_y_img", "uv", "pseed"), &MMBlurGaussian::get_value_y_img);
ClassDB::bind_method(D_METHOD("gaussian_blur_x", "uv", "psize", "psigma", "pamount"), &MMBlurGaussian::gaussian_blur_x);
ClassDB::bind_method(D_METHOD("gaussian_blur_y", "uv", "psize", "psigma", "pamount"), &MMBlurGaussian::gaussian_blur_y);
ClassDB::bind_method(D_METHOD("gaussian_blur_y_img", "uv", "psize", "psigma", "pamount"), &MMBlurGaussian::gaussian_blur_y_img);
}
}
if (direction == 2) {
for (int x = 0; x < img.get_width(); ++x) { //x in range(img.get_width())
for (int y = 0; y < img.get_height(); ++y) { //y in range(img.get_height())
Vector2 v = Vector2(x / w, y / h);
Color col = get_value_y(v, pseed);
img.set_pixel(x, y, col);
}
}
}
img.unlock();
return img;
}
Color BlurGaussian::get_value_x(const Vector2 &uv, const int pseed) {
float sig_def = sigma.get_default_value(uv);
float sig = sigma.get_value(uv);
return gaussian_blur_x(uv, size, sig_def, sig);
}
Color BlurGaussian::get_value_y(const Vector2 &uv, const int pseed) {
float sig_def = sigma.get_default_value(uv);
float sig = sigma.get_value(uv);
return gaussian_blur_y(uv, size, sig_def, sig);
}
Color BlurGaussian::get_value_y_img(const Vector2 &uv, const int pseed) {
float sig_def = sigma.get_default_value(uv);
float sig = sigma.get_value(uv);
return gaussian_blur_y_img(uv, size, sig_def, sig);
}
int BlurGaussian::get_direction() {
return direction;
}
void BlurGaussian::set_direction(const int val) {
direction = val;
set_dirty(true);
}
//----------------------;
//gaussian_blur_x.mmg;
//vec4 $(name)_fct(vec2 uv) {;
// float e = 1.0 / $size;
// vec4 rv = vec4(0.0);
// float sum = 0.0;
// float sigma = max(0.000001, $sigma * $amount(uv));
//;
// for (float i = -50.0; i <= 50.0; i += 1.0) {;
// float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718 * sigma * sigma);
// rv += $in(uv+vec2(i*e, 0.0))*coef;
// sum += coef;
// };
//;
// return rv/sum;
//};
Color BlurGaussian::gaussian_blur_x(const Vector2 &uv, const float psize, const float psigma, const float pamount) {
float e = 1.0 / psize;
Color rv = Color();
float sum = 0.0;
//pamount(uv));
float sigma = max(0.000001, psigma * pamount);
float i = -50;
//for (float i = -50.0; i <= 50.0; i += 1.0) {;
while (i <= 50) {
float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718 * sigma * sigma);
rv += input.get_value(uv + Vector2(i*e, 0.0)) * coef;
sum += coef;
i += 1;
}
return rv / sum;
}
//----------------------;
//gaussian_blur_y.mmg;
//vec4 $(name)_fct(vec2 uv) {;
// float e = 1.0/$size;
// vec4 rv = vec4(0.0);
// float sum = 0.0;
// float sigma = max(0.000001, $sigma*$amount(uv));
// for (float i = -50.0; i <= 50.0; i += 1.0) {;
// float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718*sigma*sigma);
// rv += $in(uv+vec2(0.0, i*e))*coef;
// sum += coef;
// };
//;
// return rv/sum;
//};
Color BlurGaussian::gaussian_blur_y(const Vector2 &uv, const float psize, const float psigma, const float pamount) {
float e = 1.0 / psize;
Color rv = Color();
float sum = 0.0;
//pamount(uv));
float sigma = max(0.000001, psigma * pamount);
float i = -50;
//for (float i = -50.0; i <= 50.0; i += 1.0) {;
while (i <= 50) {
float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718 * sigma * sigma);
rv += input.get_value(uv + Vector2(0.0, i * e)) * coef;
sum += coef;
i += 1;
}
return rv / sum;
}
Color BlurGaussian::gaussian_blur_y_img(const Vector2 &uv, const float psize, const float psigma, const float pamount) {
float e = 1.0 / psize;
Color rv = Color();
float sum = 0.0;
//pamount(uv));
float sigma = max(0.000001, psigma * pamount);
float i = -50;
//for (float i = -50.0; i <= 50.0; i += 1.0) {;
while (i <= 50) {
float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718 * sigma * sigma);
rv += image.get_value(uv + Vector2(0.0, i * e)) * coef;
sum += coef;
i += 1;
}
return rv / sum;
}
}
BlurGaussian::BlurGaussian() {
image;
input;
sigma;
direction = 0;
size = 0;
}
BlurGaussian::~BlurGaussian() {
}
static void BlurGaussian::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &BlurGaussian::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &BlurGaussian::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &BlurGaussian::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &BlurGaussian::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_sigma"), &BlurGaussian::get_sigma);
ClassDB::bind_method(D_METHOD("set_sigma", "value"), &BlurGaussian::set_sigma);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "sigma", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_sigma", "get_sigma");
ClassDB::bind_method(D_METHOD("get_direction"), &BlurGaussian::get_direction);
ClassDB::bind_method(D_METHOD("set_direction", "value"), &BlurGaussian::set_direction);
ADD_PROPERTY(PropertyInfo(Variant::INT, "direction"), "set_direction", "get_direction");
ClassDB::bind_method(D_METHOD("get_size"), &BlurGaussian::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &BlurGaussian::set_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &BlurGaussian::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &BlurGaussian::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &BlurGaussian::_render);
ClassDB::bind_method(D_METHOD("_render_image", "material"), &BlurGaussian::_render_image);
ClassDB::bind_method(D_METHOD("get_value_x", "uv", "pseed"), &BlurGaussian::get_value_x);
ClassDB::bind_method(D_METHOD("get_value_y", "uv", "pseed"), &BlurGaussian::get_value_y);
ClassDB::bind_method(D_METHOD("get_value_y_img", "uv", "pseed"), &BlurGaussian::get_value_y_img);
ClassDB::bind_method(D_METHOD("get_direction"), &BlurGaussian::get_direction);
ClassDB::bind_method(D_METHOD("set_direction", "val"), &BlurGaussian::set_direction);
ClassDB::bind_method(D_METHOD("gaussian_blur_x", "uv", "psize", "psigma", "pamount"), &BlurGaussian::gaussian_blur_x);
ClassDB::bind_method(D_METHOD("gaussian_blur_y", "uv", "psize", "psigma", "pamount"), &BlurGaussian::gaussian_blur_y);
ClassDB::bind_method(D_METHOD("gaussian_blur_y_img", "uv", "psize", "psigma", "pamount"), &BlurGaussian::gaussian_blur_y_img);
}

View File

@ -1,88 +1,53 @@
#ifndef BLUR_GAUSSIAN_H
#define BLUR_GAUSSIAN_H
#ifndef MM_BLUR_GAUSSIAN_H
#define MM_BLUR_GAUSSIAN_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class BlurGaussian : public MMNode {
GDCLASS(BlurGaussian, MMNode);
class MMBlurGaussian : public MMNode {
GDCLASS(MMBlurGaussian, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_sigma();
void set_sigma(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_sigma();
void set_sigma(const Ref<Resource> &val);
int get_direction() const;
void set_direction(const int val);
int get_direction() const;
void set_direction(const int val);
int get_size() const;
void set_size(const int val);
int get_size() const;
void set_size(const int val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Ref<Image> _render_image(const Ref<MMMaterial> &material);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Image _render_image(const Variant &material);
Color get_value_x(const Vector2 &uv, const int pseed);
Color get_value_y(const Vector2 &uv, const int pseed);
Color get_value_y_img(const Vector2 &uv, const int pseed);
int get_direction();
void set_direction(const int val);
Color gaussian_blur_x(const Vector2 &uv, const float psize, const float psigma, const float pamount);
Color gaussian_blur_y(const Vector2 &uv, const float psize, const float psigma, const float pamount);
Color gaussian_blur_y_img(const Vector2 &uv, const float psize, const float psigma, const float pamount);
Color get_value_x(const Vector2 &uv, const int pseed);
Color get_value_y(const Vector2 &uv, const int pseed);
Color get_value_y_img(const Vector2 &uv, const int pseed);
BlurGaussian();
~BlurGaussian();
Color gaussian_blur_x(const Vector2 &uv, const float psize, const float psigma, const float pamount);
Color gaussian_blur_y(const Vector2 &uv, const float psize, const float psigma, const float pamount);
Color gaussian_blur_y_img(const Vector2 &uv, const float psize, const float psigma, const float pamount);
protected:
static void _bind_methods();
MMBlurGaussian();
~MMBlurGaussian();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(Resource)
Ref<Resource> sigma;
//export(int, "Both,X,Y")
int direction = 0;
int size = 0;
//----------------------
//gaussian_blur_x.mmg
//vec4 $(name)_fct(vec2 uv) {
// float e = 1.0 / $size;
// vec4 rv = vec4(0.0);
// float sum = 0.0;
// float sigma = max(0.000001, $sigma * $amount(uv));
//
// for (float i = -50.0; i <= 50.0; i += 1.0) {
// float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718 * sigma * sigma);
// rv += $in(uv+vec2(i*e, 0.0))*coef;
// sum += coef;
// }
//
// return rv/sum;
//}
//----------------------
//gaussian_blur_y.mmg
//vec4 $(name)_fct(vec2 uv) {
// float e = 1.0/$size;
// vec4 rv = vec4(0.0);
// float sum = 0.0;
// float sigma = max(0.000001, $sigma*$amount(uv));
// for (float i = -50.0; i <= 50.0; i += 1.0) {
// float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718*sigma*sigma);
// rv += $in(uv+vec2(0.0, i*e))*coef;
// sum += coef;
// }
//
// return rv/sum;
//}
protected:
static void _bind_methods();
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
Ref<MMNodeUniversalProperty> sigma;
//export(int, "Both,X,Y")
int direction;
int size;
};
#endif

View File

@ -1,165 +1,106 @@
#include "brightness_contrast.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> BrightnessContrast::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMBrightnessContrast::get_image() {
return image;
}
void BrightnessContrast::set_image(const Ref<Resource> &val) {
image = val;
void MMBrightnessContrast::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> BrightnessContrast::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMBrightnessContrast::get_input() {
return input;
}
void BrightnessContrast::set_input(const Ref<Resource> &val) {
input = val;
void MMBrightnessContrast::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
float BrightnessContrast::get_brightness() const {
return brightness;
float MMBrightnessContrast::get_brightness() const {
return brightness;
}
void BrightnessContrast::set_brightness(const float val) {
brightness = val;
void MMBrightnessContrast::set_brightness(const float val) {
brightness = val;
set_dirty(true);
}
float BrightnessContrast::get_contrast() const {
return contrast;
float MMBrightnessContrast::get_contrast() const {
return contrast;
}
void BrightnessContrast::set_contrast(const float val) {
contrast = val;
void MMBrightnessContrast::set_contrast(const float val) {
contrast = val;
set_dirty(true);
}
void MMBrightnessContrast::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color(0, 0, 0, 1));
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input1 ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(float) ;
float brightness = 0;
//export(float) ;
float contrast = 1;
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void BrightnessContrast::_init_properties() {
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
register_input_property(input);
register_output_property(image);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
void MMBrightnessContrast::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_float("get_brightness", "set_brightness", "Brightness", 0.01);
mm_graph_node->add_slot_float("get_contrast", "set_contrast", "Contrast", 0.01);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_output_property(image);
void MMBrightnessContrast::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
void BrightnessContrast::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_float("get_brightness", "set_brightness", "Brightness", 0.01);
mm_graph_node.add_slot_float("get_contrast", "set_contrast", "Contrast", 0.01);
Color MMBrightnessContrast::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input->get_value(uv);
return MMAlgos::brightness_contrast(c, brightness, contrast);
}
void BrightnessContrast::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
MMBrightnessContrast::MMBrightnessContrast() {
brightness = 0;
contrast = 1;
}
Color BrightnessContrast::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input.get_value(uv);
return MMAlgos.brightness_contrast(c, brightness, contrast);
MMBrightnessContrast::~MMBrightnessContrast() {
}
//brightness;
void MMBrightnessContrast::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMBrightnessContrast::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMBrightnessContrast::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
float BrightnessContrast::get_brightness() {
return brightness;
ClassDB::bind_method(D_METHOD("get_input"), &MMBrightnessContrast::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMBrightnessContrast::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_brightness"), &MMBrightnessContrast::get_brightness);
ClassDB::bind_method(D_METHOD("set_brightness", "value"), &MMBrightnessContrast::set_brightness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "brightness"), "set_brightness", "get_brightness");
ClassDB::bind_method(D_METHOD("get_contrast"), &MMBrightnessContrast::get_contrast);
ClassDB::bind_method(D_METHOD("set_contrast", "value"), &MMBrightnessContrast::set_contrast);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "contrast"), "set_contrast", "get_contrast");
}
void BrightnessContrast::set_brightness(const float val) {
brightness = val;
set_dirty(true);
}
//contrast;
float BrightnessContrast::get_contrast() {
return contrast;
}
void BrightnessContrast::set_contrast(const float val) {
contrast = val;
set_dirty(true);
}
}
BrightnessContrast::BrightnessContrast() {
image;
input;
brightness = 0;
contrast = 1;
}
BrightnessContrast::~BrightnessContrast() {
}
static void BrightnessContrast::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &BrightnessContrast::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &BrightnessContrast::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &BrightnessContrast::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &BrightnessContrast::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_brightness"), &BrightnessContrast::get_brightness);
ClassDB::bind_method(D_METHOD("set_brightness", "value"), &BrightnessContrast::set_brightness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "brightness"), "set_brightness", "get_brightness");
ClassDB::bind_method(D_METHOD("get_contrast"), &BrightnessContrast::get_contrast);
ClassDB::bind_method(D_METHOD("set_contrast", "value"), &BrightnessContrast::set_contrast);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "contrast"), "set_contrast", "get_contrast");
ClassDB::bind_method(D_METHOD("_init_properties"), &BrightnessContrast::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &BrightnessContrast::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &BrightnessContrast::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &BrightnessContrast::_get_value_for);
ClassDB::bind_method(D_METHOD("get_brightness"), &BrightnessContrast::get_brightness);
ClassDB::bind_method(D_METHOD("set_brightness", "val"), &BrightnessContrast::set_brightness);
ClassDB::bind_method(D_METHOD("get_contrast"), &BrightnessContrast::get_contrast);
ClassDB::bind_method(D_METHOD("set_contrast", "val"), &BrightnessContrast::set_contrast);
}

View File

@ -1,51 +1,40 @@
#ifndef BRIGHTNESS_CONTRAST_H
#define BRIGHTNESS_CONTRAST_H
#ifndef MM_BRIGHTNESS_CONTRAST_H
#define MM_BRIGHTNESS_CONTRAST_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class BrightnessContrast : public MMNode {
GDCLASS(BrightnessContrast, MMNode);
class MMBrightnessContrast : public MMNode {
GDCLASS(MMBrightnessContrast, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
float get_brightness() const;
void set_brightness(const float val);
float get_brightness() const;
void set_brightness(const float val);
float get_contrast() const;
void set_contrast(const float val);
float get_contrast() const;
void set_contrast(const float val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
float get_brightness();
void set_brightness(const float val);
float get_contrast();
void set_contrast(const float val);
MMBrightnessContrast();
~MMBrightnessContrast();
BrightnessContrast();
~BrightnessContrast();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(float)
float brightness = 0;
//export(float)
float contrast = 1;
//brightness
//contrast
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
float brightness;
float contrast;
};
#endif

View File

@ -1,129 +1,93 @@
#include "colorize.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Colorize::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMColorize::get_image() {
return image;
}
void Colorize::set_image(const Ref<Resource> &val) {
image = val;
void MMColorize::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> Colorize::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMColorize::get_input() {
return input;
}
void Colorize::set_input(const Ref<Resource> &val) {
input = val;
void MMColorize::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
void MMColorize::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
input->set_default_value(1);
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input1 ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void Colorize::_init_properties() {
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
input.set_default_value(1);
register_input_property(input);
register_output_property(image);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
void MMColorize::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_gradient();
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_output_property(image);
void MMColorize::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
void Colorize::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_gradient();
Color MMColorize::_get_value_for(const Vector2 &uv, const int pseed) {
float f = input->get_value(uv);
return get_gradient_color(f);
}
// return Color(0.5, 0.5, 0.5, 1);
void Colorize::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
Color MMColorize::_get_gradient_color(const float x) {
if (interpolation_type == 0) {
return MMAlgos::gradient_type_1(x, points);
} else if (interpolation_type == 1) {
return MMAlgos::gradient_type_2(x, points);
} else if (interpolation_type == 2) {
return MMAlgos::gradient_type_3(x, points);
} else if (interpolation_type == 3) {
return MMAlgos::gradient_type_4(x, points);
}
return Color(1, 1, 1, 1);
}
Color Colorize::_get_value_for(const Vector2 &uv, const int pseed) {
float f = input.get_value(uv);
return get_gradient_color(f);
MMColorize::MMColorize() {
}
// return Color(0.5, 0.5, 0.5, 1);
Color Colorize::get_gradient_color(const float x) {
if (interpolation_type == 0) {
return MMAlgos.gradient_type_1(x, points);
MMColorize::~MMColorize() {
}
void MMColorize::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMColorize::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMColorize::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
else if (interpolation_type == 1) {
return MMAlgos.gradient_type_2(x, points);
ClassDB::bind_method(D_METHOD("get_input"), &MMColorize::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMColorize::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
}
else if (interpolation_type == 2) {
return MMAlgos.gradient_type_3(x, points);
}
else if (interpolation_type == 3) {
return MMAlgos.gradient_type_4(x, points);
}
return Color(1, 1, 1, 1);
}
}
Colorize::Colorize() {
image;
input;
}
Colorize::~Colorize() {
}
static void Colorize::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Colorize::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Colorize::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &Colorize::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &Colorize::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("_init_properties"), &Colorize::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Colorize::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Colorize::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Colorize::_get_value_for);
ClassDB::bind_method(D_METHOD("get_gradient_color", "x"), &Colorize::get_gradient_color);
}

View File

@ -1,37 +1,33 @@
#ifndef COLORIZE_H
#define COLORIZE_H
#ifndef MM_COLORIZE_H
#define MM_COLORIZE_H
#include "../bases/gradient_base.h"
#include "../mm_node_universal_property.h"
class Colorize : public GradientBase {
GDCLASS(Colorize, GradientBase);
class MMColorize : public GradientBase {
GDCLASS(MMColorize, GradientBase);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
Color _get_gradient_color(const float x);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
Color get_gradient_color(const float x);
MMColorize();
~MMColorize();
Colorize();
~Colorize();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
// return Color(0.5, 0.5, 0.5, 1)
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
};
#endif

View File

@ -1,188 +1,148 @@
#include "combine.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Combine::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMCombine::get_image() {
return image;
}
void Combine::set_image(const Ref<Resource> &val) {
image = val;
void MMCombine::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> Combine::get_input_r() {
return input_r;
Ref<MMNodeUniversalProperty> MMCombine::get_input_r() {
return input_r;
}
void Combine::set_input_r(const Ref<Resource> &val) {
input_r = val;
void MMCombine::set_input_r(const Ref<MMNodeUniversalProperty> &val) {
input_r = val;
}
Ref<Resource> Combine::get_input_g() {
return input_g;
Ref<MMNodeUniversalProperty> MMCombine::get_input_g() {
return input_g;
}
void Combine::set_input_g(const Ref<Resource> &val) {
input_g = val;
void MMCombine::set_input_g(const Ref<MMNodeUniversalProperty> &val) {
input_g = val;
}
Ref<Resource> Combine::get_input_b() {
return input_b;
Ref<MMNodeUniversalProperty> MMCombine::get_input_b() {
return input_b;
}
void Combine::set_input_b(const Ref<Resource> &val) {
input_b = val;
void MMCombine::set_input_b(const Ref<MMNodeUniversalProperty> &val) {
input_b = val;
}
Ref<Resource> Combine::get_input_a() {
return input_a;
Ref<MMNodeUniversalProperty> MMCombine::get_input_a() {
return input_a;
}
void Combine::set_input_a(const Ref<Resource> &val) {
input_a = val;
void MMCombine::set_input_a(const Ref<MMNodeUniversalProperty> &val) {
input_a = val;
}
void MMCombine::_init_properties() {
if (!input_r.is_valid()) {
input_r.instance();
input_r->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
input_r->set_default_value(0);
}
input_r->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input_r->set_slot_name(">>> R ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input_r;
//export(Resource) ;
Ref<Resource> input_g;
//export(Resource) ;
Ref<Resource> input_b;
//export(Resource) ;
Ref<Resource> input_a;
if (!input_g.is_valid()) {
input_g.instance();
input_g->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
input_g->set_default_value(0);
}
void Combine::_init_properties() {
input_g->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input_g->set_slot_name(">>> G ");
if (!input_r) {
input_r = MMNodeUniversalProperty.new();
input_r.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
input_r.set_default_value(0);
if (!input_b.is_valid()) {
input_b.instance();
input_b->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
input_b->set_default_value(0);
}
input_b->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input_b->set_slot_name(">>> B ");
if (!input_a.is_valid()) {
input_a.instance();
input_a->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
input_a->set_default_value(1);
}
input_a->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input_a->set_slot_name(">>> A ");
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
register_input_property(input_r);
register_input_property(input_g);
register_input_property(input_b);
register_input_property(input_a);
register_output_property(image);
}
input_r.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input_r.slot_name = ">>> R ";
if (!input_g) {
input_g = MMNodeUniversalProperty.new();
input_g.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
input_g.set_default_value(0);
void MMCombine::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input_r);
mm_graph_node->add_slot_label_universal(input_g);
mm_graph_node->add_slot_label_universal(input_b);
mm_graph_node->add_slot_label_universal(input_a);
mm_graph_node->add_slot_texture_universal(image);
}
input_g.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input_g.slot_name = ">>> G ";
if (!input_b) {
input_b = MMNodeUniversalProperty.new();
input_b.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
input_b.set_default_value(0);
void MMCombine::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
input_b.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input_b.slot_name = ">>> B ";
if (!input_a) {
input_a = MMNodeUniversalProperty.new();
input_a.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
input_a.set_default_value(1);
Color MMCombine::_get_value_for(const Vector2 &uv, const int pseed) {
float r = input_r->get_value(uv);
float g = input_g->get_value(uv);
float b = input_b->get_value(uv);
float a = input_a->get_value(uv);
return Color(r, g, b, a);
}
input_a.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input_a.slot_name = ">>> A ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
MMCombine::MMCombine() {
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input_r);
register_input_property(input_g);
register_input_property(input_b);
register_input_property(input_a);
register_output_property(image);
MMCombine::~MMCombine() {
}
void MMCombine::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMCombine::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMCombine::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
void Combine::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input_r);
mm_graph_node.add_slot_label_universal(input_g);
mm_graph_node.add_slot_label_universal(input_b);
mm_graph_node.add_slot_label_universal(input_a);
mm_graph_node.add_slot_texture_universal(image);
ClassDB::bind_method(D_METHOD("get_input_r"), &MMCombine::get_input_r);
ClassDB::bind_method(D_METHOD("set_input_r", "value"), &MMCombine::set_input_r);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input_r", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input_r", "get_input_r");
ClassDB::bind_method(D_METHOD("get_input_g"), &MMCombine::get_input_g);
ClassDB::bind_method(D_METHOD("set_input_g", "value"), &MMCombine::set_input_g);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input_g", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input_g", "get_input_g");
ClassDB::bind_method(D_METHOD("get_input_b"), &MMCombine::get_input_b);
ClassDB::bind_method(D_METHOD("set_input_b", "value"), &MMCombine::set_input_b);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input_b", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input_b", "get_input_b");
ClassDB::bind_method(D_METHOD("get_input_a"), &MMCombine::get_input_a);
ClassDB::bind_method(D_METHOD("set_input_a", "value"), &MMCombine::set_input_a);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input_a", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input_a", "get_input_a");
}
void Combine::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color Combine::_get_value_for(const Vector2 &uv, const int pseed) {
float r = input_r.get_value(uv);
float g = input_g.get_value(uv);
float b = input_b.get_value(uv);
float a = input_a.get_value(uv);
return Color(r, g, b, a);
}
}
Combine::Combine() {
image;
input_r;
input_g;
input_b;
input_a;
}
Combine::~Combine() {
}
static void Combine::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Combine::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Combine::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input_r"), &Combine::get_input_r);
ClassDB::bind_method(D_METHOD("set_input_r", "value"), &Combine::set_input_r);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input_r", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input_r", "get_input_r");
ClassDB::bind_method(D_METHOD("get_input_g"), &Combine::get_input_g);
ClassDB::bind_method(D_METHOD("set_input_g", "value"), &Combine::set_input_g);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input_g", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input_g", "get_input_g");
ClassDB::bind_method(D_METHOD("get_input_b"), &Combine::get_input_b);
ClassDB::bind_method(D_METHOD("set_input_b", "value"), &Combine::set_input_b);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input_b", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input_b", "get_input_b");
ClassDB::bind_method(D_METHOD("get_input_a"), &Combine::get_input_a);
ClassDB::bind_method(D_METHOD("set_input_a", "value"), &Combine::set_input_a);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input_a", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input_a", "get_input_a");
ClassDB::bind_method(D_METHOD("_init_properties"), &Combine::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Combine::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Combine::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Combine::_get_value_for);
}

View File

@ -1,50 +1,44 @@
#ifndef COMBINE_H
#define COMBINE_H
#ifndef MM_COMBINE_H
#define MM_COMBINE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Combine : public MMNode {
GDCLASS(Combine, MMNode);
class MMCombine : public MMNode {
GDCLASS(MMCombine, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input_r();
void set_input_r(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input_r();
void set_input_r(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input_g();
void set_input_g(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input_g();
void set_input_g(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input_b();
void set_input_b(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input_b();
void set_input_b(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input_a();
void set_input_a(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input_a();
void set_input_a(const Ref<Resource> &val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
MMCombine();
~MMCombine();
Combine();
~Combine();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input_r;
//export(Resource)
Ref<Resource> input_g;
//export(Resource)
Ref<Resource> input_b;
//export(Resource)
Ref<Resource> input_a;
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input_r;
Ref<MMNodeUniversalProperty> input_g;
Ref<MMNodeUniversalProperty> input_b;
Ref<MMNodeUniversalProperty> input_a;
};
#endif

View File

@ -1,211 +1,178 @@
#include "decompose.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Decompose::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMDecompose::get_input() {
return input;
}
void Decompose::set_input(const Ref<Resource> &val) {
input = val;
void MMDecompose::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
Ref<Resource> Decompose::get_out_r() {
return out_r;
Ref<MMNodeUniversalProperty> MMDecompose::get_out_r() {
return out_r;
}
void Decompose::set_out_r(const Ref<Resource> &val) {
out_r = val;
void MMDecompose::set_out_r(const Ref<MMNodeUniversalProperty> &val) {
out_r = val;
}
Ref<Resource> Decompose::get_out_g() {
return out_g;
Ref<MMNodeUniversalProperty> MMDecompose::get_out_g() {
return out_g;
}
void Decompose::set_out_g(const Ref<Resource> &val) {
out_g = val;
void MMDecompose::set_out_g(const Ref<MMNodeUniversalProperty> &val) {
out_g = val;
}
Ref<Resource> Decompose::get_out_b() {
return out_b;
Ref<MMNodeUniversalProperty> MMDecompose::get_out_b() {
return out_b;
}
void Decompose::set_out_b(const Ref<Resource> &val) {
out_b = val;
void MMDecompose::set_out_b(const Ref<MMNodeUniversalProperty> &val) {
out_b = val;
}
Ref<Resource> Decompose::get_out_a() {
return out_a;
Ref<MMNodeUniversalProperty> MMDecompose::get_out_a() {
return out_a;
}
void Decompose::set_out_a(const Ref<Resource> &val) {
out_a = val;
void MMDecompose::set_out_a(const Ref<MMNodeUniversalProperty> &val) {
out_a = val;
}
void MMDecompose::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color(0, 0, 0, 1));
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input ");
//tool;
//export(Resource) ;
Ref<Resource> input;
//export(Resource) ;
Ref<Resource> out_r;
//export(Resource) ;
Ref<Resource> out_g;
//export(Resource) ;
Ref<Resource> out_b;
//export(Resource) ;
Ref<Resource> out_a;
if (!out_r.is_valid()) {
out_r.instance();
out_r->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void Decompose::_init_properties() {
out_r->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
if (!out_g.is_valid()) {
out_g.instance();
out_g->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
out_g->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
if (!out_b.is_valid()) {
out_b.instance();
out_b->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
out_b->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
if (!out_a.is_valid()) {
out_a.instance();
out_a->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
out_a->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
register_input_property(input);
register_output_property(out_r);
register_output_property(out_g);
register_output_property(out_b);
register_output_property(out_a);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!out_r) {
out_r = MMNodeUniversalProperty.new();
out_r.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
void MMDecompose::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(out_r);
mm_graph_node->add_slot_texture_universal(out_g);
mm_graph_node->add_slot_texture_universal(out_b);
mm_graph_node->add_slot_texture_universal(out_a);
}
out_r.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
void MMDecompose::_render(const Ref<MMMaterial> &material) {
Ref<Image> img_r;
Ref<Image> img_g;
Ref<Image> img_b;
Ref<Image> img_a;
if (!out_g) {
out_g = MMNodeUniversalProperty.new();
out_g.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
img_r.instance();
img_g.instance();
img_b.instance();
img_a.instance();
img_r->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
img_g->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
img_b->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
img_a->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
img_r->lock();
img_g->lock();
img_b->lock();
img_a->lock();
float w = material->image_size.x;
float h = material->image_size.y;
//float pseed = Math::randf() + Math::rand();
for (int x = 0; x < material->image_size.x; ++x) { //x in range(material.image_size.x)
for (int y = 0; y < material->image_size.y; ++y) { //y in range(material.image_size.y)
Vector2 uv = Vector2(x / w, y / h);
Color c = input->get_value(uv);
img_r->set_pixel(x, y, Color(c.r, c.r, c.r, 1));
img_g->set_pixel(x, y, Color(c.g, c.g, c.g, 1));
img_b->set_pixel(x, y, Color(c.b, c.b, c.b, 1));
img_a->set_pixel(x, y, Color(c.a, c.a, c.a, c.a));
}
}
img_r->unlock();
img_g->unlock();
img_b->unlock();
img_a->unlock();
out_r->set_value(img_r);
out_g->set_value(img_g);
out_b->set_value(img_b);
out_a->set_value(img_a);
}
out_g.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_b) {
out_b = MMNodeUniversalProperty.new();
out_b.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
Color MMDecompose::_get_value_for(const Vector2 &uv, const int pseed) {
return Color();
}
out_b.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_a) {
out_a = MMNodeUniversalProperty.new();
out_a.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
MMDecompose::MMDecompose() {
}
out_a.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_input_property(input);
register_output_property(out_r);
register_output_property(out_g);
register_output_property(out_b);
register_output_property(out_a);
MMDecompose::~MMDecompose() {
}
void MMDecompose::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input"), &MMDecompose::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMDecompose::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
void Decompose::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(out_r);
mm_graph_node.add_slot_texture_universal(out_g);
mm_graph_node.add_slot_texture_universal(out_b);
mm_graph_node.add_slot_texture_universal(out_a);
ClassDB::bind_method(D_METHOD("get_out_r"), &MMDecompose::get_out_r);
ClassDB::bind_method(D_METHOD("set_out_r", "value"), &MMDecompose::set_out_r);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_r", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_r", "get_out_r");
ClassDB::bind_method(D_METHOD("get_out_g"), &MMDecompose::get_out_g);
ClassDB::bind_method(D_METHOD("set_out_g", "value"), &MMDecompose::set_out_g);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_g", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_g", "get_out_g");
ClassDB::bind_method(D_METHOD("get_out_b"), &MMDecompose::get_out_b);
ClassDB::bind_method(D_METHOD("set_out_b", "value"), &MMDecompose::set_out_b);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_b", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_b", "get_out_b");
ClassDB::bind_method(D_METHOD("get_out_a"), &MMDecompose::get_out_a);
ClassDB::bind_method(D_METHOD("set_out_a", "value"), &MMDecompose::set_out_a);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_a", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_a", "get_out_a");
}
void Decompose::_render(const Variant &material) {
Ref<Image> img_r = Image.new();
Ref<Image> img_g = Image.new();
Ref<Image> img_b = Image.new();
Ref<Image> img_a = Image.new();
img_r.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
img_g.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
img_b.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
img_a.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
img_r.lock();
img_g.lock();
img_b.lock();
img_a.lock();
float w = material.image_size.x;
float h = material.image_size.y;
float pseed = randf() + randi();
for (int x = 0; x < material.image_size.x; ++x) { //x in range(material.image_size.x)
for (int y = 0; y < material.image_size.y; ++y) { //y in range(material.image_size.y)
Vector2 uv = Vector2(x / w, y / h);
Color c = input.get_value(uv);
img_r.set_pixel(x, y, Color(c.r, c.r, c.r, 1));
img_g.set_pixel(x, y, Color(c.g, c.g, c.g, 1));
img_b.set_pixel(x, y, Color(c.b, c.b, c.b, 1));
img_a.set_pixel(x, y, Color(c.a, c.a, c.a, c.a));
}
}
img_r.unlock();
img_g.unlock();
img_b.unlock();
img_a.unlock();
out_r.set_value(img_r);
out_g.set_value(img_g);
out_b.set_value(img_b);
out_a.set_value(img_a);
}
Color Decompose::_get_value_for(const Vector2 &uv, const int pseed) {
return Color();
}
}
Decompose::Decompose() {
input;
out_r;
out_g;
out_b;
out_a;
}
Decompose::~Decompose() {
}
static void Decompose::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input"), &Decompose::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &Decompose::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_out_r"), &Decompose::get_out_r);
ClassDB::bind_method(D_METHOD("set_out_r", "value"), &Decompose::set_out_r);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_r", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_r", "get_out_r");
ClassDB::bind_method(D_METHOD("get_out_g"), &Decompose::get_out_g);
ClassDB::bind_method(D_METHOD("set_out_g", "value"), &Decompose::set_out_g);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_g", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_g", "get_out_g");
ClassDB::bind_method(D_METHOD("get_out_b"), &Decompose::get_out_b);
ClassDB::bind_method(D_METHOD("set_out_b", "value"), &Decompose::set_out_b);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_b", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_b", "get_out_b");
ClassDB::bind_method(D_METHOD("get_out_a"), &Decompose::get_out_a);
ClassDB::bind_method(D_METHOD("set_out_a", "value"), &Decompose::set_out_a);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_a", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_a", "get_out_a");
ClassDB::bind_method(D_METHOD("_init_properties"), &Decompose::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Decompose::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Decompose::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Decompose::_get_value_for);
}

View File

@ -1,50 +1,44 @@
#ifndef DECOMPOSE_H
#define DECOMPOSE_H
#ifndef MM_DECOMPOSE_H
#define MM_DECOMPOSE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Decompose : public MMNode {
GDCLASS(Decompose, MMNode);
class MMDecompose : public MMNode {
GDCLASS(MMDecompose, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_out_r();
void set_out_r(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_r();
void set_out_r(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_out_g();
void set_out_g(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_g();
void set_out_g(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_out_b();
void set_out_b(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_b();
void set_out_b(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_out_a();
void set_out_a(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_a();
void set_out_a(const Ref<Resource> &val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
MMDecompose();
~MMDecompose();
Decompose();
~Decompose();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> input;
//export(Resource)
Ref<Resource> out_r;
//export(Resource)
Ref<Resource> out_g;
//export(Resource)
Ref<Resource> out_b;
//export(Resource)
Ref<Resource> out_a;
Ref<MMNodeUniversalProperty> input;
Ref<MMNodeUniversalProperty> out_r;
Ref<MMNodeUniversalProperty> out_g;
Ref<MMNodeUniversalProperty> out_b;
Ref<MMNodeUniversalProperty> out_a;
};
#endif

View File

@ -1,253 +1,177 @@
#include "emboss.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Emboss::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMEmboss::get_image() {
return image;
}
void Emboss::set_image(const Ref<Resource> &val) {
image = val;
void MMEmboss::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> Emboss::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMEmboss::get_input() {
return input;
}
void Emboss::set_input(const Ref<Resource> &val) {
input = val;
void MMEmboss::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
float Emboss::get_angle() const {
return angle;
float MMEmboss::get_angle() const {
return angle;
}
void Emboss::set_angle(const float val) {
angle = val;
void MMEmboss::set_angle(const float val) {
angle = val;
set_dirty(true);
}
float Emboss::get_amount() const {
return amount;
float MMEmboss::get_amount() const {
return amount;
}
void Emboss::set_amount(const float val) {
amount = val;
void MMEmboss::set_amount(const float val) {
amount = val;
set_dirty(true);
}
float Emboss::get_width() const {
return width;
float MMEmboss::get_width() const {
return width;
}
void Emboss::set_width(const float val) {
width = val;
void MMEmboss::set_width(const float val) {
width = val;
set_dirty(true);
}
int Emboss::get_size() const {
return size;
int MMEmboss::get_size() const {
return size;
}
void Emboss::set_size(const int val) {
size = val;
void MMEmboss::set_size(const int val) {
size = val;
set_dirty(true);
}
void MMEmboss::_init_properties() {
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(float) ;
float angle = 0;
//export(float) ;
float amount = 5;
//export(float) ;
float width = 1;
int size = 0;
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
input->set_default_value(1);
}
void Emboss::_init_properties() {
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input1 ");
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
register_input_property(input);
register_output_property(image);
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
input.set_default_value(1);
void MMEmboss::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_float("get_angle", "set_angle", "Angle", 0.1);
mm_graph_node->add_slot_float("get_amount", "set_amount", "Amount", 0.1);
mm_graph_node->add_slot_float("get_width", "set_width", "Width", 1);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
register_input_property(input);
register_output_property(image);
void MMEmboss::_render(const Ref<MMMaterial> &material) {
size = MAX(material->image_size.x, material->image_size.y);
Ref<Image> img = render_image(material);
image->set_value(img);
}
void Emboss::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_float("get_angle", "set_angle", "Angle", 0.1);
mm_graph_node.add_slot_float("get_amount", "set_amount", "Amount", 0.1);
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 1);
Color MMEmboss::_get_value_for(const Vector2 &uv, const int pseed) {
float f = 0;
f = emboss(uv, size, angle, amount, width);
return Color(f, f, f, 1);
}
//float $(name)_fct(vec2 uv) {;
// float pixels = max(1.0, $width);
// float e = 1.0/$size;
// float rv = 0.0;
//;
// for (float dx = -pixels; dx <= pixels; dx += 1.0) {;
// for (float dy = -pixels; dy <= pixels; dy += 1.0) {;
// if (abs(dx) > 0.5 || abs(dy) > 0.5) {;
// rv += $in(uv+e*vec2(dx, dy))*cos(atan(dy, dx)-$angle*3.14159265359/180.0)/length(vec2(dx, dy));
// };
// };
// };
//;
// return $amount*rv/pixels+0.5;
//};
void Emboss::_render(const Variant &material) {
size = max(material.image_size.x, material.image_size.y);
Ref<Image> img = render_image(material);
image.set_value(img);
float MMEmboss::emboss(const Vector2 &uv, const float psize, const float pangle, const float pamount, const float pwidth) {
float pixels = MAX(1.0, pwidth);
float e = 1.0 / psize;
float rv = 0.0;
float dx = -pixels;
float dy = -pixels;
//for (float dx = -pixels; dx <= pixels; dx += 1.0) {;
while (dx <= pixels) {
//for (float dy = -pixels; dy <= pixels; dy += 1.0) {;
while (dy <= pixels) {
if ((abs(dx) > 0.5 || abs(dy) > 0.5)) {
rv += float(input->get_value(uv + e * Vector2(dx, dy))) * Math::cos(Math::atan2(dy, dx) - pangle * 3.14159265359 / 180.0) / Vector2(dx, dy).length();
}
dx += 1;
dy += 1;
}
}
return pamount * rv / pixels + 0.5;
}
Color Emboss::_get_value_for(const Vector2 &uv, const int pseed) {
float f = 0;
f = emboss(uv, size, angle, amount, width);
return Color(f, f, f, 1);
MMEmboss::MMEmboss() {
angle = 0;
amount = 5;
width = 1;
size = 0;
}
float Emboss::get_angle() {
return angle;
MMEmboss::~MMEmboss() {
}
void MMEmboss::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMEmboss::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMEmboss::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
void Emboss::set_angle(const float val) {
angle = val;
set_dirty(true);
ClassDB::bind_method(D_METHOD("get_input"), &MMEmboss::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMEmboss::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_angle"), &MMEmboss::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "value"), &MMEmboss::set_angle);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angle"), "set_angle", "get_angle");
ClassDB::bind_method(D_METHOD("get_amount"), &MMEmboss::get_amount);
ClassDB::bind_method(D_METHOD("set_amount", "value"), &MMEmboss::set_amount);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "amount"), "set_amount", "get_amount");
ClassDB::bind_method(D_METHOD("get_width"), &MMEmboss::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &MMEmboss::set_width);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
ClassDB::bind_method(D_METHOD("get_size"), &MMEmboss::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &MMEmboss::set_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("emboss", "uv", "psize", "pangle", "pamount", "pwidth"), &MMEmboss::emboss);
}
float Emboss::get_amount() {
return amount;
}
void Emboss::set_amount(const float val) {
amount = val;
set_dirty(true);
}
float Emboss::get_width() {
return width;
}
void Emboss::set_width(const float val) {
width = val;
set_dirty(true);
}
//float $(name)_fct(vec2 uv) {;
// float pixels = max(1.0, $width);
// float e = 1.0/$size;
// float rv = 0.0;
//;
// for (float dx = -pixels; dx <= pixels; dx += 1.0) {;
// for (float dy = -pixels; dy <= pixels; dy += 1.0) {;
// if (abs(dx) > 0.5 || abs(dy) > 0.5) {;
// rv += $in(uv+e*vec2(dx, dy))*cos(atan(dy, dx)-$angle*3.14159265359/180.0)/length(vec2(dx, dy));
// };
// };
// };
//;
// return $amount*rv/pixels+0.5;
//};
float Emboss::emboss(const Vector2 &uv, const float psize, const float pangle, const float pamount, const float pwidth) {
float pixels = max(1.0, pwidth);
float e = 1.0 / psize;
float rv = 0.0;
float dx = -pixels;
float dy = -pixels;
//for (float dx = -pixels; dx <= pixels; dx += 1.0) {;
while (dx <= pixels) {
//for (float dy = -pixels; dy <= pixels; dy += 1.0) {;
while (dy <= pixels) {
if ((abs(dx) > 0.5 || abs(dy) > 0.5)) {
rv += input.get_value(uv + e * Vector2(dx, dy)) * cos(atan2(dy, dx) - pangle * 3.14159265359 / 180.0) / Vector2(dx, dy).length();
}
dx += 1;
dy += 1;
}
}
return pamount * rv / pixels + 0.5;
}
}
Emboss::Emboss() {
image;
input;
angle = 0;
amount = 5;
width = 1;
size = 0;
}
Emboss::~Emboss() {
}
static void Emboss::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Emboss::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Emboss::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &Emboss::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &Emboss::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_angle"), &Emboss::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "value"), &Emboss::set_angle);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angle"), "set_angle", "get_angle");
ClassDB::bind_method(D_METHOD("get_amount"), &Emboss::get_amount);
ClassDB::bind_method(D_METHOD("set_amount", "value"), &Emboss::set_amount);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "amount"), "set_amount", "get_amount");
ClassDB::bind_method(D_METHOD("get_width"), &Emboss::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &Emboss::set_width);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
ClassDB::bind_method(D_METHOD("get_size"), &Emboss::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Emboss::set_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &Emboss::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Emboss::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Emboss::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Emboss::_get_value_for);
ClassDB::bind_method(D_METHOD("get_angle"), &Emboss::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "val"), &Emboss::set_angle);
ClassDB::bind_method(D_METHOD("get_amount"), &Emboss::get_amount);
ClassDB::bind_method(D_METHOD("set_amount", "val"), &Emboss::set_amount);
ClassDB::bind_method(D_METHOD("get_width"), &Emboss::get_width);
ClassDB::bind_method(D_METHOD("set_width", "val"), &Emboss::set_width);
ClassDB::bind_method(D_METHOD("emboss", "uv", "psize", "pangle", "pamount", "pwidth"), &Emboss::emboss);
}

View File

@ -1,76 +1,50 @@
#ifndef EMBOSS_H
#define EMBOSS_H
#ifndef MM_EMBOSS_H
#define MM_EMBOSS_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Emboss : public MMNode {
GDCLASS(Emboss, MMNode);
class MMEmboss : public MMNode {
GDCLASS(MMEmboss, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
float get_angle() const;
void set_angle(const float val);
float get_angle() const;
void set_angle(const float val);
float get_amount() const;
void set_amount(const float val);
float get_amount() const;
void set_amount(const float val);
float get_width() const;
void set_width(const float val);
float get_width() const;
void set_width(const float val);
int get_size() const;
void set_size(const int val);
int get_size() const;
void set_size(const int val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
float get_angle();
void set_angle(const float val);
float get_amount();
void set_amount(const float val);
float get_width();
void set_width(const float val);
float emboss(const Vector2 &uv, const float psize, const float pangle, const float pamount, const float pwidth);
float emboss(const Vector2 &uv, const float psize, const float pangle, const float pamount, const float pwidth);
Emboss();
~Emboss();
MMEmboss();
~MMEmboss();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(float)
float angle = 0;
//export(float)
float amount = 5;
//export(float)
float width = 1;
int size = 0;
//float $(name)_fct(vec2 uv) {
// float pixels = max(1.0, $width);
// float e = 1.0/$size;
// float rv = 0.0;
//
// for (float dx = -pixels; dx <= pixels; dx += 1.0) {
// for (float dy = -pixels; dy <= pixels; dy += 1.0) {
// if (abs(dx) > 0.5 || abs(dy) > 0.5) {
// rv += $in(uv+e*vec2(dx, dy))*cos(atan(dy, dx)-$angle*3.14159265359/180.0)/length(vec2(dx, dy));
// }
// }
// }
//
// return $amount*rv/pixels+0.5;
//}
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
float angle;
float amount;
float width;
int size;
};
#endif

View File

@ -1,179 +1,137 @@
#include "fill_channel.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> FillChannel::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMFillChannel::get_image() {
return image;
}
void FillChannel::set_image(const Ref<Resource> &val) {
image = val;
void MMFillChannel::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> FillChannel::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMFillChannel::get_input() {
return input;
}
void FillChannel::set_input(const Ref<Resource> &val) {
input = val;
void MMFillChannel::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
Ref<Resource> FillChannel::get_value() {
return value;
Ref<MMNodeUniversalProperty> MMFillChannel::get_value() {
return value;
}
void FillChannel::set_value(const Ref<Resource> &val) {
value = val;
void MMFillChannel::set_value(const Ref<MMNodeUniversalProperty> &val) {
value = val;
}
int FillChannel::get_channel() const {
return channel;
int MMFillChannel::get_channel() const {
return channel;
}
void FillChannel::set_channel(const int val) {
channel = val;
void MMFillChannel::set_channel(const int val) {
channel = val;
set_dirty(true);
}
void MMFillChannel::_init_properties() {
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(Resource) ;
Ref<Resource> value;
//export(int, "R,G,B,A") ;
int channel = 3;
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color());
}
void FillChannel::_init_properties() {
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input1 ");
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
if (!value.is_valid()) {
value.instance();
value->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
value->set_default_value(1);
}
value->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
value->set_value_step(0.01);
value->set_value_range(Vector2(0, 1));
register_input_property(input);
register_output_property(image);
register_input_property(value);
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
void MMFillChannel::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_float_universal(value);
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color());
Array arr;
arr.push_back("R");
arr.push_back("G");
arr.push_back("B");
arr.push_back("A");
mm_graph_node->add_slot_enum("get_channel", "set_channel", "Channel", arr);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
if (!value) {
value = MMNodeUniversalProperty.new();
value.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
value.set_default_value(1);
void MMFillChannel::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
value.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
value.value_step = 0.01;
value.value_range = Vector2(0, 1);
register_input_property(input);
register_output_property(image);
register_input_property(value);
Color MMFillChannel::_get_value_for(const Vector2 &uv, const int pseed) {
Color col = input->get_value(uv);
if (channel == 0) {
col.r = value->get_value(uv);
}
if (channel == 1) {
col.g = value->get_value(uv);
}
if (channel == 2) {
col.b = value->get_value(uv);
}
if (channel == 3) {
col.a = value->get_value(uv);
}
return col;
}
void FillChannel::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_float_universal(value);
mm_graph_node.add_slot_enum("get_channel", "set_channel", "Channel", [ "R", "G", "B", "A" ]);
MMFillChannel::MMFillChannel() {
channel = 3;
}
void FillChannel::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
MMFillChannel::~MMFillChannel() {
}
void MMFillChannel::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMFillChannel::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMFillChannel::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<MMNodeUniversalProperty>"), "set_image", "get_image");
Color FillChannel::_get_value_for(const Vector2 &uv, const int pseed) {
Color col = input.get_value(uv);
ClassDB::bind_method(D_METHOD("get_input"), &MMFillChannel::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMFillChannel::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<MMNodeUniversalProperty>"), "set_input", "get_input");
if (channel == 0) {
col.r = value.get_value(uv);
ClassDB::bind_method(D_METHOD("get_value"), &MMFillChannel::get_value);
ClassDB::bind_method(D_METHOD("set_value", "value"), &MMFillChannel::set_value);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "value", PROPERTY_HINT_RESOURCE_TYPE, "Ref<MMNodeUniversalProperty>"), "set_value", "get_value");
ClassDB::bind_method(D_METHOD("get_channel"), &MMFillChannel::get_channel);
ClassDB::bind_method(D_METHOD("set_channel", "value"), &MMFillChannel::set_channel);
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel"), "set_channel", "get_channel");
}
if (channel == 1) {
col.g = value.get_value(uv);
}
if (channel == 2) {
col.b = value.get_value(uv);
}
if (channel == 3) {
col.a = value.get_value(uv);
}
return col;
}
int FillChannel::get_channel() {
return channel;
}
void FillChannel::set_channel(const int val) {
channel = val;
set_dirty(true);
}
}
FillChannel::FillChannel() {
image;
input;
value;
channel = 3;
}
FillChannel::~FillChannel() {
}
static void FillChannel::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &FillChannel::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &FillChannel::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &FillChannel::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &FillChannel::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_value"), &FillChannel::get_value);
ClassDB::bind_method(D_METHOD("set_value", "value"), &FillChannel::set_value);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "value", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_value", "get_value");
ClassDB::bind_method(D_METHOD("get_channel"), &FillChannel::get_channel);
ClassDB::bind_method(D_METHOD("set_channel", "value"), &FillChannel::set_channel);
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel"), "set_channel", "get_channel");
ClassDB::bind_method(D_METHOD("_init_properties"), &FillChannel::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &FillChannel::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &FillChannel::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &FillChannel::_get_value_for);
ClassDB::bind_method(D_METHOD("get_channel"), &FillChannel::get_channel);
ClassDB::bind_method(D_METHOD("set_channel", "val"), &FillChannel::set_channel);
}

View File

@ -1,47 +1,41 @@
#ifndef FILL_CHANNEL_H
#define FILL_CHANNEL_H
#ifndef MM_FILL_CHANNEL_H
#define MM_FILL_CHANNEL_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class FillChannel : public MMNode {
GDCLASS(FillChannel, MMNode);
class MMFillChannel : public MMNode {
GDCLASS(MMFillChannel, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_value();
void set_value(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_value();
void set_value(const Ref<Resource> &val);
int get_channel() const;
void set_channel(const int val);
int get_channel() const;
void set_channel(const int val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
int get_channel();
void set_channel(const int val);
MMFillChannel();
~MMFillChannel();
FillChannel();
~FillChannel();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(Resource)
Ref<Resource> value;
//export(int, "R,G,B,A")
int channel = 3;
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
Ref<MMNodeUniversalProperty> value;
//export(int, "R,G,B,A")
int channel;
};
#endif

View File

@ -1,165 +1,118 @@
#include "fill_to_color.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> FillToColor::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMFillToColor::get_image() {
return image;
}
void FillToColor::set_image(const Ref<Resource> &val) {
image = val;
void MMFillToColor::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> FillToColor::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMFillToColor::get_input() {
return input;
}
void FillToColor::set_input(const Ref<Resource> &val) {
input = val;
void MMFillToColor::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
Ref<Resource> FillToColor::get_color_map() {
return color_map;
Ref<MMNodeUniversalProperty> MMFillToColor::get_color_map() {
return color_map;
}
void FillToColor::set_color_map(const Ref<Resource> &val) {
color_map = val;
void MMFillToColor::set_color_map(const Ref<MMNodeUniversalProperty> &val) {
color_map = val;
}
Color FillToColor::get_edge_color() {
return edge_color;
Color MMFillToColor::get_edge_color() {
return edge_color;
}
void FillToColor::set_edge_color(const Color &val) {
edge_color = val;
void MMFillToColor::set_edge_color(const Color &val) {
edge_color = val;
set_dirty(true);
}
void MMFillToColor::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color(0, 0, 0, 1));
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(Resource) ;
Ref<Resource> color_map;
//export(Color) ;
Color edge_color = Color(1, 1, 1, 1);
if (!color_map.is_valid()) {
color_map.instance();
color_map->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
color_map->set_default_value(Color(1, 1, 1, 1));
}
void FillToColor::_init_properties() {
color_map->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
color_map->set_slot_name(">>> Color Map ");
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
register_input_property(input);
register_input_property(color_map);
register_output_property(image);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!color_map) {
color_map = MMNodeUniversalProperty.new();
color_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
color_map.set_default_value(Color(1, 1, 1, 1));
void MMFillToColor::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_label_universal(color_map);
mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_color("get_edge_color", "set_edge_color");
}
color_map.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
color_map.slot_name = ">>> Color Map ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
void MMFillToColor::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_input_property(color_map);
register_output_property(image);
Color MMFillToColor::_get_value_for(const Vector2 &uv, const int pseed) {
//vec4 $(name_uv)_bb = $in($uv);
Color c = input->get_value(uv);
//mix($edgecolor, $map(fract($(name_uv)_bb.xy+0.5*$(name_uv)_bb.zw)), step(0.0000001, dot($(name_uv)_bb.zw, vec2(1.0))));
Color rc = color_map->get_value(MMAlgos::fractv2(Vector2(c.r, c.g) + 0.5 * Vector2(c.b, c.a)));
float s = MMAlgos::step(0.0000001, Vector2(c.b, c.a).dot(Vector2(1, 1)));
return edge_color.linear_interpolate(rc, s);
}
void FillToColor::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_label_universal(color_map);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_color("get_edge_color", "set_edge_color");
MMFillToColor::MMFillToColor() {
edge_color = Color(1, 1, 1, 1);
}
void FillToColor::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
MMFillToColor::~MMFillToColor() {
}
void MMFillToColor::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMFillToColor::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMFillToColor::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
Color FillToColor::_get_value_for(const Vector2 &uv, const int pseed) {
//vec4 $(name_uv)_bb = $in($uv);
Color c = input.get_value(uv);
//mix($edgecolor, $map(fract($(name_uv)_bb.xy+0.5*$(name_uv)_bb.zw)), step(0.0000001, dot($(name_uv)_bb.zw, vec2(1.0))));
Color rc = color_map.get_value(MMAlgos.fractv2(Vector2(c.r, c.g) + 0.5 * Vector2(c.b, c.a)));
float s = MMAlgos.step(0.0000001, Vector2(c.b, c.a).dot(Vector2(1, 1)));
return lerp(edge_color, rc, s);
ClassDB::bind_method(D_METHOD("get_input"), &MMFillToColor::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMFillToColor::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_color_map"), &MMFillToColor::get_color_map);
ClassDB::bind_method(D_METHOD("set_color_map", "value"), &MMFillToColor::set_color_map);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "color_map", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_color_map", "get_color_map");
ClassDB::bind_method(D_METHOD("get_edge_color"), &MMFillToColor::get_edge_color);
ClassDB::bind_method(D_METHOD("set_edge_color", "value"), &MMFillToColor::set_edge_color);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "edge_color"), "set_edge_color", "get_edge_color");
}
//edge_color;
Color FillToColor::get_edge_color() {
return edge_color;
}
void FillToColor::set_edge_color(const Color &val) {
edge_color = val;
set_dirty(true);
}
}
FillToColor::FillToColor() {
image;
input;
color_map;
edge_color = Color(1, 1, 1, 1);
}
FillToColor::~FillToColor() {
}
static void FillToColor::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &FillToColor::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &FillToColor::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &FillToColor::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &FillToColor::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_color_map"), &FillToColor::get_color_map);
ClassDB::bind_method(D_METHOD("set_color_map", "value"), &FillToColor::set_color_map);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "color_map", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_color_map", "get_color_map");
ClassDB::bind_method(D_METHOD("get_edge_color"), &FillToColor::get_edge_color);
ClassDB::bind_method(D_METHOD("set_edge_color", "value"), &FillToColor::set_edge_color);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "edge_color"), "set_edge_color", "get_edge_color");
ClassDB::bind_method(D_METHOD("_init_properties"), &FillToColor::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &FillToColor::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &FillToColor::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &FillToColor::_get_value_for);
ClassDB::bind_method(D_METHOD("get_edge_color"), &FillToColor::get_edge_color);
ClassDB::bind_method(D_METHOD("set_edge_color", "val"), &FillToColor::set_edge_color);
}

View File

@ -1,48 +1,40 @@
#ifndef FILL_TO_COLOR_H
#define FILL_TO_COLOR_H
#ifndef MM_FILL_TO_COLOR_H
#define MM_FILL_TO_COLOR_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class FillToColor : public MMNode {
GDCLASS(FillToColor, MMNode);
class MMFillToColor : public MMNode {
GDCLASS(MMFillToColor, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_color_map();
void set_color_map(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_color_map();
void set_color_map(const Ref<Resource> &val);
Color get_edge_color();
void set_edge_color(const Color &val);
Color get_edge_color();
void set_edge_color(const Color &val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
Color get_edge_color();
void set_edge_color(const Color &val);
MMFillToColor();
~MMFillToColor();
FillToColor();
~FillToColor();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(Resource)
Ref<Resource> color_map;
//export(Color)
Color edge_color = Color(1, 1, 1, 1);
//edge_color
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
Ref<MMNodeUniversalProperty> color_map;
Color edge_color;
};
#endif

View File

@ -1,154 +1,112 @@
#include "fill_to_position.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> FillToPosition::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMFillToPosition::get_image() {
return image;
}
void FillToPosition::set_image(const Ref<Resource> &val) {
image = val;
void MMFillToPosition::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> FillToPosition::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMFillToPosition::get_input() {
return input;
}
void FillToPosition::set_input(const Ref<Resource> &val) {
input = val;
void MMFillToPosition::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
int FillToPosition::get_axis() const {
return axis;
int MMFillToPosition::get_axis() const {
return axis;
}
void FillToPosition::set_axis(const int val) {
axis = val;
void MMFillToPosition::set_axis(const int val) {
axis = val;
set_dirty(true);
}
void MMFillToPosition::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color(0, 0, 0, 1));
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(int, "X,Y,Radial") ;
int axis = 2;
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void FillToPosition::_init_properties() {
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
register_input_property(input);
register_output_property(image);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
void MMFillToPosition::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
Array arr;
arr.push_back("X");
arr.push_back("Y");
arr.push_back("Radial");
mm_graph_node->add_slot_enum("get_axis", "set_axis", "Axis", arr);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_output_property(image);
void MMFillToPosition::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
Color MMFillToPosition::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input->get_value(uv);
//vec2 $(name_uv)_c = fract($in($uv).xy+0.5*$in($uv).zw);
Vector2 cnv = MMAlgos::fractv2(Vector2(c.r, c.g) + 0.5 * Vector2(c.b, c.a));
//X, $(name_uv)_c.x;
//Y, $(name_uv)_c.y;
//Radial, length($(name_uv)_c-vec2(0.5));
void FillToPosition::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_enum("get_axis", "set_axis", "Axis", [ "X", "Y", "Radial" ]);
if (axis == 0) {
return Color(cnv.x, cnv.x, cnv.x, 1);
} else if (axis == 1) {
return Color(cnv.y, cnv.y, cnv.y, 1);
} else if (axis == 2) {
float f = (cnv - Vector2(0.5, 0.5)).length();
return Color(f, f, f, 1);
}
return Color(0, 0, 0, 1);
}
void FillToPosition::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
MMFillToPosition::MMFillToPosition() {
axis = 2;
}
Color FillToPosition::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input.get_value(uv);
//vec2 $(name_uv)_c = fract($in($uv).xy+0.5*$in($uv).zw);
Vector2 cnv = MMAlgos.fractv2(Vector2(c.r, c.g) + 0.5 * Vector2(c.b, c.a));
//X, $(name_uv)_c.x;
//Y, $(name_uv)_c.y;
//Radial, length($(name_uv)_c-vec2(0.5));
if (axis == 0) {
return Color(cnv.x, cnv.x, cnv.x, 1);
MMFillToPosition::~MMFillToPosition() {
}
void MMFillToPosition::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMFillToPosition::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMFillToPosition::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<MMNodeUniversalProperty>"), "set_image", "get_image");
else if (axis == 1) {
return Color(cnv.y, cnv.y, cnv.y, 1);
ClassDB::bind_method(D_METHOD("get_input"), &MMFillToPosition::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMFillToPosition::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<MMNodeUniversalProperty>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_axis"), &MMFillToPosition::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "value"), &MMFillToPosition::set_axis);
ADD_PROPERTY(PropertyInfo(Variant::INT, "axis"), "set_axis", "get_axis");
}
else if (axis == 2) {
float f = (cnv - Vector2(0.5, 0.5)).length();
return Color(f, f, f, 1);
}
return Color(0, 0, 0, 1);
}
//axis;
int FillToPosition::get_axis() {
return axis;
}
void FillToPosition::set_axis(const int val) {
axis = val;
set_dirty(true);
}
}
FillToPosition::FillToPosition() {
image;
input;
axis = 2;
}
FillToPosition::~FillToPosition() {
}
static void FillToPosition::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &FillToPosition::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &FillToPosition::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &FillToPosition::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &FillToPosition::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_axis"), &FillToPosition::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "value"), &FillToPosition::set_axis);
ADD_PROPERTY(PropertyInfo(Variant::INT, "axis"), "set_axis", "get_axis");
ClassDB::bind_method(D_METHOD("_init_properties"), &FillToPosition::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &FillToPosition::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &FillToPosition::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &FillToPosition::_get_value_for);
ClassDB::bind_method(D_METHOD("get_axis"), &FillToPosition::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "val"), &FillToPosition::set_axis);
}

View File

@ -1,43 +1,37 @@
#ifndef FILL_TO_POSITION_H
#define FILL_TO_POSITION_H
#ifndef MM_FILL_TO_POSITION_H
#define MM_FILL_TO_POSITION_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class FillToPosition : public MMNode {
GDCLASS(FillToPosition, MMNode);
class MMFillToPosition : public MMNode {
GDCLASS(MMFillToPosition, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
int get_axis() const;
void set_axis(const int val);
int get_axis() const;
void set_axis(const int val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
int get_axis();
void set_axis(const int val);
MMFillToPosition();
~MMFillToPosition();
FillToPosition();
~FillToPosition();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(int, "X,Y,Radial")
int axis = 2;
//axis
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
//export(int, "X,Y,Radial")
int axis;
};
#endif

View File

@ -1,139 +1,97 @@
#include "fill_to_random_color.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> FillToRandomColor::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMFillToRandomColor::get_image() {
return image;
}
void FillToRandomColor::set_image(const Ref<Resource> &val) {
image = val;
void MMFillToRandomColor::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> FillToRandomColor::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMFillToRandomColor::get_input() {
return input;
}
void FillToRandomColor::set_input(const Ref<Resource> &val) {
input = val;
void MMFillToRandomColor::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
Color FillToRandomColor::get_edge_color() {
return edge_color;
Color MMFillToRandomColor::get_edge_color() {
return edge_color;
}
void FillToRandomColor::set_edge_color(const Color &val) {
edge_color = val;
void MMFillToRandomColor::set_edge_color(const Color &val) {
edge_color = val;
set_dirty(true);
}
void MMFillToRandomColor::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color(0, 0, 0, 1));
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(Color) ;
Color edge_color = Color(1, 1, 1, 1);
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void FillToRandomColor::_init_properties() {
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
register_input_property(input);
register_output_property(image);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
void MMFillToRandomColor::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_color("get_edge_color", "set_edge_color");
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_output_property(image);
void MMFillToRandomColor::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
void FillToRandomColor::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_color("get_edge_color", "set_edge_color");
Color MMFillToRandomColor::_get_value_for(const Vector2 &uv, const int pseed) {
//vec4 $(name_uv)_bb = $in($uv);
Color c = input->get_value(uv);
//mix($edgecolor.rgb, rand3(vec2(float($seed), rand(vec2(rand($(name_uv)_bb.xy), rand($(name_uv)_bb.zw))))), step(0.0000001, dot($(name_uv)_bb.zw, vec2(1.0))));
float r1 = MMAlgos::rand(Vector2(c.r, c.g));
float r2 = MMAlgos::rand(Vector2(c.b, c.a));
float s = MMAlgos::step(0.0000001, Vector2(c.b, c.a).dot(Vector2(1, 1)));
Vector3 f = Vector3(edge_color.r, edge_color.g, edge_color.b).linear_interpolate(MMAlgos::rand3(Vector2(1.0 / float(pseed), MMAlgos::rand(Vector2(r1, r2)))), s);
return Color(f.x, f.y, f.z, 1);
}
void FillToRandomColor::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
MMFillToRandomColor::MMFillToRandomColor() {
edge_color = Color(1, 1, 1, 1);
}
Color FillToRandomColor::_get_value_for(const Vector2 &uv, const int pseed) {
//vec4 $(name_uv)_bb = $in($uv);
Color c = input.get_value(uv);
//mix($edgecolor.rgb, rand3(vec2(float($seed), rand(vec2(rand($(name_uv)_bb.xy), rand($(name_uv)_bb.zw))))), step(0.0000001, dot($(name_uv)_bb.zw, vec2(1.0))));
float r1 = MMAlgos.rand(Vector2(c.r, c.g));
float r2 = MMAlgos.rand(Vector2(c.b, c.a));
float s = MMAlgos.step(0.0000001, Vector2(c.b, c.a).dot(Vector2(1, 1)));
Vector3 f = lerp(Vector3(edge_color.r, edge_color.g, edge_color.b), MMAlgos.rand3(Vector2(1.0 / float(pseed), MMAlgos.rand(Vector2(r1, r2)))), s);
return Color(f.x, f.y, f.z, 1);
MMFillToRandomColor::~MMFillToRandomColor() {
}
//edge_color;
void MMFillToRandomColor::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMFillToRandomColor::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMFillToRandomColor::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
Color FillToRandomColor::get_edge_color() {
return edge_color;
ClassDB::bind_method(D_METHOD("get_input"), &MMFillToRandomColor::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMFillToRandomColor::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_edge_color"), &MMFillToRandomColor::get_edge_color);
ClassDB::bind_method(D_METHOD("set_edge_color", "value"), &MMFillToRandomColor::set_edge_color);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "edge_color"), "set_edge_color", "get_edge_color");
}
void FillToRandomColor::set_edge_color(const Color &val) {
edge_color = val;
set_dirty(true);
}
}
FillToRandomColor::FillToRandomColor() {
image;
input;
edge_color = Color(1, 1, 1, 1);
}
FillToRandomColor::~FillToRandomColor() {
}
static void FillToRandomColor::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &FillToRandomColor::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &FillToRandomColor::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &FillToRandomColor::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &FillToRandomColor::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_edge_color"), &FillToRandomColor::get_edge_color);
ClassDB::bind_method(D_METHOD("set_edge_color", "value"), &FillToRandomColor::set_edge_color);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "edge_color"), "set_edge_color", "get_edge_color");
ClassDB::bind_method(D_METHOD("_init_properties"), &FillToRandomColor::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &FillToRandomColor::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &FillToRandomColor::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &FillToRandomColor::_get_value_for);
ClassDB::bind_method(D_METHOD("get_edge_color"), &FillToRandomColor::get_edge_color);
ClassDB::bind_method(D_METHOD("set_edge_color", "val"), &FillToRandomColor::set_edge_color);
}

View File

@ -1,43 +1,36 @@
#ifndef FILL_TO_RANDOM_COLOR_H
#define FILL_TO_RANDOM_COLOR_H
#ifndef MM_FILL_TO_RANDOM_COLOR_H
#define MM_FILL_TO_RANDOM_COLOR_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class FillToRandomColor : public MMNode {
GDCLASS(FillToRandomColor, MMNode);
class MMFillToRandomColor : public MMNode {
GDCLASS(MMFillToRandomColor, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
Color get_edge_color();
void set_edge_color(const Color &val);
Color get_edge_color();
void set_edge_color(const Color &val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
Color get_edge_color();
void set_edge_color(const Color &val);
MMFillToRandomColor();
~MMFillToRandomColor();
FillToRandomColor();
~FillToRandomColor();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(Color)
Color edge_color = Color(1, 1, 1, 1);
//edge_color
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
Color edge_color;
};
#endif

View File

@ -1,139 +1,96 @@
#include "fill_to_random_grey.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> FillToRandomGrey::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMFillToRandomGrey::get_image() {
return image;
}
void FillToRandomGrey::set_image(const Ref<Resource> &val) {
image = val;
void MMFillToRandomGrey::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> FillToRandomGrey::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMFillToRandomGrey::get_input() {
return input;
}
void FillToRandomGrey::set_input(const Ref<Resource> &val) {
input = val;
void MMFillToRandomGrey::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
float FillToRandomGrey::get_edge_color() const {
return edge_color;
float MMFillToRandomGrey::get_edge_color() const {
return edge_color;
}
void FillToRandomGrey::set_edge_color(const float val) {
edge_color = val;
void MMFillToRandomGrey::set_edge_color(const float val) {
edge_color = val;
set_dirty(true);
}
void MMFillToRandomGrey::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color(0, 0, 0, 1));
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(float) ;
float edge_color = 1;
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void FillToRandomGrey::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
register_input_property(input);
register_output_property(image);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
void MMFillToRandomGrey::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_float("get_edge_color", "set_edge_color", "Edge color", 0.01);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_output_property(image);
void MMFillToRandomGrey::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
void FillToRandomGrey::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_float("get_edge_color", "set_edge_color", "Edge color", 0.01);
Color MMFillToRandomGrey::_get_value_for(const Vector2 &uv, const int pseed) {
//vec4 $(name_uv)_bb = $in($uv);
Color c = input->get_value(uv);
//mix($edgecolor, rand(vec2(float($seed), rand(vec2(rand($(name_uv)_bb.xy), rand($(name_uv)_bb.zw))))), step(0.0000001, dot($(name_uv)_bb.zw, vec2(1.0))));
float r1 = MMAlgos::rand(Vector2(c.r, c.g));
float r2 = MMAlgos::rand(Vector2(c.b, c.a));
float s = MMAlgos::step(0.0000001, Vector2(c.b, c.a).dot(Vector2(1, 1)));
float f = Math::lerp(edge_color, MMAlgos::rand(Vector2(1.0 / float(pseed), MMAlgos::rand(Vector2(r1, r2)))), s);
return Color(f, f, f, 1);
}
void FillToRandomGrey::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
MMFillToRandomGrey::MMFillToRandomGrey() {
edge_color = 1;
}
Color FillToRandomGrey::_get_value_for(const Vector2 &uv, const int pseed) {
//vec4 $(name_uv)_bb = $in($uv);
Color c = input.get_value(uv);
//mix($edgecolor, rand(vec2(float($seed), rand(vec2(rand($(name_uv)_bb.xy), rand($(name_uv)_bb.zw))))), step(0.0000001, dot($(name_uv)_bb.zw, vec2(1.0))));
float r1 = MMAlgos.rand(Vector2(c.r, c.g));
float r2 = MMAlgos.rand(Vector2(c.b, c.a));
float s = MMAlgos.step(0.0000001, Vector2(c.b, c.a).dot(Vector2(1, 1)));
float f = lerp(edge_color, MMAlgos.rand(Vector2(1.0 / float(pseed), MMAlgos.rand(Vector2(r1, r2)))), s);
return Color(f, f, f, 1);
MMFillToRandomGrey::~MMFillToRandomGrey() {
}
//edge_color;
void MMFillToRandomGrey::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMFillToRandomGrey::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMFillToRandomGrey::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
float FillToRandomGrey::get_edge_color() {
return edge_color;
ClassDB::bind_method(D_METHOD("get_input"), &MMFillToRandomGrey::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMFillToRandomGrey::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_edge_color"), &MMFillToRandomGrey::get_edge_color);
ClassDB::bind_method(D_METHOD("set_edge_color", "value"), &MMFillToRandomGrey::set_edge_color);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "edge_color"), "set_edge_color", "get_edge_color");
}
void FillToRandomGrey::set_edge_color(const float val) {
edge_color = val;
set_dirty(true);
}
}
FillToRandomGrey::FillToRandomGrey() {
image;
input;
edge_color = 1;
}
FillToRandomGrey::~FillToRandomGrey() {
}
static void FillToRandomGrey::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &FillToRandomGrey::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &FillToRandomGrey::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &FillToRandomGrey::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &FillToRandomGrey::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_edge_color"), &FillToRandomGrey::get_edge_color);
ClassDB::bind_method(D_METHOD("set_edge_color", "value"), &FillToRandomGrey::set_edge_color);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "edge_color"), "set_edge_color", "get_edge_color");
ClassDB::bind_method(D_METHOD("_init_properties"), &FillToRandomGrey::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &FillToRandomGrey::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &FillToRandomGrey::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &FillToRandomGrey::_get_value_for);
ClassDB::bind_method(D_METHOD("get_edge_color"), &FillToRandomGrey::get_edge_color);
ClassDB::bind_method(D_METHOD("set_edge_color", "val"), &FillToRandomGrey::set_edge_color);
}

View File

@ -1,43 +1,36 @@
#ifndef FILL_TO_RANDOM_GREY_H
#define FILL_TO_RANDOM_GREY_H
#ifndef MM_FILL_TO_RANDOM_GREY_H
#define MM_FILL_TO_RANDOM_GREY_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class FillToRandomGrey : public MMNode {
GDCLASS(FillToRandomGrey, MMNode);
class MMFillToRandomGrey : public MMNode {
GDCLASS(MMFillToRandomGrey, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
float get_edge_color() const;
void set_edge_color(const float val);
float get_edge_color() const;
void set_edge_color(const float val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
float get_edge_color();
void set_edge_color(const float val);
MMFillToRandomGrey();
~MMFillToRandomGrey();
FillToRandomGrey();
~FillToRandomGrey();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(float)
float edge_color = 1;
//edge_color
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
float edge_color;
};
#endif

View File

@ -1,159 +1,114 @@
#include "fill_to_size.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> FillToSize::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMFillToSize::get_image() {
return image;
}
void FillToSize::set_image(const Ref<Resource> &val) {
image = val;
void MMFillToSize::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> FillToSize::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMFillToSize::get_input() {
return input;
}
void FillToSize::set_input(const Ref<Resource> &val) {
input = val;
void MMFillToSize::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
int FillToSize::get_formula() const {
return formula;
int MMFillToSize::get_formula() const {
return formula;
}
void FillToSize::set_formula(const int val) {
formula = val;
void MMFillToSize::set_formula(const int val) {
formula = val;
set_dirty(true);
}
void MMFillToSize::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color(0, 0, 0, 1));
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(int, "Area,Width,Height,Max(W,H)") ;
int formula = 0;
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void FillToSize::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
register_input_property(input);
register_output_property(image);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
void MMFillToSize::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
Array arr;
arr.push_back("Area");
arr.push_back("Width");
arr.push_back("Height");
arr.push_back("Max(W,H)");
mm_graph_node->add_slot_enum("get_formula", "set_formula", "Formula", arr);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_output_property(image);
void MMFillToSize::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
Color MMFillToSize::_get_value_for(const Vector2 &uv, const int pseed) {
//vec4 $(name_uv)_bb = $in($uv);
Color c = input->get_value(uv);
float f = 0;
//"Area" sqrt($(name_uv)_bb.z*$(name_uv)_bb.w);
//"Width" $(name_uv)_bb.z;
//"Height" $(name_uv)_bb.w;
//"max(W, H)" max($(name_uv)_bb.z, $(name_uv)_bb.w);
void FillToSize::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_enum("get_formula", "set_formula", "Formula", [ "Area", "Width", "Height", "Max(W,H)" ]);
if (formula == 0) {
f = sqrt(c.b * c.a);
} else if (formula == 1) {
f = c.b;
} else if (formula == 2) {
f = c.a;
} else if (formula == 3) {
f = MAX(c.b, c.a);
}
return Color(f, f, f, 1);
}
void FillToSize::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
MMFillToSize::MMFillToSize() {
formula = 0;
}
Color FillToSize::_get_value_for(const Vector2 &uv, const int pseed) {
//vec4 $(name_uv)_bb = $in($uv);
Color c = input.get_value(uv);
float f = 0;
//"Area" sqrt($(name_uv)_bb.z*$(name_uv)_bb.w);
//"Width" $(name_uv)_bb.z;
//"Height" $(name_uv)_bb.w;
//"max(W, H)" max($(name_uv)_bb.z, $(name_uv)_bb.w);
if (formula == 0) {
f = sqrt(c.b * c.a);
MMFillToSize::~MMFillToSize() {
}
void MMFillToSize::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMFillToSize::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMFillToSize::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
else if (formula == 1) {
f = c.b;
ClassDB::bind_method(D_METHOD("get_input"), &MMFillToSize::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMFillToSize::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_formula"), &MMFillToSize::get_formula);
ClassDB::bind_method(D_METHOD("set_formula", "value"), &MMFillToSize::set_formula);
ADD_PROPERTY(PropertyInfo(Variant::INT, "formula"), "set_formula", "get_formula");
}
else if (formula == 2) {
f = c.a;
}
else if (formula == 3) {
f = max(c.b, c.a);
}
return Color(f, f, f, 1);
}
//formula;
int FillToSize::get_formula() {
return formula;
}
void FillToSize::set_formula(const int val) {
formula = val;
set_dirty(true);
}
}
FillToSize::FillToSize() {
image;
input;
formula = 0;
}
FillToSize::~FillToSize() {
}
static void FillToSize::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &FillToSize::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &FillToSize::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &FillToSize::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &FillToSize::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_formula"), &FillToSize::get_formula);
ClassDB::bind_method(D_METHOD("set_formula", "value"), &FillToSize::set_formula);
ADD_PROPERTY(PropertyInfo(Variant::INT, "formula"), "set_formula", "get_formula");
ClassDB::bind_method(D_METHOD("_init_properties"), &FillToSize::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &FillToSize::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &FillToSize::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &FillToSize::_get_value_for);
ClassDB::bind_method(D_METHOD("get_formula"), &FillToSize::get_formula);
ClassDB::bind_method(D_METHOD("set_formula", "val"), &FillToSize::set_formula);
}

View File

@ -1,43 +1,37 @@
#ifndef FILL_TO_SIZE_H
#define FILL_TO_SIZE_H
#ifndef MM_FILL_TO_SIZE_H
#define MM_FILL_TO_SIZE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class FillToSize : public MMNode {
GDCLASS(FillToSize, MMNode);
class MMFillToSize : public MMNode {
GDCLASS(MMFillToSize, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
int get_formula() const;
void set_formula(const int val);
int get_formula() const;
void set_formula(const int val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
int get_formula();
void set_formula(const int val);
MMFillToSize();
~MMFillToSize();
FillToSize();
~FillToSize();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(int, "Area,Width,Height,Max(W,H)")
int formula = 0;
//formula
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
//export(int, "Area,Width,Height,Max(W,H)")
int formula;
};
#endif

View File

@ -1,146 +1,106 @@
#include "fill_to_uv.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> FillToUv::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMFillToUv::get_image() {
return image;
}
void FillToUv::set_image(const Ref<Resource> &val) {
image = val;
void MMFillToUv::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> FillToUv::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMFillToUv::get_input() {
return input;
}
void FillToUv::set_input(const Ref<Resource> &val) {
input = val;
void MMFillToUv::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
int FillToUv::get_mode() const {
return mode;
int MMFillToUv::get_mode() const {
return mode;
}
void FillToUv::set_mode(const int val) {
mode = val;
void MMFillToUv::set_mode(const int val) {
mode = val;
set_dirty(true);
}
void MMFillToUv::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color(0, 0, 0, 1));
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(int, "Stretch,Square") ;
int mode = 0;
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void FillToUv::_init_properties() {
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
register_input_property(input);
register_output_property(image);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
void MMFillToUv::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
Array arr;
arr.push_back("Stretch");
arr.push_back("Square");
mm_graph_node->add_slot_enum("get_mode", "set_mode", "Mode", arr);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_output_property(image);
void MMFillToUv::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
Color MMFillToUv::_get_value_for(const Vector2 &uv, const int pseed) {
//vec4 $(name_uv)_bb = $in($uv);
Color c = input->get_value(uv);
//fill_to_uv_$mode($uv, $(name_uv)_bb, float($seed));
Vector3 r = Vector3();
void FillToUv::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_enum("get_mode", "set_mode", "Mode", [ "Stretch", "Square" ]);
if (mode == 0) {
r = MMAlgos::fill_to_uv_stretch(uv, c, float(pseed));
} else if (mode == 1) {
r = MMAlgos::fill_to_uv_square(uv, c, float(pseed));
}
return Color(r.x, r.y, r.z, 1);
}
void FillToUv::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
MMFillToUv::MMFillToUv() {
mode = 0;
}
Color FillToUv::_get_value_for(const Vector2 &uv, const int pseed) {
//vec4 $(name_uv)_bb = $in($uv);
Color c = input.get_value(uv);
//fill_to_uv_$mode($uv, $(name_uv)_bb, float($seed));
Vector3 r = Vector3();
if (mode == 0) {
r = MMAlgos.fill_to_uv_stretch(uv, c, float(pseed));
MMFillToUv::~MMFillToUv() {
}
void MMFillToUv::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMFillToUv::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMFillToUv::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
else if (mode == 1) {
r = MMAlgos.fill_to_uv_square(uv, c, float(pseed));
ClassDB::bind_method(D_METHOD("get_input"), &MMFillToUv::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMFillToUv::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_mode"), &MMFillToUv::get_mode);
ClassDB::bind_method(D_METHOD("set_mode", "value"), &MMFillToUv::set_mode);
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode"), "set_mode", "get_mode");
}
return Color(r.x, r.y, r.z, 1);
}
//mode;
int FillToUv::get_mode() {
return mode;
}
void FillToUv::set_mode(const int val) {
mode = val;
set_dirty(true);
}
}
FillToUv::FillToUv() {
image;
input;
mode = 0;
}
FillToUv::~FillToUv() {
}
static void FillToUv::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &FillToUv::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &FillToUv::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &FillToUv::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &FillToUv::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_mode"), &FillToUv::get_mode);
ClassDB::bind_method(D_METHOD("set_mode", "value"), &FillToUv::set_mode);
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode"), "set_mode", "get_mode");
ClassDB::bind_method(D_METHOD("_init_properties"), &FillToUv::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &FillToUv::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &FillToUv::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &FillToUv::_get_value_for);
ClassDB::bind_method(D_METHOD("get_mode"), &FillToUv::get_mode);
ClassDB::bind_method(D_METHOD("set_mode", "val"), &FillToUv::set_mode);
}

View File

@ -1,43 +1,37 @@
#ifndef FILL_TO_UV_H
#define FILL_TO_UV_H
#ifndef MM_FILL_TO_UV_H
#define MM_FILL_TO_UV_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class FillToUv : public MMNode {
GDCLASS(FillToUv, MMNode);
class MMFillToUv : public MMNode {
GDCLASS(MMFillToUv, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
int get_mode() const;
void set_mode(const int val);
int get_mode() const;
void set_mode(const int val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
int get_mode();
void set_mode(const int val);
MMFillToUv();
~MMFillToUv();
FillToUv();
~FillToUv();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(int, "Stretch,Square")
int mode = 0;
//mode
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
//export(int, "Stretch,Square")
int mode;
};
#endif

View File

@ -1,159 +1,113 @@
#include "greyscale.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Greyscale::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMGreyscale::get_image() {
return image;
}
void Greyscale::set_image(const Ref<Resource> &val) {
image = val;
void MMGreyscale::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> Greyscale::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMGreyscale::get_input() {
return input;
}
void Greyscale::set_input(const Ref<Resource> &val) {
input = val;
void MMGreyscale::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
int Greyscale::get_type() const {
return type;
int MMGreyscale::get_type() const {
return type;
}
void Greyscale::set_type(const int val) {
type = val;
void MMGreyscale::set_type(const int val) {
type = val;
set_dirty(true);
}
void MMGreyscale::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color(0, 0, 0, 1));
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input1 ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(int, "Lightness,Average,Luminosity,Min,Max") ;
int type = 2;
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void Greyscale::_init_properties() {
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
register_input_property(input);
register_output_property(image);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
void MMGreyscale::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
Array arr;
arr.push_back("Lightness");
arr.push_back("Average");
arr.push_back("Luminosity");
arr.push_back("Min");
arr.push_back("Max");
mm_graph_node->add_slot_enum("get_type", "set_type", "Type", arr);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_output_property(image);
void MMGreyscale::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
Color MMGreyscale::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input->get_value(uv);
float f = 0;
void Greyscale::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_enum("get_type", "set_type", "Type", [ "Lightness", "Average", "Luminosity", "Min", "Max" ]);
if (type == 0) {
f = MMAlgos::grayscale_lightness(Vector3(c.r, c.g, c.b));
} else if (type == 1) {
f = MMAlgos::grayscale_average(Vector3(c.r, c.g, c.b));
} else if (type == 2) {
f = MMAlgos::grayscale_luminosity(Vector3(c.r, c.g, c.b));
} else if (type == 3) {
f = MMAlgos::grayscale_min(Vector3(c.r, c.g, c.b));
} else if (type == 4) {
f = MMAlgos::grayscale_max(Vector3(c.r, c.g, c.b));
}
return Color(f, f, f, c.a);
}
void Greyscale::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
MMGreyscale::MMGreyscale() {
type = 2;
}
Color Greyscale::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input.get_value(uv);
float f = 0;
if (type == 0) {
f = MMAlgos.grayscale_lightness(Vector3(c.r, c.g, c.b));
MMGreyscale::~MMGreyscale() {
}
void MMGreyscale::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMGreyscale::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMGreyscale::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
else if (type == 1) {
f = MMAlgos.grayscale_average(Vector3(c.r, c.g, c.b));
ClassDB::bind_method(D_METHOD("get_input"), &MMGreyscale::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMGreyscale::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_type"), &MMGreyscale::get_type);
ClassDB::bind_method(D_METHOD("set_type", "value"), &MMGreyscale::set_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "type"), "set_type", "get_type");
}
else if (type == 2) {
f = MMAlgos.grayscale_luminosity(Vector3(c.r, c.g, c.b));
}
else if (type == 3) {
f = MMAlgos.grayscale_min(Vector3(c.r, c.g, c.b));
}
else if (type == 4) {
f = MMAlgos.grayscale_max(Vector3(c.r, c.g, c.b));
}
return Color(f, f, f, c.a);
}
//type;
int Greyscale::get_type() {
return type;
}
void Greyscale::set_type(const int val) {
type = val;
set_dirty(true);
}
}
Greyscale::Greyscale() {
image;
input;
type = 2;
}
Greyscale::~Greyscale() {
}
static void Greyscale::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Greyscale::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Greyscale::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &Greyscale::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &Greyscale::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_type"), &Greyscale::get_type);
ClassDB::bind_method(D_METHOD("set_type", "value"), &Greyscale::set_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "type"), "set_type", "get_type");
ClassDB::bind_method(D_METHOD("_init_properties"), &Greyscale::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Greyscale::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Greyscale::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Greyscale::_get_value_for);
ClassDB::bind_method(D_METHOD("get_type"), &Greyscale::get_type);
ClassDB::bind_method(D_METHOD("set_type", "val"), &Greyscale::set_type);
}

View File

@ -1,43 +1,37 @@
#ifndef GREYSCALE_H
#define GREYSCALE_H
#ifndef MM_GREYSCALE_H
#define MM_GREYSCALE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Greyscale : public MMNode {
GDCLASS(Greyscale, MMNode);
class MMGreyscale : public MMNode {
GDCLASS(MMGreyscale, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
int get_type() const;
void set_type(const int val);
int get_type() const;
void set_type(const int val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
int get_type();
void set_type(const int val);
MMGreyscale();
~MMGreyscale();
Greyscale();
~Greyscale();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(int, "Lightness,Average,Luminosity,Min,Max")
int type = 2;
//type
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
//export(int, "Lightness,Average,Luminosity,Min,Max")
int type;
};
#endif

View File

@ -1,101 +1,75 @@
#include "invert.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Invert::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMInvert::get_image() {
return image;
}
void Invert::set_image(const Ref<Resource> &val) {
image = val;
void MMInvert::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> Invert::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMInvert::get_input() {
return input;
}
void Invert::set_input(const Ref<Resource> &val) {
input = val;
void MMInvert::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
void MMInvert::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color(0, 0, 0, 1));
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input1 ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void Invert::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
register_input_property(input);
register_output_property(image);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
void MMInvert::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_output_property(image);
void MMInvert::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
void Invert::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
Color MMInvert::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input->get_value(uv);
return MMAlgos::invert(c);
}
void Invert::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
MMInvert::MMInvert() {
}
Color Invert::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input.get_value(uv);
return MMAlgos.invert(c);
MMInvert::~MMInvert() {
}
void MMInvert::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMInvert::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMInvert::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &MMInvert::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMInvert::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
}
Invert::Invert() {
image;
input;
}
Invert::~Invert() {
}
static void Invert::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Invert::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Invert::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &Invert::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &Invert::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("_init_properties"), &Invert::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Invert::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Invert::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Invert::_get_value_for);
}

View File

@ -1,35 +1,35 @@
#ifndef INVERT_H
#define INVERT_H
#ifndef MM_INVERT_H
#define MM_INVERT_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Invert : public MMNode {
GDCLASS(Invert, MMNode);
class MMInvert : public MMNode {
GDCLASS(MMInvert, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
MMInvert();
~MMInvert();
Invert();
~Invert();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//tool
//export(MMNodeUniversalProperty)
Ref<MMNodeUniversalProperty> image;
//export(MMNodeUniversalProperty)
Ref<MMNodeUniversalProperty> input;
};
#endif

View File

@ -1,168 +1,125 @@
#include "make_tileable.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> MakeTileable::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMMakeTileable::get_image() {
return image;
}
void MakeTileable::set_image(const Ref<Resource> &val) {
image = val;
void MMMakeTileable::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> MakeTileable::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMMakeTileable::get_input() {
return input;
}
void MakeTileable::set_input(const Ref<Resource> &val) {
input = val;
void MMMakeTileable::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
float MakeTileable::get_width() const {
return width;
float MMMakeTileable::get_width() const {
return width;
}
void MakeTileable::set_width(const float val) {
width = val;
void MMMakeTileable::set_width(const float val) {
width = val;
set_dirty(true);
}
int MakeTileable::get_size() const {
return size;
int MMMakeTileable::get_size() const {
return size;
}
void MakeTileable::set_size(const int val) {
size = val;
void MMMakeTileable::set_size(const int val) {
size = val;
set_dirty(true);
}
void MMMakeTileable::_init_properties() {
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(float) ;
float width = 0.1;
int size = 0;
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color());
}
void MakeTileable::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input1 ");
register_input_property(input);
register_output_property(image);
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color());
void MMMakeTileable::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_float("get_width", "set_width", "Width", 0.01);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
register_input_property(input);
register_output_property(image);
void MMMakeTileable::_render(const Ref<MMMaterial> &material) {
size = MAX(material->image_size.x, material->image_size.y);
Ref<Image> img = render_image(material);
image->set_value(img);
}
void MakeTileable::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01);
Color MMMakeTileable::_get_value_for(const Vector2 &uv, const int pseed) {
//make_tileable_$(name)($uv, 0.5*$w);
return make_tileable(uv, 0.5 * width);
}
//----------------------;
//make_tileable.mmg;
//vec4 make_tileable_$(name)(vec2 uv, float w) {;
// vec4 a = $in(uv);
// vec4 b = $in(fract(uv+vec2(0.5)));
// float coef_ab = sin(1.57079632679*clamp((length(uv-vec2(0.5))-0.5+w)/w, 0.0, 1.0));
// vec4 c = $in(fract(uv+vec2(0.25)));
// float coef_abc = sin(1.57079632679*clamp((min(min(length(uv-vec2(0.0, 0.5)), length(uv-vec2(0.5, 0.0))), min(length(uv-vec2(1.0, 0.5)), length(uv-vec2(0.5, 1.0))))-w)/w, 0.0, 1.0));
// return mix(c, mix(a, b, coef_ab), coef_abc);
//};
void MakeTileable::_render(const Variant &material) {
size = max(material.image_size.x, material.image_size.y);
Ref<Image> img = render_image(material);
image.set_value(img);
Color MMMakeTileable::make_tileable(const Vector2 &uv, const float w) {
Color a = input->get_value(uv);
Color b = input->get_value(MMAlgos::fractv2(uv + Vector2(0.5, 0.5)));
float coef_ab = Math::sin(1.57079632679 * CLAMP(((uv - Vector2(0.5, 0.5)).length() - 0.5 + w) / w, 0.0, 1.0));
Color c = input->get_value(MMAlgos::fractv2(uv + Vector2(0.25, 0.25)));
float coef_abc = sin(1.57079632679 * CLAMP((MIN(MIN((uv - Vector2(0.0, 0.5)).length(), (uv - Vector2(0.5, 0.0)).length()), MIN((uv - Vector2(1.0, 0.5)).length(), (uv - Vector2(0.5, 1.0)).length())) - w) / w, 0.0, 1.0));
return c.linear_interpolate(a.linear_interpolate(b, coef_ab), coef_abc);
}
Color MakeTileable::_get_value_for(const Vector2 &uv, const int pseed) {
//make_tileable_$(name)($uv, 0.5*$w);
return make_tileable(uv, 0.5 * width);
MMMakeTileable::MMMakeTileable() {
width = 0.1;
size = 0;
}
float MakeTileable::get_width() {
return width;
MMMakeTileable::~MMMakeTileable() {
}
void MMMakeTileable::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMMakeTileable::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMMakeTileable::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
void MakeTileable::set_width(const float val) {
width = val;
set_dirty(true);
ClassDB::bind_method(D_METHOD("get_input"), &MMMakeTileable::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMMakeTileable::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_width"), &MMMakeTileable::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &MMMakeTileable::set_width);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
ClassDB::bind_method(D_METHOD("get_size"), &MMMakeTileable::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &MMMakeTileable::set_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("make_tileable", "uv", "w"), &MMMakeTileable::make_tileable);
}
//----------------------;
//make_tileable.mmg;
//vec4 make_tileable_$(name)(vec2 uv, float w) {;
// vec4 a = $in(uv);
// vec4 b = $in(fract(uv+vec2(0.5)));
// float coef_ab = sin(1.57079632679*clamp((length(uv-vec2(0.5))-0.5+w)/w, 0.0, 1.0));
// vec4 c = $in(fract(uv+vec2(0.25)));
// float coef_abc = sin(1.57079632679*clamp((min(min(length(uv-vec2(0.0, 0.5)), length(uv-vec2(0.5, 0.0))), min(length(uv-vec2(1.0, 0.5)), length(uv-vec2(0.5, 1.0))))-w)/w, 0.0, 1.0));
// return mix(c, mix(a, b, coef_ab), coef_abc);
//};
Color MakeTileable::make_tileable(const Vector2 &uv, const float w) {
Color a = input.get_value(uv);
Color b = input.get_value(MMAlgos.fractv2(uv + Vector2(0.5, 0.5)));
float coef_ab = sin(1.57079632679 * clamp(((uv - Vector2(0.5, 0.5)).length() - 0.5 + w) / w, 0.0, 1.0));
Color c = input.get_value(MMAlgos.fractv2(uv + Vector2(0.25, 0.25)));
float coef_abc = sin(1.57079632679 * clamp((min(min((uv - Vector2(0.0, 0.5)).length(), (uv - Vector2(0.5, 0.0)).length()), min((uv- Vector2(1.0, 0.5)).length(), (uv - Vector2(0.5, 1.0)).length())) - w) / w, 0.0, 1.0));
return lerp(c, lerp(a, b, coef_ab), coef_abc);
}
}
MakeTileable::MakeTileable() {
image;
input;
width = 0.1;
size = 0;
}
MakeTileable::~MakeTileable() {
}
static void MakeTileable::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MakeTileable::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MakeTileable::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &MakeTileable::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MakeTileable::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_width"), &MakeTileable::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &MakeTileable::set_width);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
ClassDB::bind_method(D_METHOD("get_size"), &MakeTileable::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &MakeTileable::set_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &MakeTileable::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &MakeTileable::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &MakeTileable::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &MakeTileable::_get_value_for);
ClassDB::bind_method(D_METHOD("get_width"), &MakeTileable::get_width);
ClassDB::bind_method(D_METHOD("set_width", "val"), &MakeTileable::set_width);
ClassDB::bind_method(D_METHOD("make_tileable", "uv", "w"), &MakeTileable::make_tileable);
}

View File

@ -1,57 +1,42 @@
#ifndef MAKE_TILEABLE_H
#define MAKE_TILEABLE_H
#ifndef MM_MAKE_TILEABLE_H
#define MM_MAKE_TILEABLE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class MakeTileable : public MMNode {
GDCLASS(MakeTileable, MMNode);
class MMMakeTileable : public MMNode {
GDCLASS(MMMakeTileable, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
float get_width() const;
void set_width(const float val);
float get_width() const;
void set_width(const float val);
int get_size() const;
void set_size(const int val);
int get_size() const;
void set_size(const int val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
float get_width();
void set_width(const float val);
Color make_tileable(const Vector2 &uv, const float w);
Color make_tileable(const Vector2 &uv, const float w);
MakeTileable();
~MakeTileable();
MMMakeTileable();
~MMMakeTileable();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(float)
float width = 0.1;
int size = 0;
//----------------------
//make_tileable.mmg
//vec4 make_tileable_$(name)(vec2 uv, float w) {
// vec4 a = $in(uv);
// vec4 b = $in(fract(uv+vec2(0.5)));
// float coef_ab = sin(1.57079632679*clamp((length(uv-vec2(0.5))-0.5+w)/w, 0.0, 1.0));
// vec4 c = $in(fract(uv+vec2(0.25)));
// float coef_abc = sin(1.57079632679*clamp((min(min(length(uv-vec2(0.0, 0.5)), length(uv-vec2(0.5, 0.0))), min(length(uv-vec2(1.0, 0.5)), length(uv-vec2(0.5, 1.0))))-w)/w, 0.0, 1.0));
// return mix(c, mix(a, b, coef_ab), coef_abc);
//}
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
float width;
int size;
};
#endif

View File

@ -1,369 +1,281 @@
#include "math.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Math::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMMath::get_image() {
return image;
}
void Math::set_image(const Ref<Resource> &val) {
image = val;
void MMMath::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> Math::get_a() {
return a;
Ref<MMNodeUniversalProperty> MMMath::get_a() {
return a;
}
void Math::set_a(const Ref<Resource> &val) {
a = val;
void MMMath::set_a(const Ref<MMNodeUniversalProperty> &val) {
a = val;
}
Ref<Resource> Math::get_b() {
return b;
Ref<MMNodeUniversalProperty> MMMath::get_b() {
return b;
}
void Math::set_b(const Ref<Resource> &val) {
b = val;
void MMMath::set_b(const Ref<MMNodeUniversalProperty> &val) {
b = val;
}
Ref<Resource> Math::get_output() {
return output;
Ref<MMNodeUniversalProperty> MMMath::get_output() {
return output;
}
void Math::set_output(const Ref<Resource> &val) {
output = val;
void MMMath::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
int Math::get_operation() const {
return operation;
int MMMath::get_operation() const {
return operation;
}
void Math::set_operation(const int val) {
operation = val;
void MMMath::set_operation(const int val) {
operation = val;
set_dirty(true);
output->do_emit_changed();
}
bool Math::get_clamp_result() const {
return clamp_result;
bool MMMath::get_clamp_result() const {
return clamp_result;
}
void Math::set_clamp_result(const bool val) {
clamp_result = val;
void MMMath::set_clamp_result(const bool val) {
clamp_result = val;
set_dirty(true);
output->do_emit_changed();
}
void MMMath::_init_properties() {
if (!a.is_valid()) {
a.instance();
a->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
a->set_default_value(0);
}
a->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
a->set_slot_name(">>> A ");
a->set_value_step(0.01);
a->set_value_range(Vector2(0, 1));
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> a;
//export(Resource) ;
Ref<Resource> b;
//export(Resource) ;
Ref<Resource> output;
//export(int, "A+B,A-B,A*B,A/B,log(A),log2(A),pow(A; B),abs(A),round(A),floor(A),ceil(A),trunc(A),fract(A),min(A; B),max(A; B),A<B,cos(A*B),sin(A*B),tan(A*B),sqrt(1-A*A)") ;
int operation = 0;
//export(bool) ;
bool clamp_result = false;
if (!b.is_valid()) {
b.instance();
b->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
b->set_default_value(0);
}
void Math::_init_properties() {
b->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
b->set_slot_name(">>> B ");
b->set_value_step(0.01);
b->set_value_range(Vector2(0, 1));
if (!a) {
a = MMNodeUniversalProperty.new();
a.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
a.set_default_value(0);
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
if (!output.is_valid()) {
output.instance();
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
output->set_default_value(0);
}
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
output->set_slot_name(" Output >>>");
output->set_get_value_from_owner(true);
register_input_property(a);
register_input_property(b);
register_output_property(output);
register_output_property(image);
}
a.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
a.slot_name = ">>> A ";
a.value_step = 0.01;
a.value_range = Vector2(0, 1);
void MMMath::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(a);
mm_graph_node->add_slot_label_universal(b);
mm_graph_node->add_slot_label_universal(output);
mm_graph_node->add_slot_texture_universal(image);
if (!b) {
b = MMNodeUniversalProperty.new();
b.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
b.set_default_value(0);
Array arr;
arr.push_back("A+B");
arr.push_back("A-B");
arr.push_back("A*B");
arr.push_back("A/B");
arr.push_back("log(A)");
arr.push_back("log2(A)");
arr.push_back("pow(A, B)");
arr.push_back("abs(A)");
arr.push_back("round(A)");
arr.push_back("floor(A)");
arr.push_back("ceil(A)");
arr.push_back("trunc(A)");
arr.push_back("fract(A)");
arr.push_back("min(A, B)");
arr.push_back("max(A, B)");
arr.push_back("A<B");
arr.push_back("cos(A*B)");
arr.push_back("sin(A*B)");
arr.push_back("tan(A*B)");
arr.push_back("sqrt(1-A*A)");
mm_graph_node->add_slot_enum("get_operation", "set_operation", "Operation", arr);
mm_graph_node->add_slot_bool("get_clamp_result", "set_clamp_result", "Clamp result");
}
b.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
b.slot_name = ">>> B ";
b.value_step = 0.01;
b.value_range = Vector2(0, 1);
Variant MMMath::_get_property_value(const Vector2 &uv) {
float af = a->get_value(uv);
float bf = b->get_value(uv);
float f = 0;
//"A+B",;
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
if (operation == 0) {
f = af + bf;
}
//"A-B",;
else if (operation == 1) {
f = af - bf;
}
//"A*B",;
else if (operation == 2) {
f = af * bf;
}
//"A/B",;
else if (operation == 3) {
if (bf == 0) {
bf = 0.000001;
}
f = af / bf;
}
//"log(A)",;
else if (operation == 4) {
//todo needs to be implemented;
f = log(af);
}
//"log2(A)",;
else if (operation == 5) {
//todo needs to be implemented;
f = log(af);
}
//"pow(A, B)",;
else if (operation == 6) {
f = pow(af, bf);
}
//"abs(A)",;
else if (operation == 7) {
f = abs(af);
}
//"round(A)",;
else if (operation == 8) {
f = round(af);
}
//"floor(A)",;
else if (operation == 9) {
f = floor(af);
}
//"ceil(A)",;
else if (operation == 10) {
f = ceil(af);
}
//"trunc(A)",;
else if (operation == 11) {
f = int(af);
}
//"fract(A)",;
else if (operation == 12) {
f = MMAlgos::fractf(af);
}
//"min(A, B)",;
else if (operation == 13) {
f = MIN(af, bf);
}
//"max(A, B)",;
else if (operation == 14) {
f = MAX(af, bf);
}
//"A<B",;
else if (operation == 15) {
f = af < bf;
}
//"cos(A*B)",;
else if (operation == 16) {
f = cos(af * bf);
}
//"sin(A*B)",;
else if (operation == 17) {
f = sin(af * bf);
}
//"tan(A*B)",;
else if (operation == 18) {
f = tan(af * bf);
}
//"sqrt(1-A*A)";
else if (operation == 19) {
f = sqrt(1 - af * af);
}
if (clamp_result) {
f = CLAMP(f, 0, 1);
}
return f;
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
output.set_default_value(0);
void MMMath::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
output.slot_name = " Output >>>";
output.get_value_from_owner = true;
register_input_property(a);
register_input_property(b);
register_output_property(output);
register_output_property(image);
Color MMMath::_get_value_for(const Vector2 &uv, const int pseed) {
float f = get_property_value(uv);
return Color(f, f, f, 1);
}
void Math::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(a);
mm_graph_node.add_slot_label_universal(b);
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_enum("get_operation", "set_operation", "Operation", [ "A+B", "A-B", "A*B", "A/B", "log(A)", "log2(A)", "pow(A, B)", "abs(A)", "round(A)", "floor(A)", "ceil(A)", "trunc(A)", "fract(A)", "min(A, B)", "max(A, B)", "A<B", "cos(A*B)", "sin(A*B)", "tan(A*B)", "sqrt(1-A*A)" ]);
mm_graph_node.add_slot_bool("get_clamp_result", "set_clamp_result", "Clamp result");
MMMath::MMMath() {
operation = 0;
clamp_result = false;
}
float Math::_get_property_value(const Vector2 &uv) {
float af = a.get_value(uv);
float bf = b.get_value(uv);
float f = 0;
//"A+B",;
if (operation == 0) {
f = af + bf;
MMMath::~MMMath() {
}
//"A-B",;
void MMMath::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMMath::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMMath::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
else if (operation == 1) {
f = af - bf;
ClassDB::bind_method(D_METHOD("get_a"), &MMMath::get_a);
ClassDB::bind_method(D_METHOD("set_a", "value"), &MMMath::set_a);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "a", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_a", "get_a");
ClassDB::bind_method(D_METHOD("get_b"), &MMMath::get_b);
ClassDB::bind_method(D_METHOD("set_b", "value"), &MMMath::set_b);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "b", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_b", "get_b");
ClassDB::bind_method(D_METHOD("get_output"), &MMMath::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMMath::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_operation"), &MMMath::get_operation);
ClassDB::bind_method(D_METHOD("set_operation", "value"), &MMMath::set_operation);
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation"), "set_operation", "get_operation");
ClassDB::bind_method(D_METHOD("get_clamp_result"), &MMMath::get_clamp_result);
ClassDB::bind_method(D_METHOD("set_clamp_result", "value"), &MMMath::set_clamp_result);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "clamp_result"), "set_clamp_result", "get_clamp_result");
}
//"A*B",;
else if (operation == 2) {
f = af * bf;
}
//"A/B",;
else if (operation == 3) {
if (bf == 0) {
bf = 0.000001;
}
f = af / bf;
}
//"log(A)",;
else if (operation == 4) {
//todo needs to be implemented;
f = log(af);
}
//"log2(A)",;
else if (operation == 5) {
//todo needs to be implemented;
f = log(af);
}
//"pow(A, B)",;
else if (operation == 6) {
f = pow(af, bf);
}
//"abs(A)",;
else if (operation == 7) {
f = abs(af);
}
//"round(A)",;
else if (operation == 8) {
f = round(af);
}
//"floor(A)",;
else if (operation == 9) {
f = floor(af);
}
//"ceil(A)",;
else if (operation == 10) {
f = ceil(af);
}
//"trunc(A)",;
else if (operation == 11) {
f = int(af);
}
//"fract(A)",;
else if (operation == 12) {
f = MMAlgos.fractf(af);
}
//"min(A, B)",;
else if (operation == 13) {
f = min(af, bf);
}
//"max(A, B)",;
else if (operation == 14) {
f = max(af, bf);
}
//"A<B",;
else if (operation == 15) {
f = af < bf;
}
//"cos(A*B)",;
else if (operation == 16) {
f = cos(af * bf);
}
//"sin(A*B)",;
else if (operation == 17) {
f = sin(af * bf);
}
//"tan(A*B)",;
else if (operation == 18) {
f = tan(af * bf);
}
//"sqrt(1-A*A)";
else if (operation == 19) {
f = sqrt(1 - af * af);
}
if (clamp_result) {
f = clamp(f, 0, 1);
}
return f;
}
void Math::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color Math::_get_value_for(const Vector2 &uv, const int pseed) {
float f = get_property_value(uv);
return Color(f, f, f, 1);
}
//operation;
int Math::get_operation() {
return operation;
}
void Math::set_operation(const int val) {
operation = val;
set_dirty(true);
output.emit_changed();
}
//clamp_result;
bool Math::get_clamp_result() {
return clamp_result;
}
void Math::set_clamp_result(const bool val) {
clamp_result = val;
set_dirty(true);
output.emit_changed();
}
}
Math::Math() {
image;
a;
b;
output;
operation = 0;
clamp_result = false;
}
Math::~Math() {
}
static void Math::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Math::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Math::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_a"), &Math::get_a);
ClassDB::bind_method(D_METHOD("set_a", "value"), &Math::set_a);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "a", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_a", "get_a");
ClassDB::bind_method(D_METHOD("get_b"), &Math::get_b);
ClassDB::bind_method(D_METHOD("set_b", "value"), &Math::set_b);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "b", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_b", "get_b");
ClassDB::bind_method(D_METHOD("get_output"), &Math::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &Math::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_operation"), &Math::get_operation);
ClassDB::bind_method(D_METHOD("set_operation", "value"), &Math::set_operation);
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation"), "set_operation", "get_operation");
ClassDB::bind_method(D_METHOD("get_clamp_result"), &Math::get_clamp_result);
ClassDB::bind_method(D_METHOD("set_clamp_result", "value"), &Math::set_clamp_result);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "clamp_result"), "set_clamp_result", "get_clamp_result");
ClassDB::bind_method(D_METHOD("_init_properties"), &Math::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Math::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &Math::_get_property_value);
ClassDB::bind_method(D_METHOD("_render", "material"), &Math::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Math::_get_value_for);
ClassDB::bind_method(D_METHOD("get_operation"), &Math::get_operation);
ClassDB::bind_method(D_METHOD("set_operation", "val"), &Math::set_operation);
ClassDB::bind_method(D_METHOD("get_clamp_result"), &Math::get_clamp_result);
ClassDB::bind_method(D_METHOD("set_clamp_result", "val"), &Math::set_clamp_result);
}

View File

@ -1,62 +1,50 @@
#ifndef MATH_H
#define MATH_H
#ifndef MM_MATH_H
#define MM_MATH_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Math : public MMNode {
GDCLASS(Math, MMNode);
class MMMath : public MMNode {
GDCLASS(MMMath, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_a();
void set_a(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_a();
void set_a(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_b();
void set_b(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_b();
void set_b(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
int get_operation() const;
void set_operation(const int val);
int get_operation() const;
void set_operation(const int val);
bool get_clamp_result() const;
void set_clamp_result(const bool val);
bool get_clamp_result() const;
void set_clamp_result(const bool val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
float _get_property_value(const Vector2 &uv);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
int get_operation();
void set_operation(const int val);
bool get_clamp_result();
void set_clamp_result(const bool val);
MMMath();
~MMMath();
Math();
~Math();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> a;
//export(Resource)
Ref<Resource> b;
//export(Resource)
Ref<Resource> output;
//export(int, "A+B,A-B,A*B,A/B,log(A),log2(A),pow(A; B),abs(A),round(A),floor(A),ceil(A),trunc(A),fract(A),min(A; B),max(A; B),A<B,cos(A*B),sin(A*B),tan(A*B),sqrt(1-A*A)")
int operation = 0;
//export(bool)
bool clamp_result = false;
//operation
//clamp_result
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> a;
Ref<MMNodeUniversalProperty> b;
Ref<MMNodeUniversalProperty> output;
//export(int, "A+B,A-B,A*B,A/B,log(A),log2(A),pow(A; B),abs(A),round(A),floor(A),ceil(A),trunc(A),fract(A),min(A; B),max(A; B),A<B,cos(A*B),sin(A*B),tan(A*B),sqrt(1-A*A)")
int operation;
bool clamp_result;
};
#endif

View File

@ -1,135 +1,92 @@
#include "quantize.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Quantize::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMQuantize::get_image() {
return image;
}
void Quantize::set_image(const Ref<Resource> &val) {
image = val;
void MMQuantize::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> Quantize::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMQuantize::get_input() {
return input;
}
void Quantize::set_input(const Ref<Resource> &val) {
input = val;
void MMQuantize::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
int Quantize::get_steps() const {
return steps;
int MMQuantize::get_steps() const {
return steps;
}
void Quantize::set_steps(const int val) {
steps = val;
void MMQuantize::set_steps(const int val) {
steps = val;
set_dirty(true);
}
void MMQuantize::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color(0, 0, 0, 1));
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(int) ;
int steps = 4;
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void Quantize::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
register_input_property(input);
register_output_property(image);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
void MMQuantize::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_int("get_steps", "set_steps", "Steps");
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_output_property(image);
void MMQuantize::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
void Quantize::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_int("get_steps", "set_steps", "Steps");
Color MMQuantize::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input->get_value(uv);
//vec4(floor($in($uv).rgb*$steps)/$steps, $in($uv).a);
Vector3 v = MMAlgos::floorv3(Vector3(c.r, c.g, c.b) * steps) / float(steps);
return Color(v.x, v.y, v.z, c.a);
}
void Quantize::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
MMQuantize::MMQuantize() {
steps = 4;
}
Color Quantize::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input.get_value(uv);
//vec4(floor($in($uv).rgb*$steps)/$steps, $in($uv).a);
Vector3 v = MMAlgos.floorv3(Vector3(c.r, c.g, c.b) * steps) / float(steps);
return Color(v.x, v.y, v.z, c.a);
MMQuantize::~MMQuantize() {
}
//steps;
void MMQuantize::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMQuantize::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMQuantize::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
int Quantize::get_steps() {
return steps;
ClassDB::bind_method(D_METHOD("get_input"), &MMQuantize::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMQuantize::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_steps"), &MMQuantize::get_steps);
ClassDB::bind_method(D_METHOD("set_steps", "value"), &MMQuantize::set_steps);
ADD_PROPERTY(PropertyInfo(Variant::INT, "steps"), "set_steps", "get_steps");
}
void Quantize::set_steps(const int val) {
steps = val;
set_dirty(true);
}
}
Quantize::Quantize() {
image;
input;
steps = 4;
}
Quantize::~Quantize() {
}
static void Quantize::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Quantize::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Quantize::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &Quantize::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &Quantize::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_steps"), &Quantize::get_steps);
ClassDB::bind_method(D_METHOD("set_steps", "value"), &Quantize::set_steps);
ADD_PROPERTY(PropertyInfo(Variant::INT, "steps"), "set_steps", "get_steps");
ClassDB::bind_method(D_METHOD("_init_properties"), &Quantize::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Quantize::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Quantize::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Quantize::_get_value_for);
ClassDB::bind_method(D_METHOD("get_steps"), &Quantize::get_steps);
ClassDB::bind_method(D_METHOD("set_steps", "val"), &Quantize::set_steps);
}

View File

@ -1,43 +1,36 @@
#ifndef QUANTIZE_H
#define QUANTIZE_H
#ifndef MM_QUANTIZE_H
#define MM_QUANTIZE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Quantize : public MMNode {
GDCLASS(Quantize, MMNode);
class MMQuantize : public MMNode {
GDCLASS(MMQuantize, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
int get_steps() const;
void set_steps(const int val);
int get_steps() const;
void set_steps(const int val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
int get_steps();
void set_steps(const int val);
MMQuantize();
~MMQuantize();
Quantize();
~Quantize();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(int)
int steps = 4;
//steps
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
int steps;
};
#endif

View File

@ -1,285 +1,176 @@
#include "swap_channels.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SwapChannels::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMSwapChannels::get_image() {
return image;
}
void SwapChannels::set_image(const Ref<Resource> &val) {
image = val;
void MMSwapChannels::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> SwapChannels::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMSwapChannels::get_input() {
return input;
}
void SwapChannels::set_input(const Ref<Resource> &val) {
input = val;
void MMSwapChannels::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
int SwapChannels::get_op_r() const {
return op_r;
int MMSwapChannels::get_op_r() const {
return op_r;
}
void SwapChannels::set_op_r(const int val) {
op_r = val;
void MMSwapChannels::set_op_r(const int val) {
op_r = val;
set_dirty(true);
}
int SwapChannels::get_op_g() const {
return op_g;
int MMSwapChannels::get_op_g() const {
return op_g;
}
void SwapChannels::set_op_g(const int val) {
op_g = val;
void MMSwapChannels::set_op_g(const int val) {
op_g = val;
set_dirty(true);
}
int SwapChannels::get_op_b() const {
return op_b;
int MMSwapChannels::get_op_b() const {
return op_b;
}
void SwapChannels::set_op_b(const int val) {
op_b = val;
void MMSwapChannels::set_op_b(const int val) {
op_b = val;
set_dirty(true);
}
int SwapChannels::get_op_a() const {
return op_a;
int MMSwapChannels::get_op_a() const {
return op_a;
}
void SwapChannels::set_op_a(const int val) {
op_a = val;
void MMSwapChannels::set_op_a(const int val) {
op_a = val;
set_dirty(true);
}
void MMSwapChannels::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
input->set_default_value(Color(0, 0, 0, 1));
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(int, "0,1,R,-R,G,-G,B,-B,A,-A") ;
int op_r = 2;
//export(int, "0,1,R,-R,G,-G,B,-B,A,-A") ;
int op_g = 4;
//export(int, "0,1,R,-R,G,-G,B,-B,A,-A") ;
int op_b = 6;
//export(int, "0,1,R,-R,G,-G,B,-B,A,-A") ;
int op_a = 8;
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void SwapChannels::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
register_input_property(input);
register_output_property(image);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
void MMSwapChannels::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
Array arr;
arr.push_back("0");
arr.push_back("1");
arr.push_back("R");
arr.push_back("-R");
arr.push_back("G");
arr.push_back("-G");
arr.push_back("B");
arr.push_back("-B");
arr.push_back("A");
arr.push_back("-A");
mm_graph_node->add_slot_enum("get_op_r", "set_op_r", "R", arr);
mm_graph_node->add_slot_enum("get_op_g", "set_op_g", "G", arr);
mm_graph_node->add_slot_enum("get_op_b", "set_op_b", "B", arr);
mm_graph_node->add_slot_enum("get_op_a", "set_op_a", "A", arr);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_output_property(image);
void MMSwapChannels::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
float MMSwapChannels::apply(const int op, const Color &val) {
if (op == 0) {
return 0.0;
} else if (op == 1) {
return 1.0;
} else if (op == 2) {
return val.r;
} else if (op == 3) {
return 1.0 - val.r;
} else if (op == 4) {
return val.g;
} else if (op == 5) {
return 1.0 - val.g;
} else if (op == 6) {
return val.b;
} else if (op == 7) {
return 1.0 - val.b;
} else if (op == 8) {
return val.a;
} else if (op == 9) {
return 1.0 - val.a;
}
void SwapChannels::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_enum("get_op_r", "set_op_r", "R", [ "0", "1", "R", "-R", "G", "-G", "B", "-B", "A","-A" ]);
mm_graph_node.add_slot_enum("get_op_g", "set_op_g", "G", [ "0", "1", "R", "-R", "G", "-G", "B", "-B", "A","-A" ]);
mm_graph_node.add_slot_enum("get_op_b", "set_op_b", "B", [ "0", "1", "R", "-R", "G", "-G", "B", "-B", "A","-A" ]);
mm_graph_node.add_slot_enum("get_op_a", "set_op_a", "A", [ "0", "1", "R", "-R", "G", "-G", "B", "-B", "A","-A" ]);
return 0.0;
}
void SwapChannels::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
Color MMSwapChannels::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input->get_value(uv);
return Color(apply(op_r, c), apply(op_g, c), apply(op_b, c), apply(op_a, c));
}
float SwapChannels::apply(const int op, const Color &val) {
if (op == 0) {
return 0.0;
MMSwapChannels::MMSwapChannels() {
op_r = 2;
op_g = 4;
op_b = 6;
op_a = 8;
}
else if (op == 1) {
return 1.0;
MMSwapChannels::~MMSwapChannels() {
}
void MMSwapChannels::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMSwapChannels::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMSwapChannels::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
else if (op == 2) {
return val.r;
ClassDB::bind_method(D_METHOD("get_input"), &MMSwapChannels::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMSwapChannels::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_op_r"), &MMSwapChannels::get_op_r);
ClassDB::bind_method(D_METHOD("set_op_r", "value"), &MMSwapChannels::set_op_r);
ADD_PROPERTY(PropertyInfo(Variant::INT, "op_r"), "set_op_r", "get_op_r");
ClassDB::bind_method(D_METHOD("get_op_g"), &MMSwapChannels::get_op_g);
ClassDB::bind_method(D_METHOD("set_op_g", "value"), &MMSwapChannels::set_op_g);
ADD_PROPERTY(PropertyInfo(Variant::INT, "op_g"), "set_op_g", "get_op_g");
ClassDB::bind_method(D_METHOD("get_op_b"), &MMSwapChannels::get_op_b);
ClassDB::bind_method(D_METHOD("set_op_b", "value"), &MMSwapChannels::set_op_b);
ADD_PROPERTY(PropertyInfo(Variant::INT, "op_b"), "set_op_b", "get_op_b");
ClassDB::bind_method(D_METHOD("get_op_a"), &MMSwapChannels::get_op_a);
ClassDB::bind_method(D_METHOD("set_op_a", "value"), &MMSwapChannels::set_op_a);
ADD_PROPERTY(PropertyInfo(Variant::INT, "op_a"), "set_op_a", "get_op_a");
ClassDB::bind_method(D_METHOD("apply", "op", "val"), &MMSwapChannels::apply);
}
else if (op == 3) {
return 1.0 - val.r;
}
else if (op == 4) {
return val.g;
}
else if (op == 5) {
return 1.0 - val.g;
}
else if (op == 6) {
return val.b;
}
else if (op == 7) {
return 1.0 - val.b;
}
else if (op == 8) {
return val.a;
}
else if (op == 9) {
return 1.0 - val.a;
}
return 0.0;
}
Color SwapChannels::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input.get_value(uv);
return Color(apply(op_r, c), apply(op_g, c), apply(op_b, c), apply(op_a, c));
}
//op_r;
int SwapChannels::get_op_r() {
return op_r;
}
void SwapChannels::set_op_r(const int val) {
op_r = val;
set_dirty(true);
}
//op_g;
int SwapChannels::get_op_g() {
return op_g;
}
void SwapChannels::set_op_g(const int val) {
op_g = val;
set_dirty(true);
}
//op_b;
int SwapChannels::get_op_b() {
return op_b;
}
void SwapChannels::set_op_b(const int val) {
op_b = val;
set_dirty(true);
}
//op_a;
int SwapChannels::get_op_a() {
return op_a;
}
void SwapChannels::set_op_a(const int val) {
op_a = val;
set_dirty(true);
}
}
SwapChannels::SwapChannels() {
image;
input;
op_r = 2;
op_g = 4;
op_b = 6;
op_a = 8;
}
SwapChannels::~SwapChannels() {
}
static void SwapChannels::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &SwapChannels::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &SwapChannels::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &SwapChannels::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &SwapChannels::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_op_r"), &SwapChannels::get_op_r);
ClassDB::bind_method(D_METHOD("set_op_r", "value"), &SwapChannels::set_op_r);
ADD_PROPERTY(PropertyInfo(Variant::INT, "op_r"), "set_op_r", "get_op_r");
ClassDB::bind_method(D_METHOD("get_op_g"), &SwapChannels::get_op_g);
ClassDB::bind_method(D_METHOD("set_op_g", "value"), &SwapChannels::set_op_g);
ADD_PROPERTY(PropertyInfo(Variant::INT, "op_g"), "set_op_g", "get_op_g");
ClassDB::bind_method(D_METHOD("get_op_b"), &SwapChannels::get_op_b);
ClassDB::bind_method(D_METHOD("set_op_b", "value"), &SwapChannels::set_op_b);
ADD_PROPERTY(PropertyInfo(Variant::INT, "op_b"), "set_op_b", "get_op_b");
ClassDB::bind_method(D_METHOD("get_op_a"), &SwapChannels::get_op_a);
ClassDB::bind_method(D_METHOD("set_op_a", "value"), &SwapChannels::set_op_a);
ADD_PROPERTY(PropertyInfo(Variant::INT, "op_a"), "set_op_a", "get_op_a");
ClassDB::bind_method(D_METHOD("_init_properties"), &SwapChannels::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SwapChannels::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &SwapChannels::_render);
ClassDB::bind_method(D_METHOD("apply", "op", "val"), &SwapChannels::apply);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &SwapChannels::_get_value_for);
ClassDB::bind_method(D_METHOD("get_op_r"), &SwapChannels::get_op_r);
ClassDB::bind_method(D_METHOD("set_op_r", "val"), &SwapChannels::set_op_r);
ClassDB::bind_method(D_METHOD("get_op_g"), &SwapChannels::get_op_g);
ClassDB::bind_method(D_METHOD("set_op_g", "val"), &SwapChannels::set_op_g);
ClassDB::bind_method(D_METHOD("get_op_b"), &SwapChannels::get_op_b);
ClassDB::bind_method(D_METHOD("set_op_b", "val"), &SwapChannels::set_op_b);
ClassDB::bind_method(D_METHOD("get_op_a"), &SwapChannels::get_op_a);
ClassDB::bind_method(D_METHOD("set_op_a", "val"), &SwapChannels::set_op_a);
}

View File

@ -1,68 +1,55 @@
#ifndef SWAP_CHANNELS_H
#define SWAP_CHANNELS_H
#ifndef MM_SWAP_CHANNELS_H
#define MM_SWAP_CHANNELS_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SwapChannels : public MMNode {
GDCLASS(SwapChannels, MMNode);
class MMSwapChannels : public MMNode {
GDCLASS(MMSwapChannels, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
int get_op_r() const;
void set_op_r(const int val);
int get_op_r() const;
void set_op_r(const int val);
int get_op_g() const;
void set_op_g(const int val);
int get_op_g() const;
void set_op_g(const int val);
int get_op_b() const;
void set_op_b(const int val);
int get_op_b() const;
void set_op_b(const int val);
int get_op_a() const;
void set_op_a(const int val);
int get_op_a() const;
void set_op_a(const int val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
float apply(const int op, const Color &val);
Color _get_value_for(const Vector2 &uv, const int pseed);
int get_op_r();
void set_op_r(const int val);
int get_op_g();
void set_op_g(const int val);
int get_op_b();
void set_op_b(const int val);
int get_op_a();
void set_op_a(const int val);
float apply(const int op, const Color &val);
SwapChannels();
~SwapChannels();
Color _get_value_for(const Vector2 &uv, const int pseed);
protected:
static void _bind_methods();
MMSwapChannels();
~MMSwapChannels();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(int, "0,1,R,-R,G,-G,B,-B,A,-A")
int op_r = 2;
//export(int, "0,1,R,-R,G,-G,B,-B,A,-A")
int op_g = 4;
//export(int, "0,1,R,-R,G,-G,B,-B,A,-A")
int op_b = 6;
//export(int, "0,1,R,-R,G,-G,B,-B,A,-A")
int op_a = 8;
//op_r
//op_g
//op_b
//op_a
protected:
static void _bind_methods();
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
//export(int, "0,1,R,-R,G,-G,B,-B,A,-A")
int op_r;
//export(int, "0,1,R,-R,G,-G,B,-B,A,-A")
int op_g;
//export(int, "0,1,R,-R,G,-G,B,-B,A,-A")
int op_b;
//export(int, "0,1,R,-R,G,-G,B,-B,A,-A")
int op_a;
};
#endif

View File

@ -1,115 +1,89 @@
#include "tonality.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Tonality::get_image() {
return image;
Ref<MMNodeUniversalProperty> MMTonality::get_image() {
return image;
}
void Tonality::set_image(const Ref<Resource> &val) {
image = val;
void MMTonality::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> Tonality::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMTonality::get_input() {
return input;
}
void Tonality::set_input(const Ref<Resource> &val) {
input = val;
void MMTonality::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
void MMTonality::_init_properties() {
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
input->set_default_value(0);
}
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name(">>> Input ");
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
void Tonality::_init() {
init_points_01();
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//image.force_override = true;
register_input_property(input);
register_output_property(image);
}
void Tonality::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
input.set_default_value(0);
void MMTonality::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_curve();
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
void MMTonality::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
//image.force_override = true;
register_input_property(input);
register_output_property(image);
Color MMTonality::_get_value_for(const Vector2 &uv, const int pseed) {
float f = input->get_value(uv);
float cf = MMAlgos::curve(f, points);
return Color(cf, cf, cf, 1);
}
void Tonality::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_curve();
void MMTonality::_curve_changed() {
set_dirty(true);
}
void Tonality::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
MMTonality::MMTonality() {
}
Color Tonality::_get_value_for(const Vector2 &uv, const int pseed) {
float f = input.get_value(uv);
float cf = MMAlgos.curve(f, points_array);
return Color(cf, cf, cf, 1);
MMTonality::~MMTonality() {
}
void Tonality::_curve_changed() {
set_dirty(true);
void MMTonality::_notification(int p_what) {
if (p_what == NOTIFICATION_POSTINITIALIZE) {
if (points.size() == 0) {
init_points_01();
}
}
}
void MMTonality::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMTonality::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMTonality::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &MMTonality::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMTonality::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
}
Tonality::Tonality() {
image;
input;
}
Tonality::~Tonality() {
}
static void Tonality::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Tonality::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Tonality::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &Tonality::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &Tonality::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("_init"), &Tonality::_init);
ClassDB::bind_method(D_METHOD("_init_properties"), &Tonality::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Tonality::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Tonality::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Tonality::_get_value_for);
ClassDB::bind_method(D_METHOD("_curve_changed"), &Tonality::_curve_changed);
}

View File

@ -1,37 +1,35 @@
#ifndef TONALITY_H
#define TONALITY_H
#ifndef MM_TONALITY_H
#define MM_TONALITY_H
#include "../bases/curve_base.h"
#include "../mm_node_universal_property.h"
class Tonality : public CurveBase {
GDCLASS(Tonality, CurveBase);
class MMTonality : public CurveBase {
GDCLASS(MMTonality, CurveBase);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _curve_changed();
void _init();
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _curve_changed();
MMTonality();
~MMTonality();
Tonality();
~Tonality();
protected:
void _notification(int p_what);
protected:
static void _bind_methods();
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
};
#endif

View File

@ -130,6 +130,29 @@ SOFTWARE.
#include "nodes/gradient/gradient.h"
#include "nodes/gradient/radial_gradient.h"
#include "nodes/filter/adjust_hsv.h"
#include "nodes/filter/blend.h"
#include "nodes/filter/blur_gaussian.h"
#include "nodes/filter/brightness_contrast.h"
#include "nodes/filter/colorize.h"
#include "nodes/filter/combine.h"
#include "nodes/filter/decompose.h"
#include "nodes/filter/emboss.h"
#include "nodes/filter/fill_channel.h"
#include "nodes/filter/fill_to_color.h"
#include "nodes/filter/fill_to_position.h"
#include "nodes/filter/fill_to_random_color.h"
#include "nodes/filter/fill_to_random_grey.h"
#include "nodes/filter/fill_to_size.h"
#include "nodes/filter/fill_to_uv.h"
#include "nodes/filter/greyscale.h"
#include "nodes/filter/invert.h"
#include "nodes/filter/make_tileable.h"
#include "nodes/filter/math.h"
#include "nodes/filter/quantize.h"
#include "nodes/filter/swap_channels.h"
#include "nodes/filter/tonality.h"
static _MMAlgos *_mm_algos_singleton = nullptr;
void register_material_maker_types() {
@ -303,6 +326,51 @@ void register_material_maker_types() {
ClassDB::register_class<MMCircularGradient>();
MMAlgos::register_node_class("Gradient", "MMCircularGradient");
ClassDB::register_class<MMTonality>();
MMAlgos::register_node_class("Filter", "MMTonality");
ClassDB::register_class<MMSwapChannels>();
MMAlgos::register_node_class("Filter", "MMSwapChannels");
ClassDB::register_class<MMQuantize>();
MMAlgos::register_node_class("Filter", "MMQuantize");
ClassDB::register_class<MMMath>();
MMAlgos::register_node_class("Filter", "MMMath");
ClassDB::register_class<MMMakeTileable>();
MMAlgos::register_node_class("Filter", "MMMakeTileable");
ClassDB::register_class<MMInvert>();
MMAlgos::register_node_class("Filter", "MMInvert");
ClassDB::register_class<MMGreyscale>();
MMAlgos::register_node_class("Filter", "MMGreyscale");
ClassDB::register_class<MMFillToUv>();
MMAlgos::register_node_class("Filter", "MMFillToUv");
ClassDB::register_class<MMFillToSize>();
MMAlgos::register_node_class("Filter", "MMFillToSize");
ClassDB::register_class<MMFillToRandomGrey>();
MMAlgos::register_node_class("Filter", "MMFillToRandomGrey");
ClassDB::register_class<MMFillToRandomColor>();
MMAlgos::register_node_class("Filter", "MMFillToRandomColor");
ClassDB::register_class<MMFillToPosition>();
MMAlgos::register_node_class("Filter", "MMFillToPosition");
ClassDB::register_class<MMFillToColor>();
MMAlgos::register_node_class("Filter", "MMFillToColor");
ClassDB::register_class<MMFillChannel>();
MMAlgos::register_node_class("Filter", "MMFillChannel");
ClassDB::register_class<MMEmboss>();
MMAlgos::register_node_class("Filter", "MMEmboss");
ClassDB::register_class<MMDecompose>();
MMAlgos::register_node_class("Filter", "MMDecompose");
ClassDB::register_class<MMCombine>();
MMAlgos::register_node_class("Filter", "MMCombine");
ClassDB::register_class<MMColorize>();
MMAlgos::register_node_class("Filter", "MMColorize");
ClassDB::register_class<MMBrightnessContrast>();
MMAlgos::register_node_class("Filter", "MMBrightnessContrast");
ClassDB::register_class<MMBlurGaussian>();
MMAlgos::register_node_class("Filter", "MMBlurGaussian");
ClassDB::register_class<MMBlend>();
MMAlgos::register_node_class("Filter", "MMBlend");
ClassDB::register_class<MMAdjustHsv>();
MMAlgos::register_node_class("Filter", "MMAdjustHsv");
_mm_algos_singleton = memnew(_MMAlgos);
Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton()));