Comverted the remaining nodes.

This commit is contained in:
Relintai 2022-06-16 15:29:08 +02:00
parent 1644490a3e
commit c028c76499
188 changed files with 22020 additions and 0 deletions

View File

@ -0,0 +1,197 @@
#include "adjust_hsv.h"
Ref<Resource> AdjustHsv::get_image() {
return image;
}
void AdjustHsv::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> AdjustHsv::get_input() {
return input;
}
void AdjustHsv::set_input(const Ref<Resource> &val) {
input = val;
}
float AdjustHsv::get_hue() const {
return hue;
}
void AdjustHsv::set_hue(const float val) {
hue = val;
}
float AdjustHsv::get_saturation() const {
return saturation;
}
void AdjustHsv::set_saturation(const float val) {
saturation = val;
}
float AdjustHsv::get_value() const {
return value;
}
void AdjustHsv::set_value(const float val) {
value = val;
}
//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;
void AdjustHsv::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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 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);
}
void AdjustHsv::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
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);
}
//hue;
float AdjustHsv::get_hue() {
return hue;
}
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

@ -0,0 +1,59 @@
#ifndef ADJUST_HSV_H
#define ADJUST_HSV_H
class AdjustHsv : public MMNode {
GDCLASS(AdjustHsv, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
float get_hue() const;
void set_hue(const float val);
float get_saturation() const;
void set_saturation(const float val);
float get_value() const;
void set_value(const float val);
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);
AdjustHsv();
~AdjustHsv();
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
};
#endif

View File

@ -0,0 +1,257 @@
#include "blend.h"
Ref<Resource> Blend::get_image() {
return image;
}
void Blend::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> Blend::get_input1() {
return input1;
}
void Blend::set_input1(const Ref<Resource> &val) {
input1 = val;
}
Ref<Resource> Blend::get_input2() {
return input2;
}
void Blend::set_input2(const Ref<Resource> &val) {
input2 = val;
}
int Blend::get_blend_type() const {
return blend_type;
}
void Blend::set_blend_type(const int val) {
blend_type = val;
}
Ref<Resource> Blend::get_opacity() {
return opacity;
}
void Blend::set_opacity(const Ref<Resource> &val) {
opacity = val;
}
//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;
void Blend::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!input1) {
input1 = MMNodeUniversalProperty.new();
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input1.set_default_value(Color(1, 1, 1, 1));
}
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));
}
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input2.slot_name = ">>> Input2 ";
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;
}
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);
}
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);
}
void Blend::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
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

@ -0,0 +1,69 @@
#ifndef BLEND_H
#define BLEND_H
class Blend : public MMNode {
GDCLASS(Blend, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input1();
void set_input1(const Ref<Resource> &val);
Ref<Resource> get_input2();
void set_input2(const Ref<Resource> &val);
int get_blend_type() const;
void set_blend_type(const int val);
Ref<Resource> get_opacity();
void set_opacity(const Ref<Resource> &val);
enum BlendType {
NORMAL = 0,
DISSOLVE,
MULTIPLY,
SCREEN,
OVERLAY,
HARD_LIGHT,
SOFT_LIGHT,
BURN,
DODGE,
LIGHTEN,
DARKEN,
DIFFRENCE
};
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

@ -0,0 +1,362 @@
#include "blur_gaussian.h"
Ref<Resource> BlurGaussian::get_image() {
return image;
}
void BlurGaussian::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> BlurGaussian::get_input() {
return input;
}
void BlurGaussian::set_input(const Ref<Resource> &val) {
input = val;
}
Ref<Resource> BlurGaussian::get_sigma() {
return sigma;
}
void BlurGaussian::set_sigma(const Ref<Resource> &val) {
sigma = val;
}
int BlurGaussian::get_direction() const {
return direction;
}
void BlurGaussian::set_direction(const int val) {
direction = val;
}
int BlurGaussian::get_size() const {
return size;
}
void BlurGaussian::set_size(const int val) {
size = val;
}
//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;
void BlurGaussian::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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());
}
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);
}
sigma.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
sigma.slot_name = "Sigma";
register_input_property(input);
register_output_property(image);
register_input_property(sigma);
}
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" ]);
}
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);
}
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);
}
}
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();
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;
}
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

@ -0,0 +1,88 @@
#ifndef BLUR_GAUSSIAN_H
#define BLUR_GAUSSIAN_H
class BlurGaussian : public MMNode {
GDCLASS(BlurGaussian, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
Ref<Resource> get_sigma();
void set_sigma(const Ref<Resource> &val);
int get_direction() const;
void set_direction(const int val);
int get_size() const;
void set_size(const int val);
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);
BlurGaussian();
~BlurGaussian();
protected:
static void _bind_methods();
//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;
//}
};
#endif

View File

@ -0,0 +1,165 @@
#include "brightness_contrast.h"
Ref<Resource> BrightnessContrast::get_image() {
return image;
}
void BrightnessContrast::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> BrightnessContrast::get_input() {
return input;
}
void BrightnessContrast::set_input(const Ref<Resource> &val) {
input = val;
}
float BrightnessContrast::get_brightness() const {
return brightness;
}
void BrightnessContrast::set_brightness(const float val) {
brightness = val;
}
float BrightnessContrast::get_contrast() const {
return contrast;
}
void BrightnessContrast::set_contrast(const float val) {
contrast = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(float) ;
float brightness = 0;
//export(float) ;
float contrast = 1;
void BrightnessContrast::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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 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);
}
void BrightnessContrast::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color BrightnessContrast::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input.get_value(uv);
return MMAlgos.brightness_contrast(c, brightness, contrast);
}
//brightness;
float BrightnessContrast::get_brightness() {
return brightness;
}
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

@ -0,0 +1,51 @@
#ifndef BRIGHTNESS_CONTRAST_H
#define BRIGHTNESS_CONTRAST_H
class BrightnessContrast : public MMNode {
GDCLASS(BrightnessContrast, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
float get_brightness() const;
void set_brightness(const float val);
float get_contrast() const;
void set_contrast(const float val);
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);
BrightnessContrast();
~BrightnessContrast();
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
};
#endif

View File

@ -0,0 +1,129 @@
#include "colorize.h"
Ref<Resource> Colorize::get_image() {
return image;
}
void Colorize::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> Colorize::get_input() {
return input;
}
void Colorize::set_input(const Ref<Resource> &val) {
input = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
void Colorize::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
input.set_default_value(1);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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 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();
}
void Colorize::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color Colorize::_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);
Color Colorize::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);
}
}
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

@ -0,0 +1,37 @@
#ifndef COLORIZE_H
#define COLORIZE_H
class Colorize : public GradientBase {
GDCLASS(Colorize, GradientBase);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
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);
Colorize();
~Colorize();
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)
};
#endif

View File

@ -0,0 +1,188 @@
#include "combine.h"
Ref<Resource> Combine::get_image() {
return image;
}
void Combine::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> Combine::get_input_r() {
return input_r;
}
void Combine::set_input_r(const Ref<Resource> &val) {
input_r = val;
}
Ref<Resource> Combine::get_input_g() {
return input_g;
}
void Combine::set_input_g(const Ref<Resource> &val) {
input_g = val;
}
Ref<Resource> Combine::get_input_b() {
return input_b;
}
void Combine::set_input_b(const Ref<Resource> &val) {
input_b = val;
}
Ref<Resource> Combine::get_input_a() {
return input_a;
}
void Combine::set_input_a(const Ref<Resource> &val) {
input_a = val;
}
//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;
void Combine::_init_properties() {
if (!input_r) {
input_r = MMNodeUniversalProperty.new();
input_r.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
input_r.set_default_value(0);
}
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);
}
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);
}
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);
}
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;
}
//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);
}
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);
}
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

@ -0,0 +1,50 @@
#ifndef COMBINE_H
#define COMBINE_H
class Combine : public MMNode {
GDCLASS(Combine, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input_r();
void set_input_r(const Ref<Resource> &val);
Ref<Resource> get_input_g();
void set_input_g(const Ref<Resource> &val);
Ref<Resource> get_input_b();
void set_input_b(const Ref<Resource> &val);
Ref<Resource> get_input_a();
void set_input_a(const Ref<Resource> &val);
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);
Combine();
~Combine();
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;
};
#endif

View File

@ -0,0 +1,211 @@
#include "decompose.h"
Ref<Resource> Decompose::get_input() {
return input;
}
void Decompose::set_input(const Ref<Resource> &val) {
input = val;
}
Ref<Resource> Decompose::get_out_r() {
return out_r;
}
void Decompose::set_out_r(const Ref<Resource> &val) {
out_r = val;
}
Ref<Resource> Decompose::get_out_g() {
return out_g;
}
void Decompose::set_out_g(const Ref<Resource> &val) {
out_g = val;
}
Ref<Resource> Decompose::get_out_b() {
return out_b;
}
void Decompose::set_out_b(const Ref<Resource> &val) {
out_b = val;
}
Ref<Resource> Decompose::get_out_a() {
return out_a;
}
void Decompose::set_out_a(const Ref<Resource> &val) {
out_a = val;
}
//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;
void Decompose::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
}
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;
}
out_r.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_g) {
out_g = MMNodeUniversalProperty.new();
out_g.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_g.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_b) {
out_b = MMNodeUniversalProperty.new();
out_b.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_b.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_a) {
out_a = MMNodeUniversalProperty.new();
out_a.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
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);
}
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);
}
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

@ -0,0 +1,50 @@
#ifndef DECOMPOSE_H
#define DECOMPOSE_H
class Decompose : public MMNode {
GDCLASS(Decompose, MMNode);
public:
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
Ref<Resource> get_out_r();
void set_out_r(const Ref<Resource> &val);
Ref<Resource> get_out_g();
void set_out_g(const Ref<Resource> &val);
Ref<Resource> get_out_b();
void set_out_b(const Ref<Resource> &val);
Ref<Resource> get_out_a();
void set_out_a(const Ref<Resource> &val);
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);
Decompose();
~Decompose();
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;
};
#endif

View File

@ -0,0 +1,253 @@
#include "emboss.h"
Ref<Resource> Emboss::get_image() {
return image;
}
void Emboss::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> Emboss::get_input() {
return input;
}
void Emboss::set_input(const Ref<Resource> &val) {
input = val;
}
float Emboss::get_angle() const {
return angle;
}
void Emboss::set_angle(const float val) {
angle = val;
}
float Emboss::get_amount() const {
return amount;
}
void Emboss::set_amount(const float val) {
amount = val;
}
float Emboss::get_width() const {
return width;
}
void Emboss::set_width(const float val) {
width = val;
}
int Emboss::get_size() const {
return size;
}
void Emboss::set_size(const int val) {
size = val;
}
//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;
void Emboss::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
register_input_property(input);
register_output_property(image);
}
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);
}
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);
}
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);
}
float Emboss::get_angle() {
return angle;
}
void Emboss::set_angle(const float val) {
angle = val;
set_dirty(true);
}
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

@ -0,0 +1,76 @@
#ifndef EMBOSS_H
#define EMBOSS_H
class Emboss : public MMNode {
GDCLASS(Emboss, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
float get_angle() const;
void set_angle(const float val);
float get_amount() const;
void set_amount(const float val);
float get_width() const;
void set_width(const float val);
int get_size() const;
void set_size(const int val);
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);
Emboss();
~Emboss();
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;
//}
};
#endif

View File

@ -0,0 +1,179 @@
#include "fill_channel.h"
Ref<Resource> FillChannel::get_image() {
return image;
}
void FillChannel::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> FillChannel::get_input() {
return input;
}
void FillChannel::set_input(const Ref<Resource> &val) {
input = val;
}
Ref<Resource> FillChannel::get_value() {
return value;
}
void FillChannel::set_value(const Ref<Resource> &val) {
value = val;
}
int FillChannel::get_channel() const {
return channel;
}
void FillChannel::set_channel(const int val) {
channel = val;
}
//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;
void FillChannel::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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());
}
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);
}
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);
}
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" ]);
}
void FillChannel::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color FillChannel::_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;
}
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

@ -0,0 +1,47 @@
#ifndef FILL_CHANNEL_H
#define FILL_CHANNEL_H
class FillChannel : public MMNode {
GDCLASS(FillChannel, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
Ref<Resource> get_value();
void set_value(const Ref<Resource> &val);
int get_channel() const;
void set_channel(const int val);
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);
FillChannel();
~FillChannel();
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;
};
#endif

View File

@ -0,0 +1,165 @@
#include "fill_to_color.h"
Ref<Resource> FillToColor::get_image() {
return image;
}
void FillToColor::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> FillToColor::get_input() {
return input;
}
void FillToColor::set_input(const Ref<Resource> &val) {
input = val;
}
Ref<Resource> FillToColor::get_color_map() {
return color_map;
}
void FillToColor::set_color_map(const Ref<Resource> &val) {
color_map = val;
}
Color FillToColor::get_edge_color() {
return edge_color;
}
void FillToColor::set_edge_color(const Color &val) {
edge_color = val;
}
//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);
void FillToColor::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
}
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));
}
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;
}
//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);
}
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");
}
void FillToColor::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
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);
}
//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

@ -0,0 +1,48 @@
#ifndef FILL_TO_COLOR_H
#define FILL_TO_COLOR_H
class FillToColor : public MMNode {
GDCLASS(FillToColor, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &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);
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);
FillToColor();
~FillToColor();
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
};
#endif

View File

@ -0,0 +1,154 @@
#include "fill_to_position.h"
Ref<Resource> FillToPosition::get_image() {
return image;
}
void FillToPosition::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> FillToPosition::get_input() {
return input;
}
void FillToPosition::set_input(const Ref<Resource> &val) {
input = val;
}
int FillToPosition::get_axis() const {
return axis;
}
void FillToPosition::set_axis(const int val) {
axis = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(int, "X,Y,Radial") ;
int axis = 2;
void FillToPosition::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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 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" ]);
}
void FillToPosition::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
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);
}
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);
}
//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

@ -0,0 +1,43 @@
#ifndef FILL_TO_POSITION_H
#define FILL_TO_POSITION_H
class FillToPosition : public MMNode {
GDCLASS(FillToPosition, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
int get_axis() const;
void set_axis(const int val);
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);
FillToPosition();
~FillToPosition();
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
};
#endif

View File

@ -0,0 +1,139 @@
#include "fill_to_random_color.h"
Ref<Resource> FillToRandomColor::get_image() {
return image;
}
void FillToRandomColor::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> FillToRandomColor::get_input() {
return input;
}
void FillToRandomColor::set_input(const Ref<Resource> &val) {
input = val;
}
Color FillToRandomColor::get_edge_color() {
return edge_color;
}
void FillToRandomColor::set_edge_color(const Color &val) {
edge_color = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(Color) ;
Color edge_color = Color(1, 1, 1, 1);
void FillToRandomColor::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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 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");
}
void FillToRandomColor::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
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);
}
//edge_color;
Color FillToRandomColor::get_edge_color() {
return 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

@ -0,0 +1,43 @@
#ifndef FILL_TO_RANDOM_COLOR_H
#define FILL_TO_RANDOM_COLOR_H
class FillToRandomColor : public MMNode {
GDCLASS(FillToRandomColor, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
Color get_edge_color();
void set_edge_color(const Color &val);
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);
FillToRandomColor();
~FillToRandomColor();
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
};
#endif

View File

@ -0,0 +1,139 @@
#include "fill_to_random_grey.h"
Ref<Resource> FillToRandomGrey::get_image() {
return image;
}
void FillToRandomGrey::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> FillToRandomGrey::get_input() {
return input;
}
void FillToRandomGrey::set_input(const Ref<Resource> &val) {
input = val;
}
float FillToRandomGrey::get_edge_color() const {
return edge_color;
}
void FillToRandomGrey::set_edge_color(const float val) {
edge_color = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(float) ;
float edge_color = 1;
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));
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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 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);
}
void FillToRandomGrey::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
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);
}
//edge_color;
float FillToRandomGrey::get_edge_color() {
return 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

@ -0,0 +1,43 @@
#ifndef FILL_TO_RANDOM_GREY_H
#define FILL_TO_RANDOM_GREY_H
class FillToRandomGrey : public MMNode {
GDCLASS(FillToRandomGrey, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
float get_edge_color() const;
void set_edge_color(const float val);
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);
FillToRandomGrey();
~FillToRandomGrey();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(float)
float edge_color = 1;
//edge_color
};
#endif

View File

@ -0,0 +1,159 @@
#include "fill_to_size.h"
Ref<Resource> FillToSize::get_image() {
return image;
}
void FillToSize::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> FillToSize::get_input() {
return input;
}
void FillToSize::set_input(const Ref<Resource> &val) {
input = val;
}
int FillToSize::get_formula() const {
return formula;
}
void FillToSize::set_formula(const int val) {
formula = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(int, "Area,Width,Height,Max(W,H)") ;
int formula = 0;
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));
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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 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)" ]);
}
void FillToSize::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
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);
}
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);
}
//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

@ -0,0 +1,43 @@
#ifndef FILL_TO_SIZE_H
#define FILL_TO_SIZE_H
class FillToSize : public MMNode {
GDCLASS(FillToSize, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
int get_formula() const;
void set_formula(const int val);
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);
FillToSize();
~FillToSize();
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
};
#endif

View File

@ -0,0 +1,146 @@
#include "fill_to_uv.h"
Ref<Resource> FillToUv::get_image() {
return image;
}
void FillToUv::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> FillToUv::get_input() {
return input;
}
void FillToUv::set_input(const Ref<Resource> &val) {
input = val;
}
int FillToUv::get_mode() const {
return mode;
}
void FillToUv::set_mode(const int val) {
mode = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(int, "Stretch,Square") ;
int mode = 0;
void FillToUv::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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 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" ]);
}
void FillToUv::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
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));
}
else if (mode == 1) {
r = MMAlgos.fill_to_uv_square(uv, c, float(pseed));
}
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

@ -0,0 +1,43 @@
#ifndef FILL_TO_UV_H
#define FILL_TO_UV_H
class FillToUv : public MMNode {
GDCLASS(FillToUv, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
int get_mode() const;
void set_mode(const int val);
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);
FillToUv();
~FillToUv();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(int, "Stretch,Square")
int mode = 0;
//mode
};
#endif

View File

@ -0,0 +1,159 @@
#include "greyscale.h"
Ref<Resource> Greyscale::get_image() {
return image;
}
void Greyscale::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> Greyscale::get_input() {
return input;
}
void Greyscale::set_input(const Ref<Resource> &val) {
input = val;
}
int Greyscale::get_type() const {
return type;
}
void Greyscale::set_type(const int val) {
type = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(int, "Lightness,Average,Luminosity,Min,Max") ;
int type = 2;
void Greyscale::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
input.set_default_value(Color(0, 0, 0, 1));
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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 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" ]);
}
void Greyscale::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
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));
}
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);
}
//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

@ -0,0 +1,43 @@
#ifndef GREYSCALE_H
#define GREYSCALE_H
class Greyscale : public MMNode {
GDCLASS(Greyscale, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
int get_type() const;
void set_type(const int val);
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);
Greyscale();
~Greyscale();
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
};
#endif

View File

@ -0,0 +1,101 @@
#include "invert.h"
Ref<Resource> Invert::get_image() {
return image;
}
void Invert::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> Invert::get_input() {
return input;
}
void Invert::set_input(const Ref<Resource> &val) {
input = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
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));
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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 Invert::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_texture_universal(image);
}
void Invert::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color Invert::_get_value_for(const Vector2 &uv, const int pseed) {
Color c = input.get_value(uv);
return MMAlgos.invert(c);
}
}
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

@ -0,0 +1,35 @@
#ifndef INVERT_H
#define INVERT_H
class Invert : public MMNode {
GDCLASS(Invert, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
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);
Invert();
~Invert();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
};
#endif

View File

@ -0,0 +1,168 @@
#include "make_tileable.h"
Ref<Resource> MakeTileable::get_image() {
return image;
}
void MakeTileable::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> MakeTileable::get_input() {
return input;
}
void MakeTileable::set_input(const Ref<Resource> &val) {
input = val;
}
float MakeTileable::get_width() const {
return width;
}
void MakeTileable::set_width(const float val) {
width = val;
}
int MakeTileable::get_size() const {
return size;
}
void MakeTileable::set_size(const int val) {
size = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(float) ;
float width = 0.1;
int size = 0;
void MakeTileable::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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());
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input1 ";
register_input_property(input);
register_output_property(image);
}
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);
}
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 MakeTileable::_get_value_for(const Vector2 &uv, const int pseed) {
//make_tileable_$(name)($uv, 0.5*$w);
return make_tileable(uv, 0.5 * width);
}
float MakeTileable::get_width() {
return width;
}
void MakeTileable::set_width(const float val) {
width = val;
set_dirty(true);
}
//----------------------;
//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

@ -0,0 +1,57 @@
#ifndef MAKE_TILEABLE_H
#define MAKE_TILEABLE_H
class MakeTileable : public MMNode {
GDCLASS(MakeTileable, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
float get_width() const;
void set_width(const float val);
int get_size() const;
void set_size(const int val);
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);
MakeTileable();
~MakeTileable();
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);
//}
};
#endif

View File

@ -0,0 +1,369 @@
#include "math.h"
Ref<Resource> Math::get_image() {
return image;
}
void Math::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> Math::get_a() {
return a;
}
void Math::set_a(const Ref<Resource> &val) {
a = val;
}
Ref<Resource> Math::get_b() {
return b;
}
void Math::set_b(const Ref<Resource> &val) {
b = val;
}
Ref<Resource> Math::get_output() {
return output;
}
void Math::set_output(const Ref<Resource> &val) {
output = val;
}
int Math::get_operation() const {
return operation;
}
void Math::set_operation(const int val) {
operation = val;
}
bool Math::get_clamp_result() const {
return clamp_result;
}
void Math::set_clamp_result(const bool val) {
clamp_result = val;
}
//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;
void Math::_init_properties() {
if (!a) {
a = MMNodeUniversalProperty.new();
a.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
a.set_default_value(0);
}
a.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
a.slot_name = ">>> A ";
a.value_step = 0.01;
a.value_range = Vector2(0, 1);
if (!b) {
b = MMNodeUniversalProperty.new();
b.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
b.set_default_value(0);
}
b.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
b.slot_name = ">>> B ";
b.value_step = 0.01;
b.value_range = Vector2(0, 1);
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
//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);
}
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);
}
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");
}
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;
}
//"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;
}
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

@ -0,0 +1,62 @@
#ifndef MATH_H
#define MATH_H
class Math : public MMNode {
GDCLASS(Math, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_a();
void set_a(const Ref<Resource> &val);
Ref<Resource> get_b();
void set_b(const Ref<Resource> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
int get_operation() const;
void set_operation(const int val);
bool get_clamp_result() const;
void set_clamp_result(const bool val);
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);
Math();
~Math();
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
};
#endif

View File

@ -0,0 +1,135 @@
#include "quantize.h"
Ref<Resource> Quantize::get_image() {
return image;
}
void Quantize::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> Quantize::get_input() {
return input;
}
void Quantize::set_input(const Ref<Resource> &val) {
input = val;
}
int Quantize::get_steps() const {
return steps;
}
void Quantize::set_steps(const int val) {
steps = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(int) ;
int steps = 4;
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));
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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 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");
}
void Quantize::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
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);
}
//steps;
int Quantize::get_steps() {
return 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

@ -0,0 +1,43 @@
#ifndef QUANTIZE_H
#define QUANTIZE_H
class Quantize : public MMNode {
GDCLASS(Quantize, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
int get_steps() const;
void set_steps(const int val);
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);
Quantize();
~Quantize();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(int)
int steps = 4;
//steps
};
#endif

View File

@ -0,0 +1,285 @@
#include "swap_channels.h"
Ref<Resource> SwapChannels::get_image() {
return image;
}
void SwapChannels::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> SwapChannels::get_input() {
return input;
}
void SwapChannels::set_input(const Ref<Resource> &val) {
input = val;
}
int SwapChannels::get_op_r() const {
return op_r;
}
void SwapChannels::set_op_r(const int val) {
op_r = val;
}
int SwapChannels::get_op_g() const {
return op_g;
}
void SwapChannels::set_op_g(const int val) {
op_g = val;
}
int SwapChannels::get_op_b() const {
return op_b;
}
void SwapChannels::set_op_b(const int val) {
op_b = val;
}
int SwapChannels::get_op_a() const {
return op_a;
}
void SwapChannels::set_op_a(const int val) {
op_a = val;
}
//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;
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));
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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 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" ]);
}
void SwapChannels::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
float SwapChannels::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;
}
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

@ -0,0 +1,68 @@
#ifndef SWAP_CHANNELS_H
#define SWAP_CHANNELS_H
class SwapChannels : public MMNode {
GDCLASS(SwapChannels, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &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_g() const;
void set_op_g(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);
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);
SwapChannels();
~SwapChannels();
protected:
static void _bind_methods();
//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
};
#endif

View File

@ -0,0 +1,115 @@
#include "tonality.h"
Ref<Resource> Tonality::get_image() {
return image;
}
void Tonality::set_image(const Ref<Resource> &val) {
image = val;
}
Ref<Resource> Tonality::get_input() {
return input;
}
void Tonality::set_input(const Ref<Resource> &val) {
input = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
void Tonality::_init() {
init_points_01();
}
void Tonality::_init_properties() {
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
input.set_default_value(0);
}
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = ">>> Input ";
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_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 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 Tonality::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
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);
}
void Tonality::_curve_changed() {
set_dirty(true);
}
}
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

@ -0,0 +1,37 @@
#ifndef TONALITY_H
#define TONALITY_H
class Tonality : public CurveBase {
GDCLASS(Tonality, CurveBase);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
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();
Tonality();
~Tonality();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
};
#endif

View File

@ -0,0 +1,148 @@
#include "circular_gradient.h"
Ref<Resource> CircularGradient::get_image() {
return image;
}
void CircularGradient::set_image(const Ref<Resource> &val) {
image = val;
}
float CircularGradient::get_repeat() const {
return repeat;
}
void CircularGradient::set_repeat(const float val) {
repeat = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(float) ;
float repeat = 1;
void CircularGradient::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void CircularGradient::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_float("get_repeat", "set_repeat", "repeat");
mm_graph_node.add_slot_gradient();
}
void CircularGradient::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color CircularGradient::_get_value_for(const Vector2 &uv, const int pseed) {
if (interpolation_type == 0) {
return MMAlgos.circular_gradient_type_1(uv, repeat, points);
}
else if (interpolation_type == 1) {
return MMAlgos.circular_gradient_type_2(uv, repeat, points);
}
else if (interpolation_type == 2) {
return MMAlgos.circular_gradient_type_3(uv, repeat, points);
}
else if (interpolation_type == 3) {
return MMAlgos.circular_gradient_type_4(uv, repeat, points);
}
return Color(1, 1, 1, 1);
}
Color CircularGradient::_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);
}
float CircularGradient::get_repeat() {
return repeat;
}
void CircularGradient::set_repeat(const float val) {
repeat = val;
set_dirty(true);
}
}
CircularGradient::CircularGradient() {
image;
repeat = 1;
}
CircularGradient::~CircularGradient() {
}
static void CircularGradient::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &CircularGradient::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &CircularGradient::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_repeat"), &CircularGradient::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "value"), &CircularGradient::set_repeat);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "repeat"), "set_repeat", "get_repeat");
ClassDB::bind_method(D_METHOD("_init_properties"), &CircularGradient::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &CircularGradient::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &CircularGradient::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &CircularGradient::_get_value_for);
ClassDB::bind_method(D_METHOD("_get_gradient_color", "x"), &CircularGradient::_get_gradient_color);
ClassDB::bind_method(D_METHOD("get_repeat"), &CircularGradient::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "val"), &CircularGradient::set_repeat);
}

View File

@ -0,0 +1,38 @@
#ifndef CIRCULAR_GRADIENT_H
#define CIRCULAR_GRADIENT_H
class CircularGradient : public GradientBase {
GDCLASS(CircularGradient, GradientBase);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
float get_repeat() const;
void set_repeat(const float val);
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);
float get_repeat();
void set_repeat(const float val);
CircularGradient();
~CircularGradient();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(float)
float repeat = 1;
};
#endif

View File

@ -0,0 +1,179 @@
#include "gradient.h"
Ref<Resource> Gradient::get_image() {
return image;
}
void Gradient::set_image(const Ref<Resource> &val) {
image = val;
}
float Gradient::get_repeat() const {
return repeat;
}
void Gradient::set_repeat(const float val) {
repeat = val;
}
float Gradient::get_rotate() const {
return rotate;
}
void Gradient::set_rotate(const float val) {
rotate = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(float) ;
float repeat = 1;
//export(float) ;
float rotate = 0;
void Gradient::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void Gradient::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_float("get_repeat", "set_repeat", "repeat");
mm_graph_node.add_slot_float("get_rotate", "set_rotate", "rotate");
mm_graph_node.add_slot_gradient();
}
void Gradient::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color Gradient::_get_value_for(const Vector2 &uv, const int pseed) {
if (interpolation_type == 0) {
return MMAlgos.normal_gradient_type_1(uv, repeat, rotate, points);
}
else if (interpolation_type == 1) {
return MMAlgos.normal_gradient_type_2(uv, repeat, rotate, points);
}
else if (interpolation_type == 2) {
return MMAlgos.normal_gradient_type_3(uv, repeat, rotate, points);
}
else if (interpolation_type == 3) {
return MMAlgos.normal_gradient_type_4(uv, repeat, rotate, points);
}
return Color(1, 1, 1, 1);
}
Color Gradient::_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);
}
float Gradient::get_repeat() {
return repeat;
}
void Gradient::set_repeat(const float val) {
repeat = val;
set_dirty(true);
}
float Gradient::get_rotate() {
return rotate;
}
void Gradient::set_rotate(const float val) {
rotate = val;
set_dirty(true);
}
}
Gradient::Gradient() {
image;
repeat = 1;
rotate = 0;
}
Gradient::~Gradient() {
}
static void Gradient::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Gradient::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Gradient::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_repeat"), &Gradient::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "value"), &Gradient::set_repeat);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "repeat"), "set_repeat", "get_repeat");
ClassDB::bind_method(D_METHOD("get_rotate"), &Gradient::get_rotate);
ClassDB::bind_method(D_METHOD("set_rotate", "value"), &Gradient::set_rotate);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotate"), "set_rotate", "get_rotate");
ClassDB::bind_method(D_METHOD("_init_properties"), &Gradient::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Gradient::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Gradient::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Gradient::_get_value_for);
ClassDB::bind_method(D_METHOD("_get_gradient_color", "x"), &Gradient::_get_gradient_color);
ClassDB::bind_method(D_METHOD("get_repeat"), &Gradient::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "val"), &Gradient::set_repeat);
ClassDB::bind_method(D_METHOD("get_rotate"), &Gradient::get_rotate);
ClassDB::bind_method(D_METHOD("set_rotate", "val"), &Gradient::set_rotate);
}

View File

@ -0,0 +1,45 @@
#ifndef GRADIENT_H
#define GRADIENT_H
class Gradient : public GradientBase {
GDCLASS(Gradient, GradientBase);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
float get_repeat() const;
void set_repeat(const float val);
float get_rotate() const;
void set_rotate(const float val);
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);
float get_repeat();
void set_repeat(const float val);
float get_rotate();
void set_rotate(const float val);
Gradient();
~Gradient();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(float)
float repeat = 1;
//export(float)
float rotate = 0;
};
#endif

View File

@ -0,0 +1,148 @@
#include "radial_gradient.h"
Ref<Resource> RadialGradient::get_image() {
return image;
}
void RadialGradient::set_image(const Ref<Resource> &val) {
image = val;
}
float RadialGradient::get_repeat() const {
return repeat;
}
void RadialGradient::set_repeat(const float val) {
repeat = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(float) ;
float repeat = 1;
void RadialGradient::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void RadialGradient::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_float("get_repeat", "set_repeat", "repeat");
mm_graph_node.add_slot_gradient();
}
void RadialGradient::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color RadialGradient::_get_value_for(const Vector2 &uv, const int pseed) {
if (interpolation_type == 0) {
return MMAlgos.radial_gradient_type_1(uv, repeat, points);
}
else if (interpolation_type == 1) {
return MMAlgos.radial_gradient_type_2(uv, repeat, points);
}
else if (interpolation_type == 2) {
return MMAlgos.radial_gradient_type_3(uv, repeat, points);
}
else if (interpolation_type == 3) {
return MMAlgos.radial_gradient_type_4(uv, repeat, points);
}
return Color(1, 1, 1, 1);
}
Color RadialGradient::_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);
}
float RadialGradient::get_repeat() {
return repeat;
}
void RadialGradient::set_repeat(const float val) {
repeat = val;
set_dirty(true);
}
}
RadialGradient::RadialGradient() {
image;
repeat = 1;
}
RadialGradient::~RadialGradient() {
}
static void RadialGradient::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &RadialGradient::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &RadialGradient::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_repeat"), &RadialGradient::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "value"), &RadialGradient::set_repeat);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "repeat"), "set_repeat", "get_repeat");
ClassDB::bind_method(D_METHOD("_init_properties"), &RadialGradient::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &RadialGradient::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &RadialGradient::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &RadialGradient::_get_value_for);
ClassDB::bind_method(D_METHOD("_get_gradient_color", "x"), &RadialGradient::_get_gradient_color);
ClassDB::bind_method(D_METHOD("get_repeat"), &RadialGradient::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "val"), &RadialGradient::set_repeat);
}

View File

@ -0,0 +1,38 @@
#ifndef RADIAL_GRADIENT_H
#define RADIAL_GRADIENT_H
class RadialGradient : public GradientBase {
GDCLASS(RadialGradient, GradientBase);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
float get_repeat() const;
void set_repeat(const float val);
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);
float get_repeat();
void set_repeat(const float val);
RadialGradient();
~RadialGradient();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(float)
float repeat = 1;
};
#endif

View File

@ -0,0 +1,168 @@
#include "anisotropic_noise.h"
Ref<Resource> AnisotropicNoise::get_image() {
return image;
}
void AnisotropicNoise::set_image(const Ref<Resource> &val) {
image = val;
}
Vector2 AnisotropicNoise::get_scale() {
return scale;
}
void AnisotropicNoise::set_scale(const Vector2 &val) {
scale = val;
}
float AnisotropicNoise::get_smoothness() const {
return smoothness;
}
void AnisotropicNoise::set_smoothness(const float val) {
smoothness = val;
}
float AnisotropicNoise::get_interpolation() const {
return interpolation;
}
void AnisotropicNoise::set_interpolation(const float val) {
interpolation = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Vector2) ;
Vector2 scale = Vector2(4, 256);
//export(float) ;
float smoothness = 1;
//export(float) ;
float interpolation = 1;
void AnisotropicNoise::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void AnisotropicNoise::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
//, Vector2(1, 10));
mm_graph_node.add_slot_vector2("get_scale", "set_scale", "Scale", 1);
//, Vector2(0, 1));
mm_graph_node.add_slot_float("get_smoothness", "set_smoothness", "Smoothness", 0.01);
//, Vector2(0, 1));
mm_graph_node.add_slot_float("get_interpolation", "set_interpolation", "Interpolation", 0.01);
}
Color AnisotropicNoise::_get_value_for(const Vector2 &uv, const int pseed) {
float ps = 1.0 / float(pseed);
//anisotropic($(uv), vec2($(scale_x), $(scale_y)), $(seed), $(smoothness), $(interpolation));
return MMAlgos.anisotropicc(uv, scale, ps, smoothness, interpolation);
}
void AnisotropicNoise::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Vector2 AnisotropicNoise::get_scale() {
return scale;
}
void AnisotropicNoise::set_scale(const Vector2 &val) {
scale = val;
set_dirty(true);
}
float AnisotropicNoise::get_smoothness() {
return smoothness;
}
void AnisotropicNoise::set_smoothness(const float val) {
smoothness = val;
set_dirty(true);
}
float AnisotropicNoise::get_interpolation() {
return interpolation;
}
void AnisotropicNoise::set_interpolation(const float val) {
interpolation = val;
set_dirty(true);
}
}
AnisotropicNoise::AnisotropicNoise() {
image;
scale = Vector2(4, 256);
smoothness = 1;
interpolation = 1;
}
AnisotropicNoise::~AnisotropicNoise() {
}
static void AnisotropicNoise::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &AnisotropicNoise::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &AnisotropicNoise::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_scale"), &AnisotropicNoise::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "value"), &AnisotropicNoise::set_scale);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale");
ClassDB::bind_method(D_METHOD("get_smoothness"), &AnisotropicNoise::get_smoothness);
ClassDB::bind_method(D_METHOD("set_smoothness", "value"), &AnisotropicNoise::set_smoothness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "smoothness"), "set_smoothness", "get_smoothness");
ClassDB::bind_method(D_METHOD("get_interpolation"), &AnisotropicNoise::get_interpolation);
ClassDB::bind_method(D_METHOD("set_interpolation", "value"), &AnisotropicNoise::set_interpolation);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "interpolation"), "set_interpolation", "get_interpolation");
ClassDB::bind_method(D_METHOD("_init_properties"), &AnisotropicNoise::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &AnisotropicNoise::_register_methods);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &AnisotropicNoise::_get_value_for);
ClassDB::bind_method(D_METHOD("_render", "material"), &AnisotropicNoise::_render);
ClassDB::bind_method(D_METHOD("get_scale"), &AnisotropicNoise::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "val"), &AnisotropicNoise::set_scale);
ClassDB::bind_method(D_METHOD("get_smoothness"), &AnisotropicNoise::get_smoothness);
ClassDB::bind_method(D_METHOD("set_smoothness", "val"), &AnisotropicNoise::set_smoothness);
ClassDB::bind_method(D_METHOD("get_interpolation"), &AnisotropicNoise::get_interpolation);
ClassDB::bind_method(D_METHOD("set_interpolation", "val"), &AnisotropicNoise::set_interpolation);
}

View File

@ -0,0 +1,51 @@
#ifndef ANISOTROPIC_NOISE_H
#define ANISOTROPIC_NOISE_H
class AnisotropicNoise : public MMNode {
GDCLASS(AnisotropicNoise, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Vector2 get_scale();
void set_scale(const Vector2 &val);
float get_smoothness() const;
void set_smoothness(const float val);
float get_interpolation() const;
void set_interpolation(const float val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _render(const Variant &material);
Vector2 get_scale();
void set_scale(const Vector2 &val);
float get_smoothness();
void set_smoothness(const float val);
float get_interpolation();
void set_interpolation(const float val);
AnisotropicNoise();
~AnisotropicNoise();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Vector2)
Vector2 scale = Vector2(4, 256);
//export(float)
float smoothness = 1;
//export(float)
float interpolation = 1;
};
#endif

View File

@ -0,0 +1,111 @@
#include "color_noise.h"
Ref<Resource> ColorNoise::get_image() {
return image;
}
void ColorNoise::set_image(const Ref<Resource> &val) {
image = val;
}
int ColorNoise::get_size() const {
return size;
}
void ColorNoise::set_size(const int val) {
size = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(int) ;
int size = 8;
//----------------------;
//color_noise.mmg;
//Outputs:;
//Output - (rgb) - Shows the noise pattern;
//color_dots($(uv), 1.0/$(size), $(seed));
//Inputs:;
//size, float, default: 8, min: 2, max: 12, step: 1;
void ColorNoise::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void ColorNoise::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
//, Vector2(1, 10));
mm_graph_node.add_slot_int("get_size", "set_size", "Size");
}
Color ColorNoise::_get_value_for(const Vector2 &uv, const int pseed) {
float ps = 1.0 / float(pseed);
//color_dots($(uv), 1.0/$(size), $(seed));
return MMAlgos.noise_color(uv, float(size), ps);
}
void ColorNoise::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
int ColorNoise::get_size() {
return size;
}
void ColorNoise::set_size(const int val) {
size = val;
set_dirty(true);
}
}
ColorNoise::ColorNoise() {
image;
size = 8;
}
ColorNoise::~ColorNoise() {
}
static void ColorNoise::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &ColorNoise::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &ColorNoise::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_size"), &ColorNoise::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &ColorNoise::set_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &ColorNoise::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &ColorNoise::_register_methods);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &ColorNoise::_get_value_for);
ClassDB::bind_method(D_METHOD("_render", "material"), &ColorNoise::_render);
ClassDB::bind_method(D_METHOD("get_size"), &ColorNoise::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &ColorNoise::set_size);
}

View File

@ -0,0 +1,44 @@
#ifndef COLOR_NOISE_H
#define COLOR_NOISE_H
class ColorNoise : public MMNode {
GDCLASS(ColorNoise, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
int get_size() const;
void set_size(const int val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _render(const Variant &material);
int get_size();
void set_size(const int val);
ColorNoise();
~ColorNoise();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(int)
int size = 8;
//----------------------
//color_noise.mmg
//Outputs:
//Output - (rgb) - Shows the noise pattern
//color_dots($(uv), 1.0/$(size), $(seed))
//Inputs:
//size, float, default: 8, min: 2, max: 12, step: 1
};
#endif

View File

@ -0,0 +1,168 @@
#include "color_value.h"
Ref<Resource> ColorValue::get_image() {
return image;
}
void ColorValue::set_image(const Ref<Resource> &val) {
image = val;
}
Vector2 ColorValue::get_scale() {
return scale;
}
void ColorValue::set_scale(const Vector2 &val) {
scale = val;
}
int ColorValue::get_iterations() const {
return iterations;
}
void ColorValue::set_iterations(const int val) {
iterations = val;
}
float ColorValue::get_persistence() const {
return persistence;
}
void ColorValue::set_persistence(const float val) {
persistence = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Vector2) ;
Vector2 scale = Vector2(4, 4);
//export(int) ;
int iterations = 3;
//export(float) ;
float persistence = 0.5;
void ColorValue::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void ColorValue::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
//, Vector2(1, 10));
mm_graph_node.add_slot_vector2("get_scale", "set_scale", "Scale");
//, Vector2(0, 1));
mm_graph_node.add_slot_int("get_iterations", "set_iterations", "Iterations");
//, Vector2(0, 1));
mm_graph_node.add_slot_float("get_persistence", "set_persistence", "Persistence", 0.01);
}
Color ColorValue::_get_value_for(const Vector2 &uv, const int pseed) {
float ps = 1.0 / float(pseed);
//perlin_color($(uv), vec2($(scale_x), $(scale_y)), int($(iterations)), $(persistence), $(seed));
return MMAlgos.perlin_colorc(uv, scale, iterations, persistence, ps);
}
void ColorValue::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Vector2 ColorValue::get_scale() {
return scale;
}
void ColorValue::set_scale(const Vector2 &val) {
scale = val;
set_dirty(true);
}
int ColorValue::get_iterations() {
return iterations;
}
void ColorValue::set_iterations(const int val) {
iterations = val;
set_dirty(true);
}
float ColorValue::get_persistence() {
return persistence;
}
void ColorValue::set_persistence(const float val) {
persistence = val;
set_dirty(true);
}
}
ColorValue::ColorValue() {
image;
scale = Vector2(4, 4);
iterations = 3;
persistence = 0.5;
}
ColorValue::~ColorValue() {
}
static void ColorValue::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &ColorValue::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &ColorValue::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_scale"), &ColorValue::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "value"), &ColorValue::set_scale);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale");
ClassDB::bind_method(D_METHOD("get_iterations"), &ColorValue::get_iterations);
ClassDB::bind_method(D_METHOD("set_iterations", "value"), &ColorValue::set_iterations);
ADD_PROPERTY(PropertyInfo(Variant::INT, "iterations"), "set_iterations", "get_iterations");
ClassDB::bind_method(D_METHOD("get_persistence"), &ColorValue::get_persistence);
ClassDB::bind_method(D_METHOD("set_persistence", "value"), &ColorValue::set_persistence);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "persistence"), "set_persistence", "get_persistence");
ClassDB::bind_method(D_METHOD("_init_properties"), &ColorValue::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &ColorValue::_register_methods);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &ColorValue::_get_value_for);
ClassDB::bind_method(D_METHOD("_render", "material"), &ColorValue::_render);
ClassDB::bind_method(D_METHOD("get_scale"), &ColorValue::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "val"), &ColorValue::set_scale);
ClassDB::bind_method(D_METHOD("get_iterations"), &ColorValue::get_iterations);
ClassDB::bind_method(D_METHOD("set_iterations", "val"), &ColorValue::set_iterations);
ClassDB::bind_method(D_METHOD("get_persistence"), &ColorValue::get_persistence);
ClassDB::bind_method(D_METHOD("set_persistence", "val"), &ColorValue::set_persistence);
}

View File

@ -0,0 +1,51 @@
#ifndef COLOR_VALUE_H
#define COLOR_VALUE_H
class ColorValue : public MMNode {
GDCLASS(ColorValue, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Vector2 get_scale();
void set_scale(const Vector2 &val);
int get_iterations() const;
void set_iterations(const int val);
float get_persistence() const;
void set_persistence(const float val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _render(const Variant &material);
Vector2 get_scale();
void set_scale(const Vector2 &val);
int get_iterations();
void set_iterations(const int val);
float get_persistence();
void set_persistence(const float val);
ColorValue();
~ColorValue();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Vector2)
Vector2 scale = Vector2(4, 4);
//export(int)
int iterations = 3;
//export(float)
float persistence = 0.5;
};
#endif

View File

@ -0,0 +1,277 @@
#include "fbm_noise.h"
Ref<Resource> FbmNoise::get_image() {
return image;
}
void FbmNoise::set_image(const Ref<Resource> &val) {
image = val;
}
int FbmNoise::get_type() const {
return type;
}
void FbmNoise::set_type(const int val) {
type = val;
}
Vector2 FbmNoise::get_scale() {
return scale;
}
void FbmNoise::set_scale(const Vector2 &val) {
scale = val;
}
int FbmNoise::get_folds() const {
return folds;
}
void FbmNoise::set_folds(const int val) {
folds = val;
}
int FbmNoise::get_iterations() const {
return iterations;
}
void FbmNoise::set_iterations(const int val) {
iterations = val;
}
float FbmNoise::get_persistence() const {
return persistence;
}
void FbmNoise::set_persistence(const float val) {
persistence = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(int, "Value,Perlin,Simplex,Cellular1,Cellular2,Cellular3,Cellular4,Cellular5,Cellular6") ;
int type = 0;
//export(Vector2) ;
Vector2 scale = Vector2(2, 2);
//export(int) ;
int folds = 0;
//export(int) ;
int iterations = 5;
//export(float) ;
float persistence = 0.5;
void FbmNoise::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void FbmNoise::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
//, Vector2(0, 1));
mm_graph_node.add_slot_enum("get_type", "set_type", "Type", [ "Value", "Perlin", "Simplex", "Cellular1", "Cellular2", "Cellular3", "Cellular4", "Cellular5", "Cellular6" ]);
//, Vector2(1, 10));
mm_graph_node.add_slot_vector2("get_scale", "set_scale", "Scale");
//, Vector2(0, 1));
mm_graph_node.add_slot_int("get_folds", "set_folds", "folds");
//, Vector2(0, 1));
mm_graph_node.add_slot_int("get_iterations", "set_iterations", "Iterations");
//, Vector2(0, 1));
mm_graph_node.add_slot_float("get_persistence", "set_persistence", "Persistence", 0.01);
}
Color FbmNoise::_get_value_for(const Vector2 &uv, const int pseed) {
float ps = 1.0 / float(pseed);
//"Value,Perlin,Simplex,Cellular1,Cellular2,Cellular3,Cellular4,Cellular5,Cellular6";
if (type == 0) {
return MMAlgos.fbmval(uv, scale, folds, iterations, persistence, ps);
}
else if (type == 1) {
return MMAlgos.perlin(uv, scale, folds, iterations, persistence, ps);
}
else if (type == 2) {
return MMAlgos.simplex(uv, scale, folds, iterations, persistence, ps);
}
else if (type == 3) {
return MMAlgos.cellular(uv, scale, folds, iterations, persistence, ps);
}
else if (type == 4) {
return MMAlgos.cellular2(uv, scale, folds, iterations, persistence, ps);
}
else if (type == 5) {
return MMAlgos.cellular3(uv, scale, folds, iterations, persistence, ps);
}
else if (type == 6) {
return MMAlgos.cellular4(uv, scale, folds, iterations, persistence, ps);
}
else if (type == 7) {
return MMAlgos.cellular5(uv, scale, folds, iterations, persistence, ps);
}
else if (type == 8) {
return MMAlgos.cellular6(uv, scale, folds, iterations, persistence, ps);
}
return Color();
}
void FbmNoise::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
int FbmNoise::get_type() {
return type;
}
void FbmNoise::set_type(const int val) {
type = val;
set_dirty(true);
}
Vector2 FbmNoise::get_scale() {
return scale;
}
void FbmNoise::set_scale(const Vector2 &val) {
scale = val;
set_dirty(true);
}
int FbmNoise::get_folds() {
return folds;
}
void FbmNoise::set_folds(const int val) {
folds = val;
set_dirty(true);
}
int FbmNoise::get_iterations() {
return iterations;
}
void FbmNoise::set_iterations(const int val) {
iterations = val;
set_dirty(true);
}
float FbmNoise::get_persistence() {
return persistence;
}
void FbmNoise::set_persistence(const float val) {
persistence = val;
set_dirty(true);
}
}
FbmNoise::FbmNoise() {
image;
type = 0;
scale = Vector2(2, 2);
folds = 0;
iterations = 5;
persistence = 0.5;
}
FbmNoise::~FbmNoise() {
}
static void FbmNoise::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &FbmNoise::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &FbmNoise::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_type"), &FbmNoise::get_type);
ClassDB::bind_method(D_METHOD("set_type", "value"), &FbmNoise::set_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "type"), "set_type", "get_type");
ClassDB::bind_method(D_METHOD("get_scale"), &FbmNoise::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "value"), &FbmNoise::set_scale);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale");
ClassDB::bind_method(D_METHOD("get_folds"), &FbmNoise::get_folds);
ClassDB::bind_method(D_METHOD("set_folds", "value"), &FbmNoise::set_folds);
ADD_PROPERTY(PropertyInfo(Variant::INT, "folds"), "set_folds", "get_folds");
ClassDB::bind_method(D_METHOD("get_iterations"), &FbmNoise::get_iterations);
ClassDB::bind_method(D_METHOD("set_iterations", "value"), &FbmNoise::set_iterations);
ADD_PROPERTY(PropertyInfo(Variant::INT, "iterations"), "set_iterations", "get_iterations");
ClassDB::bind_method(D_METHOD("get_persistence"), &FbmNoise::get_persistence);
ClassDB::bind_method(D_METHOD("set_persistence", "value"), &FbmNoise::set_persistence);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "persistence"), "set_persistence", "get_persistence");
ClassDB::bind_method(D_METHOD("_init_properties"), &FbmNoise::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &FbmNoise::_register_methods);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &FbmNoise::_get_value_for);
ClassDB::bind_method(D_METHOD("_render", "material"), &FbmNoise::_render);
ClassDB::bind_method(D_METHOD("get_type"), &FbmNoise::get_type);
ClassDB::bind_method(D_METHOD("set_type", "val"), &FbmNoise::set_type);
ClassDB::bind_method(D_METHOD("get_scale"), &FbmNoise::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "val"), &FbmNoise::set_scale);
ClassDB::bind_method(D_METHOD("get_folds"), &FbmNoise::get_folds);
ClassDB::bind_method(D_METHOD("set_folds", "val"), &FbmNoise::set_folds);
ClassDB::bind_method(D_METHOD("get_iterations"), &FbmNoise::get_iterations);
ClassDB::bind_method(D_METHOD("set_iterations", "val"), &FbmNoise::set_iterations);
ClassDB::bind_method(D_METHOD("get_persistence"), &FbmNoise::get_persistence);
ClassDB::bind_method(D_METHOD("set_persistence", "val"), &FbmNoise::set_persistence);
}

View File

@ -0,0 +1,65 @@
#ifndef FBM_NOISE_H
#define FBM_NOISE_H
class FbmNoise : public MMNode {
GDCLASS(FbmNoise, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
int get_type() const;
void set_type(const int val);
Vector2 get_scale();
void set_scale(const Vector2 &val);
int get_folds() const;
void set_folds(const int val);
int get_iterations() const;
void set_iterations(const int val);
float get_persistence() const;
void set_persistence(const float val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _render(const Variant &material);
int get_type();
void set_type(const int val);
Vector2 get_scale();
void set_scale(const Vector2 &val);
int get_folds();
void set_folds(const int val);
int get_iterations();
void set_iterations(const int val);
float get_persistence();
void set_persistence(const float val);
FbmNoise();
~FbmNoise();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(int, "Value,Perlin,Simplex,Cellular1,Cellular2,Cellular3,Cellular4,Cellular5,Cellular6")
int type = 0;
//export(Vector2)
Vector2 scale = Vector2(2, 2);
//export(int)
int folds = 0;
//export(int)
int iterations = 5;
//export(float)
float persistence = 0.5;
};
#endif

View File

@ -0,0 +1,137 @@
#include "noise.h"
Ref<Resource> Noise::get_image() {
return image;
}
void Noise::set_image(const Ref<Resource> &val) {
image = val;
}
int Noise::get_grid_size() const {
return grid_size;
}
void Noise::set_grid_size(const int val) {
grid_size = val;
}
float Noise::get_density() const {
return density;
}
void Noise::set_density(const float val) {
density = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(int) ;
int grid_size = 16;
//export(float) ;
float density = 0.5;
void Noise::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void Noise::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
//, Vector2(1, 10));
mm_graph_node.add_slot_int("get_grid_size", "set_grid_size", "Grid Size");
//, Vector2(0, 1));
mm_graph_node.add_slot_float("get_density", "set_density", "Density", 0.01);
}
Color Noise::_get_value_for(const Vector2 &uv, const int pseed) {
float ps = 1.0 / float(pseed);
//return dots(uv, 1.0/$(size), $(density), $(seed));
float f = MMAlgos.dots(uv, 1.0 / float(grid_size), density, ps);
return Color(f, f, f, 1);
}
void Noise::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
int Noise::get_grid_size() {
return grid_size;
}
void Noise::set_grid_size(const int val) {
grid_size = val;
set_dirty(true);
}
float Noise::get_density() {
return density;
}
void Noise::set_density(const float val) {
density = val;
set_dirty(true);
}
}
Noise::Noise() {
image;
grid_size = 16;
density = 0.5;
}
Noise::~Noise() {
}
static void Noise::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Noise::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Noise::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_grid_size"), &Noise::get_grid_size);
ClassDB::bind_method(D_METHOD("set_grid_size", "value"), &Noise::set_grid_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "grid_size"), "set_grid_size", "get_grid_size");
ClassDB::bind_method(D_METHOD("get_density"), &Noise::get_density);
ClassDB::bind_method(D_METHOD("set_density", "value"), &Noise::set_density);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "density"), "set_density", "get_density");
ClassDB::bind_method(D_METHOD("_init_properties"), &Noise::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Noise::_register_methods);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Noise::_get_value_for);
ClassDB::bind_method(D_METHOD("_render", "material"), &Noise::_render);
ClassDB::bind_method(D_METHOD("get_grid_size"), &Noise::get_grid_size);
ClassDB::bind_method(D_METHOD("set_grid_size", "val"), &Noise::set_grid_size);
ClassDB::bind_method(D_METHOD("get_density"), &Noise::get_density);
ClassDB::bind_method(D_METHOD("set_density", "val"), &Noise::set_density);
}

View File

@ -0,0 +1,44 @@
#ifndef NOISE_H
#define NOISE_H
class Noise : public MMNode {
GDCLASS(Noise, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
int get_grid_size() const;
void set_grid_size(const int val);
float get_density() const;
void set_density(const float val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _render(const Variant &material);
int get_grid_size();
void set_grid_size(const int val);
float get_density();
void set_density(const float val);
Noise();
~Noise();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(int)
int grid_size = 16;
//export(float)
float density = 0.5;
};
#endif

View File

@ -0,0 +1,332 @@
#include "voronoi.h"
Ref<Resource> Voronoi::get_out_nodes() {
return out_nodes;
}
void Voronoi::set_out_nodes(const Ref<Resource> &val) {
out_nodes = val;
}
Ref<Resource> Voronoi::get_out_borders() {
return out_borders;
}
void Voronoi::set_out_borders(const Ref<Resource> &val) {
out_borders = val;
}
Ref<Resource> Voronoi::get_out_random_color() {
return out_random_color;
}
void Voronoi::set_out_random_color(const Ref<Resource> &val) {
out_random_color = val;
}
Ref<Resource> Voronoi::get_out_fill() {
return out_fill;
}
void Voronoi::set_out_fill(const Ref<Resource> &val) {
out_fill = val;
}
Vector2 Voronoi::get_scale() {
return scale;
}
void Voronoi::set_scale(const Vector2 &val) {
scale = val;
}
Vector2 Voronoi::get_stretch() {
return stretch;
}
void Voronoi::set_stretch(const Vector2 &val) {
stretch = val;
}
float Voronoi::get_intensity() const {
return intensity;
}
void Voronoi::set_intensity(const float val) {
intensity = val;
}
float Voronoi::get_randomness() const {
return randomness;
}
void Voronoi::set_randomness(const float val) {
randomness = val;
}
//tool;
//export(Resource) ;
Ref<Resource> out_nodes;
//export(Resource) ;
Ref<Resource> out_borders;
//export(Resource) ;
Ref<Resource> out_random_color;
//export(Resource) ;
Ref<Resource> out_fill;
//export(Vector2) ;
Vector2 scale = Vector2(4, 4);
//export(Vector2) ;
Vector2 stretch = Vector2(1, 1);
//export(float) ;
float intensity = 1;
//export(float) ;
float randomness = 0.85;
void Voronoi::_init_properties() {
if (!out_nodes) {
out_nodes = MMNodeUniversalProperty.new();
out_nodes.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_nodes.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_borders) {
out_borders = MMNodeUniversalProperty.new();
out_borders.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_borders.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_random_color) {
out_random_color = MMNodeUniversalProperty.new();
out_random_color.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_random_color.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_fill) {
out_fill = MMNodeUniversalProperty.new();
out_fill.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_fill.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(out_nodes);
register_output_property(out_borders);
register_output_property(out_random_color);
register_output_property(out_fill);
}
void Voronoi::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(out_nodes);
mm_graph_node.add_slot_texture_universal(out_borders);
mm_graph_node.add_slot_texture_universal(out_random_color);
mm_graph_node.add_slot_texture_universal(out_fill);
//, Vector2(1, 32))//, Vector2(0, 32));
mm_graph_node.add_slot_vector2("get_scale", "set_scale", "Scale", 0.1);
//, Vector2(1, 32))//, Vector2(0, 32));
mm_graph_node.add_slot_vector2("get_stretch", "set_stretch", "stretch", 0.01);
//, Vector2(1, 32))//, Vector2(0, 32));
mm_graph_node.add_slot_float("get_intensity", "set_intensity", "Intensity", 0.01);
//, Vector2(1, 32))//, Vector2(0, 32));
mm_graph_node.add_slot_float("get_randomness", "set_randomness", "Randomness", 0.01);
}
void Voronoi::_render(const Variant &material) {
Ref<Image> nodes = Image.new();
Ref<Image> borders = Image.new();
Ref<Image> random_color = Image.new();
Ref<Image> fill = Image.new();
nodes.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
borders.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
random_color.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
fill.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
nodes.lock();
borders.lock();
random_color.lock();
fill.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);
float ps = 1.0 / float(pseed);
//vec4 $(name_uv)_xyzw = voronoi($uv, vec2($scale_x, $scale_y), vec2($stretch_y, $stretch_x), $intensity, $randomness, $seed);
Color voronoi = MMAlgos.voronoi(uv, scale, stretch, intensity, randomness, ps);
//Nodes - float - A greyscale pattern based on the distance to cell centers;
//$(name_uv)_xyzw.z;
Color nodes_col = Color(voronoi.b, voronoi.b, voronoi.b, 1);
//Borders - float - A greyscale pattern based on the distance to borders;
//$(name_uv)_xyzw.w;
Color borders_col = Color(voronoi.a, voronoi.a, voronoi.a, 1);
//Random color - rgb - A color pattern that assigns a random color to each cell;
//rand3(fract(floor($(name_uv)_xyzw.xy)/vec2($scale_x, $scale_y)));
Vector3 rv3 = MMAlgos.rand3(MMAlgos.fractv2(Vector2(voronoi.r, voronoi.g) / scale));
Color random_color_col = Color(rv3.x, rv3.y, rv3.z, 1);
//Fill - rgba - An output that should be plugged into a Fill companion node;
//vec4(fract(($(name_uv)_xyzw.xy-1.0)/vec2($scale_x, $scale_y)), vec2(2.0)/vec2($scale_x, $scale_y));
Vector2 fv21 = MMAlgos.fractv2((Vector2(voronoi.r, voronoi.g) - Vector2(1, 1)) / scale);
Vector2 fv22 = Vector2(2, 2) / scale;
Color fill_col = Color(fv21.x, fv21.y, fv22.x, fv22.y);
nodes.set_pixel(x, y, nodes_col);
borders.set_pixel(x, y, borders_col);
random_color.set_pixel(x, y, random_color_col);
fill.set_pixel(x, y, fill_col);
}
}
nodes.unlock();
borders.unlock();
random_color.unlock();
fill.unlock();
out_nodes.set_value(nodes);
out_borders.set_value(borders);
out_random_color.set_value(random_color);
out_fill.set_value(fill);
}
Color Voronoi::_get_value_for(const Vector2 &uv, const int pseed) {
return Color();
}
//scale;
Vector2 Voronoi::get_scale() {
return scale;
}
void Voronoi::set_scale(const Vector2 &val) {
scale = val;
set_dirty(true);
}
//stretch;
Vector2 Voronoi::get_stretch() {
return stretch;
}
void Voronoi::set_stretch(const Vector2 &val) {
stretch = val;
set_dirty(true);
}
//intensity;
float Voronoi::get_intensity() {
return intensity;
}
void Voronoi::set_intensity(const float val) {
intensity = val;
set_dirty(true);
}
//randomness;
float Voronoi::get_randomness() {
return randomness;
}
void Voronoi::set_randomness(const float val) {
randomness = val;
set_dirty(true);
}
}
Voronoi::Voronoi() {
out_nodes;
out_borders;
out_random_color;
out_fill;
scale = Vector2(4, 4);
stretch = Vector2(1, 1);
intensity = 1;
randomness = 0.85;
}
Voronoi::~Voronoi() {
}
static void Voronoi::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_out_nodes"), &Voronoi::get_out_nodes);
ClassDB::bind_method(D_METHOD("set_out_nodes", "value"), &Voronoi::set_out_nodes);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_nodes", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_nodes", "get_out_nodes");
ClassDB::bind_method(D_METHOD("get_out_borders"), &Voronoi::get_out_borders);
ClassDB::bind_method(D_METHOD("set_out_borders", "value"), &Voronoi::set_out_borders);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_borders", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_borders", "get_out_borders");
ClassDB::bind_method(D_METHOD("get_out_random_color"), &Voronoi::get_out_random_color);
ClassDB::bind_method(D_METHOD("set_out_random_color", "value"), &Voronoi::set_out_random_color);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_random_color", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_random_color", "get_out_random_color");
ClassDB::bind_method(D_METHOD("get_out_fill"), &Voronoi::get_out_fill);
ClassDB::bind_method(D_METHOD("set_out_fill", "value"), &Voronoi::set_out_fill);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_fill", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_fill", "get_out_fill");
ClassDB::bind_method(D_METHOD("get_scale"), &Voronoi::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "value"), &Voronoi::set_scale);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale");
ClassDB::bind_method(D_METHOD("get_stretch"), &Voronoi::get_stretch);
ClassDB::bind_method(D_METHOD("set_stretch", "value"), &Voronoi::set_stretch);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "stretch"), "set_stretch", "get_stretch");
ClassDB::bind_method(D_METHOD("get_intensity"), &Voronoi::get_intensity);
ClassDB::bind_method(D_METHOD("set_intensity", "value"), &Voronoi::set_intensity);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "intensity"), "set_intensity", "get_intensity");
ClassDB::bind_method(D_METHOD("get_randomness"), &Voronoi::get_randomness);
ClassDB::bind_method(D_METHOD("set_randomness", "value"), &Voronoi::set_randomness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "randomness"), "set_randomness", "get_randomness");
ClassDB::bind_method(D_METHOD("_init_properties"), &Voronoi::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Voronoi::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Voronoi::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Voronoi::_get_value_for);
ClassDB::bind_method(D_METHOD("get_scale"), &Voronoi::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "val"), &Voronoi::set_scale);
ClassDB::bind_method(D_METHOD("get_stretch"), &Voronoi::get_stretch);
ClassDB::bind_method(D_METHOD("set_stretch", "val"), &Voronoi::set_stretch);
ClassDB::bind_method(D_METHOD("get_intensity"), &Voronoi::get_intensity);
ClassDB::bind_method(D_METHOD("set_intensity", "val"), &Voronoi::set_intensity);
ClassDB::bind_method(D_METHOD("get_randomness"), &Voronoi::get_randomness);
ClassDB::bind_method(D_METHOD("set_randomness", "val"), &Voronoi::set_randomness);
}

View File

@ -0,0 +1,77 @@
#ifndef VORONOI_H
#define VORONOI_H
class Voronoi : public MMNode {
GDCLASS(Voronoi, MMNode);
public:
Ref<Resource> get_out_nodes();
void set_out_nodes(const Ref<Resource> &val);
Ref<Resource> get_out_borders();
void set_out_borders(const Ref<Resource> &val);
Ref<Resource> get_out_random_color();
void set_out_random_color(const Ref<Resource> &val);
Ref<Resource> get_out_fill();
void set_out_fill(const Ref<Resource> &val);
Vector2 get_scale();
void set_scale(const Vector2 &val);
Vector2 get_stretch();
void set_stretch(const Vector2 &val);
float get_intensity() const;
void set_intensity(const float val);
float get_randomness() const;
void set_randomness(const float val);
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);
Vector2 get_scale();
void set_scale(const Vector2 &val);
Vector2 get_stretch();
void set_stretch(const Vector2 &val);
float get_intensity();
void set_intensity(const float val);
float get_randomness();
void set_randomness(const float val);
Voronoi();
~Voronoi();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> out_nodes;
//export(Resource)
Ref<Resource> out_borders;
//export(Resource)
Ref<Resource> out_random_color;
//export(Resource)
Ref<Resource> out_fill;
//export(Vector2)
Vector2 scale = Vector2(4, 4);
//export(Vector2)
Vector2 stretch = Vector2(1, 1);
//export(float)
float intensity = 1;
//export(float)
float randomness = 0.85;
//scale
//stretch
//intensity
//randomness
};
#endif

View File

@ -0,0 +1,110 @@
#include "output_image.h"
Ref<Resource> OutputImage::get_image() {
return image;
}
void OutputImage::set_image(const Ref<Resource> &val) {
image = val;
}
String OutputImage::get_postfix() {
return postfix;
}
void OutputImage::set_postfix(const String &val) {
postfix = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(String) ;
String postfix = "";
void OutputImage::_init_properties() {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
image.slot_name = "image";
register_input_property(image);
}
void OutputImage::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_line_edit("get_postfix", "set_postfix", "postfix");
}
void OutputImage::_render(const Variant &material) {
if (!image) {
return;
}
Ref<Image> img = image.get_active_image();
if (!img) {
return;
}
String matpath = material.get_path();
if (matpath == "") {
return;
}
String matbn = matpath.get_basename();
String final_file_name = matbn + postfix + ".png";
img.save_png(final_file_name);
}
String OutputImage::get_postfix() {
return postfix;
}
void OutputImage::set_postfix(const String &pf) {
postfix = pf;
set_dirty(true);
}
}
OutputImage::OutputImage() {
image;
postfix = "";
}
OutputImage::~OutputImage() {
}
static void OutputImage::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &OutputImage::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &OutputImage::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_postfix"), &OutputImage::get_postfix);
ClassDB::bind_method(D_METHOD("set_postfix", "value"), &OutputImage::set_postfix);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "postfix"), "set_postfix", "get_postfix");
ClassDB::bind_method(D_METHOD("_init_properties"), &OutputImage::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &OutputImage::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &OutputImage::_render);
ClassDB::bind_method(D_METHOD("get_postfix"), &OutputImage::get_postfix);
ClassDB::bind_method(D_METHOD("set_postfix", "pf"), &OutputImage::set_postfix);
}

View File

@ -0,0 +1,36 @@
#ifndef OUTPUT_IMAGE_H
#define OUTPUT_IMAGE_H
class OutputImage : public MMNode {
GDCLASS(OutputImage, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
String get_postfix();
void set_postfix(const String &val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
String get_postfix();
void set_postfix(const String &pf);
OutputImage();
~OutputImage();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(String)
String postfix = "";
};
#endif

View File

@ -0,0 +1,201 @@
#include "beehive.h"
Ref<Resource> Beehive::get_out_main() {
return out_main;
}
void Beehive::set_out_main(const Ref<Resource> &val) {
out_main = val;
}
Ref<Resource> Beehive::get_out_random_color() {
return out_random_color;
}
void Beehive::set_out_random_color(const Ref<Resource> &val) {
out_random_color = val;
}
Ref<Resource> Beehive::get_out_uv_map() {
return out_uv_map;
}
void Beehive::set_out_uv_map(const Ref<Resource> &val) {
out_uv_map = val;
}
Vector2 Beehive::get_size() {
return size;
}
void Beehive::set_size(const Vector2 &val) {
size = val;
}
//tool;
//export(Resource) ;
Ref<Resource> out_main;
//export(Resource) ;
Ref<Resource> out_random_color;
//export(Resource) ;
Ref<Resource> out_uv_map;
//export(Vector2) ;
Vector2 size = Vector2(4, 4);
void Beehive::_init_properties() {
if (!out_main) {
out_main = MMNodeUniversalProperty.new();
out_main.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_main.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_random_color) {
out_random_color = MMNodeUniversalProperty.new();
out_random_color.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_random_color.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_uv_map) {
out_uv_map = MMNodeUniversalProperty.new();
out_uv_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_uv_map.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(out_main);
register_output_property(out_random_color);
register_output_property(out_uv_map);
}
void Beehive::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(out_main);
mm_graph_node.add_slot_texture_universal(out_random_color);
mm_graph_node.add_slot_texture_universal(out_uv_map);
//, Vector2(1, 32))//, Vector2(0, 32));
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size");
}
void Beehive::_render(const Variant &material) {
Ref<Image> main_pattern = Image.new();
Ref<Image> random_color = Image.new();
Ref<Image> uv_map = Image.new();
main_pattern.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
random_color.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
uv_map.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
main_pattern.lock();
random_color.lock();
uv_map.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);
float ps = 1.0 / float(pseed);
//vec2 $(name_uv)_uv = $uv*vec2($sx, $sy*1.73205080757);
//vec4 $(name_uv)_center = beehive_center($(name_uv)_uv);
Vector2 beehive_uv = uv * size;
Color beehive_uv_center = MMAlgos.beehive_center(beehive_uv);
//Output (float) - Shows the greyscale pattern;
//1.0-2.0*beehive_dist($(name_uv)_center.xy);
float f = 1.0 - 2.0 * MMAlgos.beehive_dist(Vector2(beehive_uv_center.r, beehive_uv_center.g));
Color main_pattern_col = Color(f, f, f, 1);
//Random color (rgb) - Shows a random color for each hexagonal tile;
//rand3(fract($(name_uv)_center.zw/vec2($sx, $sy))+vec2(float($seed)));
Vector3 rcv3 = MMAlgos.rand3(MMAlgos.fractv2(Vector2(beehive_uv_center.b, beehive_uv_center.a) / size) + Vector2(ps, ps));
Color random_color_col = Color(rcv3.x, rcv3.y, rcv3.z, 1);
//UV map (rgb) - Shows an UV map to be connected to the UV map port of the Custom UV node;
//vec3(vec2(0.5)+$(name_uv)_center.xy, rand(fract($(name_uv)_center.zw/vec2($sx, $sy))+vec2(float($seed))));
Vector2 uvm1 = Vector2(0.5, 0.5) + Vector2(beehive_uv_center.r, beehive_uv_center.g);
Vector2 uvm2 = MMAlgos.rand2(MMAlgos.fractv2(Vector2(beehive_uv_center.b, beehive_uv_center.a) / size) + Vector2(ps, ps));
Color uv_map_col = Color(uvm1.x, uvm1.y, uvm2.x, 1);
main_pattern.set_pixel(x, y, main_pattern_col);
random_color.set_pixel(x, y, random_color_col);
uv_map.set_pixel(x, y, uv_map_col);
}
}
main_pattern.unlock();
random_color.unlock();
uv_map.unlock();
out_main.set_value(main_pattern);
out_random_color.set_value(random_color);
out_uv_map.set_value(uv_map);
}
Color Beehive::_get_value_for(const Vector2 &uv, const int pseed) {
return Color();
}
//size;
Vector2 Beehive::get_size() {
return size;
}
void Beehive::set_size(const Vector2 &val) {
size = val;
set_dirty(true);
}
}
Beehive::Beehive() {
out_main;
out_random_color;
out_uv_map;
size = Vector2(4, 4);
}
Beehive::~Beehive() {
}
static void Beehive::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_out_main"), &Beehive::get_out_main);
ClassDB::bind_method(D_METHOD("set_out_main", "value"), &Beehive::set_out_main);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_main", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_main", "get_out_main");
ClassDB::bind_method(D_METHOD("get_out_random_color"), &Beehive::get_out_random_color);
ClassDB::bind_method(D_METHOD("set_out_random_color", "value"), &Beehive::set_out_random_color);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_random_color", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_random_color", "get_out_random_color");
ClassDB::bind_method(D_METHOD("get_out_uv_map"), &Beehive::get_out_uv_map);
ClassDB::bind_method(D_METHOD("set_out_uv_map", "value"), &Beehive::set_out_uv_map);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_uv_map", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_uv_map", "get_out_uv_map");
ClassDB::bind_method(D_METHOD("get_size"), &Beehive::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Beehive::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &Beehive::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Beehive::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Beehive::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Beehive::_get_value_for);
ClassDB::bind_method(D_METHOD("get_size"), &Beehive::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &Beehive::set_size);
}

View File

@ -0,0 +1,48 @@
#ifndef BEEHIVE_H
#define BEEHIVE_H
class Beehive : public MMNode {
GDCLASS(Beehive, MMNode);
public:
Ref<Resource> get_out_main();
void set_out_main(const Ref<Resource> &val);
Ref<Resource> get_out_random_color();
void set_out_random_color(const Ref<Resource> &val);
Ref<Resource> get_out_uv_map();
void set_out_uv_map(const Ref<Resource> &val);
Vector2 get_size();
void set_size(const Vector2 &val);
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);
Vector2 get_size();
void set_size(const Vector2 &val);
Beehive();
~Beehive();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> out_main;
//export(Resource)
Ref<Resource> out_random_color;
//export(Resource)
Ref<Resource> out_uv_map;
//export(Vector2)
Vector2 size = Vector2(4, 4);
//size
};
#endif

View File

@ -0,0 +1,584 @@
#include "bricks.h"
Ref<Resource> Bricks::get_out_bricks_pattern() {
return out_bricks_pattern;
}
void Bricks::set_out_bricks_pattern(const Ref<Resource> &val) {
out_bricks_pattern = val;
}
Ref<Resource> Bricks::get_out_random_color() {
return out_random_color;
}
void Bricks::set_out_random_color(const Ref<Resource> &val) {
out_random_color = val;
}
Ref<Resource> Bricks::get_out_position_x() {
return out_position_x;
}
void Bricks::set_out_position_x(const Ref<Resource> &val) {
out_position_x = val;
}
Ref<Resource> Bricks::get_out_position_y() {
return out_position_y;
}
void Bricks::set_out_position_y(const Ref<Resource> &val) {
out_position_y = val;
}
Ref<Resource> Bricks::get_out_brick_uv() {
return out_brick_uv;
}
void Bricks::set_out_brick_uv(const Ref<Resource> &val) {
out_brick_uv = val;
}
Ref<Resource> Bricks::get_out_corner_uv() {
return out_corner_uv;
}
void Bricks::set_out_corner_uv(const Ref<Resource> &val) {
out_corner_uv = val;
}
Ref<Resource> Bricks::get_out_direction() {
return out_direction;
}
void Bricks::set_out_direction(const Ref<Resource> &val) {
out_direction = val;
}
int Bricks::get_type() const {
return type;
}
void Bricks::set_type(const int val) {
type = val;
}
int Bricks::get_repeat() const {
return repeat;
}
void Bricks::set_repeat(const int val) {
repeat = val;
}
Vector2 Bricks::get_col_row() {
return col_row;
}
void Bricks::set_col_row(const Vector2 &val) {
col_row = val;
}
float Bricks::get_offset() const {
return offset;
}
void Bricks::set_offset(const float val) {
offset = val;
}
Ref<Resource> Bricks::get_mortar() {
return mortar;
}
void Bricks::set_mortar(const Ref<Resource> &val) {
mortar = val;
}
Ref<Resource> Bricks::get_bevel() {
return bevel;
}
void Bricks::set_bevel(const Ref<Resource> &val) {
bevel = val;
}
Ref<Resource> Bricks::get_roundness() {
return roundness;
}
void Bricks::set_roundness(const Ref<Resource> &val) {
roundness = val;
}
float Bricks::get_corner() const {
return corner;
}
void Bricks::set_corner(const float val) {
corner = val;
}
//tool;
//export(Resource) ;
Ref<Resource> out_bricks_pattern;
//export(Resource) ;
Ref<Resource> out_random_color;
//export(Resource) ;
Ref<Resource> out_position_x;
//export(Resource) ;
Ref<Resource> out_position_y;
//export(Resource) ;
Ref<Resource> out_brick_uv;
//export(Resource) ;
Ref<Resource> out_corner_uv;
//export(Resource) ;
Ref<Resource> out_direction;
//export(int, "Running Bond,Running Bond (2),HerringBone,Basket Weave,Spanish Bond") ;
int type = 0;
//export(int) ;
int repeat = 1;
//export(Vector2) ;
Vector2 col_row = Vector2(4, 4);
//export(float) ;
float offset = 0.5;
//export(Resource) ;
Ref<Resource> mortar;
//export(Resource) ;
Ref<Resource> bevel;
//export(Resource) ;
Ref<Resource> roundness;
//export(float) ;
float corner = 0.3;
void Bricks::_init_properties() {
if (!out_bricks_pattern) {
out_bricks_pattern = MMNodeUniversalProperty.new();
out_bricks_pattern.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_bricks_pattern.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_random_color) {
out_random_color = MMNodeUniversalProperty.new();
out_random_color.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_random_color.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_position_x) {
out_position_x = MMNodeUniversalProperty.new();
out_position_x.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_position_x.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_position_y) {
out_position_y = MMNodeUniversalProperty.new();
out_position_y.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_position_y.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_brick_uv) {
out_brick_uv = MMNodeUniversalProperty.new();
out_brick_uv.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_brick_uv.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_corner_uv) {
out_corner_uv = MMNodeUniversalProperty.new();
out_corner_uv.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_corner_uv.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_direction) {
out_direction = MMNodeUniversalProperty.new();
out_direction.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_direction.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!mortar) {
mortar = MMNodeUniversalProperty.new();
mortar.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
mortar.set_default_value(0.1);
}
mortar.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
mortar.slot_name = "Mortar";
mortar.value_step = 0.01;
mortar.value_range = Vector2(0, 0.5);
if (!bevel) {
bevel = MMNodeUniversalProperty.new();
bevel.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
bevel.set_default_value(0.1);
}
bevel.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
bevel.slot_name = "Bevel";
bevel.value_step = 0.01;
bevel.value_range = Vector2(0, 0.5);
if (!roundness) {
roundness = MMNodeUniversalProperty.new();
roundness.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
roundness.set_default_value(0.1);
}
roundness.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
roundness.slot_name = "Roundness";
roundness.value_step = 0.01;
roundness.value_range = Vector2(0, 0.5);
register_output_property(out_bricks_pattern);
register_output_property(out_random_color);
register_output_property(out_position_x);
register_output_property(out_position_y);
register_output_property(out_brick_uv);
register_output_property(out_corner_uv);
register_output_property(out_direction);
register_input_property(mortar);
register_input_property(bevel);
register_input_property(roundness);
}
void Bricks::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(out_bricks_pattern);
mm_graph_node.add_slot_texture_universal(out_random_color);
mm_graph_node.add_slot_texture_universal(out_position_x);
mm_graph_node.add_slot_texture_universal(out_position_y);
mm_graph_node.add_slot_texture_universal(out_brick_uv);
mm_graph_node.add_slot_texture_universal(out_corner_uv);
mm_graph_node.add_slot_texture_universal(out_direction);
mm_graph_node.add_slot_enum("get_type", "set_type", "Type", [ "Running Bond", "Running Bond (2)", "HerringBone", "Basket Weave", "Spanish Bond" ]);
mm_graph_node.add_slot_int("get_repeat", "set_repeat", "Repeat");
//, Vector2(1, 32))//, Vector2(0, 32));
mm_graph_node.add_slot_vector2("get_col_row", "set_col_row", "Col, Row");
mm_graph_node.add_slot_float("get_offset", "set_offset", "Offset");
mm_graph_node.add_slot_float_universal(mortar);
mm_graph_node.add_slot_float_universal(bevel);
mm_graph_node.add_slot_float_universal(roundness);
mm_graph_node.add_slot_float("get_corner", "set_corner", "Corner");
}
void Bricks::_render(const Variant &material) {
Ref<Image> bricks_pattern = Image.new();
Ref<Image> random_color = Image.new();
Ref<Image> position_x = Image.new();
Ref<Image> position_y = Image.new();
Ref<Image> brick_uv = Image.new();
Ref<Image> corner_uv = Image.new();
Ref<Image> direction = Image.new();
bricks_pattern.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
random_color.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
position_x.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
position_y.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
brick_uv.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
corner_uv.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
direction.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
bricks_pattern.lock();
random_color.lock();
position_x.lock();
position_y.lock();
brick_uv.lock();
corner_uv.lock();
direction.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);
//vec4 $(name_uv)_rect = bricks_$pattern($uv, vec2($columns, $rows), $repeat, $row_offset);
Color brick_rect = Color();
//"Running Bond,Running Bond (2),HerringBone,Basket Weave,Spanish Bond";
if (type == 0) {
brick_rect = MMAlgos.bricks_rb(uv, col_row, repeat, offset);
}
else if (type == 1) {
brick_rect = MMAlgos.bricks_rb2(uv, col_row, repeat, offset);
}
else if (type == 2) {
brick_rect = MMAlgos.bricks_hb(uv, col_row, repeat, offset);
}
else if (type == 3) {
brick_rect = MMAlgos.bricks_bw(uv, col_row, repeat, offset);
}
else if (type == 4) {
brick_rect = MMAlgos.bricks_sb(uv, col_row, repeat, offset);
}
//vec4 $(name_uv) = brick($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.001, $bevel*$bevel_map($uv)));
Color brick = MMAlgos.brick(uv, Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), mortar.get_value(uv), roundness.get_value(uv), max(0.001, bevel.get_value(uv)));
//Bricks pattern (float) - A greyscale image that shows the bricks pattern;
//$(name_uv).x;
Color bricks_pattern_col = Color(brick.r, brick.r, brick.r, 1);
//Random color (rgb) - A random color for each brick;
//brick_random_color($(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed));
Vector3 brc = MMAlgos.brick_random_color(Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), 1 / float(pseed));
Color random_color_col = Color(brc.x, brc.y, brc.z, 1);
//Position.x (float) - The position of each brick along the X axis",;
//$(name_uv).y;
Color position_x_col = Color(brick.g, brick.g, brick.g, 1);
//Position.y (float) - The position of each brick along the Y axis;
//$(name_uv).z;
Color position_y_col = Color(brick.b, brick.b, brick.b, 1);
//Brick UV (rgb) - An UV map output for each brick, to be connected to the Map input of a CustomUV node;
//brick_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed));
Vector3 buv = MMAlgos.brick_uv(uv, Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), pseed);
Color brick_uv_col = Color(buv.x, buv.y, buv.z, 1);
//Corner UV (rgb) - An UV map output for each brick corner, to be connected to the Map input of a CustomUV node;
//brick_corner_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $corner, float($seed));
Vector3 bcuv = MMAlgos.brick_corner_uv(uv, Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), mortar.get_value(uv), corner, pseed);
Color corner_uv_col = Color(bcuv.x, bcuv.y, bcuv.z, 1);
//Direction (float) - The direction of each brick (white: horizontal, black: vertical);
//0.5*(sign($(name_uv)_rect.z-$(name_uv)_rect.x-$(name_uv)_rect.w+$(name_uv)_rect.y)+1.0);
float d = 0.5 * (sign(brick_rect.b - brick_rect.r - brick_rect.a + brick_rect.g) + 1.0);
Color direction_col = Color(d, d, d, 1);
bricks_pattern.set_pixel(x, y, bricks_pattern_col);
random_color.set_pixel(x, y, random_color_col);
position_x.set_pixel(x, y, position_x_col);
position_y.set_pixel(x, y, position_y_col);
brick_uv.set_pixel(x, y, brick_uv_col);
corner_uv.set_pixel(x, y, corner_uv_col);
direction.set_pixel(x, y, direction_col);
}
}
bricks_pattern.unlock();
random_color.unlock();
position_x.unlock();
position_y.unlock();
brick_uv.unlock();
corner_uv.unlock();
direction.unlock();
out_bricks_pattern.set_value(bricks_pattern);
out_random_color.set_value(random_color);
out_position_x.set_value(position_x);
out_position_y.set_value(position_y);
out_brick_uv.set_value(brick_uv);
out_corner_uv.set_value(corner_uv);
out_direction.set_value(direction);
}
Color Bricks::_get_value_for(const Vector2 &uv, const int pseed) {
return Color();
}
//type;
int Bricks::get_type() {
return type;
}
void Bricks::set_type(const int val) {
type = val;
set_dirty(true);
}
//repeat;
int Bricks::get_repeat() {
return repeat;
}
void Bricks::set_repeat(const int val) {
repeat = val;
set_dirty(true);
}
//col_row;
Vector2 Bricks::get_col_row() {
return col_row;
}
void Bricks::set_col_row(const Vector2 &val) {
col_row = val;
set_dirty(true);
}
//offset;
float Bricks::get_offset() {
return offset;
}
void Bricks::set_offset(const float val) {
offset = val;
set_dirty(true);
}
//corner;
float Bricks::get_corner() {
return corner;
}
void Bricks::set_corner(const float val) {
corner = val;
set_dirty(true);
}
}
Bricks::Bricks() {
out_bricks_pattern;
out_random_color;
out_position_x;
out_position_y;
out_brick_uv;
out_corner_uv;
out_direction;
type = 0;
repeat = 1;
col_row = Vector2(4, 4);
offset = 0.5;
mortar;
bevel;
roundness;
corner = 0.3;
}
Bricks::~Bricks() {
}
static void Bricks::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_out_bricks_pattern"), &Bricks::get_out_bricks_pattern);
ClassDB::bind_method(D_METHOD("set_out_bricks_pattern", "value"), &Bricks::set_out_bricks_pattern);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_bricks_pattern", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_bricks_pattern", "get_out_bricks_pattern");
ClassDB::bind_method(D_METHOD("get_out_random_color"), &Bricks::get_out_random_color);
ClassDB::bind_method(D_METHOD("set_out_random_color", "value"), &Bricks::set_out_random_color);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_random_color", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_random_color", "get_out_random_color");
ClassDB::bind_method(D_METHOD("get_out_position_x"), &Bricks::get_out_position_x);
ClassDB::bind_method(D_METHOD("set_out_position_x", "value"), &Bricks::set_out_position_x);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_position_x", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_position_x", "get_out_position_x");
ClassDB::bind_method(D_METHOD("get_out_position_y"), &Bricks::get_out_position_y);
ClassDB::bind_method(D_METHOD("set_out_position_y", "value"), &Bricks::set_out_position_y);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_position_y", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_position_y", "get_out_position_y");
ClassDB::bind_method(D_METHOD("get_out_brick_uv"), &Bricks::get_out_brick_uv);
ClassDB::bind_method(D_METHOD("set_out_brick_uv", "value"), &Bricks::set_out_brick_uv);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_brick_uv", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_brick_uv", "get_out_brick_uv");
ClassDB::bind_method(D_METHOD("get_out_corner_uv"), &Bricks::get_out_corner_uv);
ClassDB::bind_method(D_METHOD("set_out_corner_uv", "value"), &Bricks::set_out_corner_uv);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_corner_uv", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_corner_uv", "get_out_corner_uv");
ClassDB::bind_method(D_METHOD("get_out_direction"), &Bricks::get_out_direction);
ClassDB::bind_method(D_METHOD("set_out_direction", "value"), &Bricks::set_out_direction);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_direction", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_direction", "get_out_direction");
ClassDB::bind_method(D_METHOD("get_type"), &Bricks::get_type);
ClassDB::bind_method(D_METHOD("set_type", "value"), &Bricks::set_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "type"), "set_type", "get_type");
ClassDB::bind_method(D_METHOD("get_repeat"), &Bricks::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "value"), &Bricks::set_repeat);
ADD_PROPERTY(PropertyInfo(Variant::INT, "repeat"), "set_repeat", "get_repeat");
ClassDB::bind_method(D_METHOD("get_col_row"), &Bricks::get_col_row);
ClassDB::bind_method(D_METHOD("set_col_row", "value"), &Bricks::set_col_row);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "col_row"), "set_col_row", "get_col_row");
ClassDB::bind_method(D_METHOD("get_offset"), &Bricks::get_offset);
ClassDB::bind_method(D_METHOD("set_offset", "value"), &Bricks::set_offset);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset"), "set_offset", "get_offset");
ClassDB::bind_method(D_METHOD("get_mortar"), &Bricks::get_mortar);
ClassDB::bind_method(D_METHOD("set_mortar", "value"), &Bricks::set_mortar);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mortar", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_mortar", "get_mortar");
ClassDB::bind_method(D_METHOD("get_bevel"), &Bricks::get_bevel);
ClassDB::bind_method(D_METHOD("set_bevel", "value"), &Bricks::set_bevel);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "bevel", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_bevel", "get_bevel");
ClassDB::bind_method(D_METHOD("get_roundness"), &Bricks::get_roundness);
ClassDB::bind_method(D_METHOD("set_roundness", "value"), &Bricks::set_roundness);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "roundness", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_roundness", "get_roundness");
ClassDB::bind_method(D_METHOD("get_corner"), &Bricks::get_corner);
ClassDB::bind_method(D_METHOD("set_corner", "value"), &Bricks::set_corner);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "corner"), "set_corner", "get_corner");
ClassDB::bind_method(D_METHOD("_init_properties"), &Bricks::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Bricks::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Bricks::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Bricks::_get_value_for);
ClassDB::bind_method(D_METHOD("get_type"), &Bricks::get_type);
ClassDB::bind_method(D_METHOD("set_type", "val"), &Bricks::set_type);
ClassDB::bind_method(D_METHOD("get_repeat"), &Bricks::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "val"), &Bricks::set_repeat);
ClassDB::bind_method(D_METHOD("get_col_row"), &Bricks::get_col_row);
ClassDB::bind_method(D_METHOD("set_col_row", "val"), &Bricks::set_col_row);
ClassDB::bind_method(D_METHOD("get_offset"), &Bricks::get_offset);
ClassDB::bind_method(D_METHOD("set_offset", "val"), &Bricks::set_offset);
ClassDB::bind_method(D_METHOD("get_corner"), &Bricks::get_corner);
ClassDB::bind_method(D_METHOD("set_corner", "val"), &Bricks::set_corner);
}

View File

@ -0,0 +1,115 @@
#ifndef BRICKS_H
#define BRICKS_H
class Bricks : public MMNode {
GDCLASS(Bricks, MMNode);
public:
Ref<Resource> get_out_bricks_pattern();
void set_out_bricks_pattern(const Ref<Resource> &val);
Ref<Resource> get_out_random_color();
void set_out_random_color(const Ref<Resource> &val);
Ref<Resource> get_out_position_x();
void set_out_position_x(const Ref<Resource> &val);
Ref<Resource> get_out_position_y();
void set_out_position_y(const Ref<Resource> &val);
Ref<Resource> get_out_brick_uv();
void set_out_brick_uv(const Ref<Resource> &val);
Ref<Resource> get_out_corner_uv();
void set_out_corner_uv(const Ref<Resource> &val);
Ref<Resource> get_out_direction();
void set_out_direction(const Ref<Resource> &val);
int get_type() const;
void set_type(const int val);
int get_repeat() const;
void set_repeat(const int val);
Vector2 get_col_row();
void set_col_row(const Vector2 &val);
float get_offset() const;
void set_offset(const float val);
Ref<Resource> get_mortar();
void set_mortar(const Ref<Resource> &val);
Ref<Resource> get_bevel();
void set_bevel(const Ref<Resource> &val);
Ref<Resource> get_roundness();
void set_roundness(const Ref<Resource> &val);
float get_corner() const;
void set_corner(const float val);
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);
int get_repeat();
void set_repeat(const int val);
Vector2 get_col_row();
void set_col_row(const Vector2 &val);
float get_offset();
void set_offset(const float val);
float get_corner();
void set_corner(const float val);
Bricks();
~Bricks();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> out_bricks_pattern;
//export(Resource)
Ref<Resource> out_random_color;
//export(Resource)
Ref<Resource> out_position_x;
//export(Resource)
Ref<Resource> out_position_y;
//export(Resource)
Ref<Resource> out_brick_uv;
//export(Resource)
Ref<Resource> out_corner_uv;
//export(Resource)
Ref<Resource> out_direction;
//export(int, "Running Bond,Running Bond (2),HerringBone,Basket Weave,Spanish Bond")
int type = 0;
//export(int)
int repeat = 1;
//export(Vector2)
Vector2 col_row = Vector2(4, 4);
//export(float)
float offset = 0.5;
//export(Resource)
Ref<Resource> mortar;
//export(Resource)
Ref<Resource> bevel;
//export(Resource)
Ref<Resource> roundness;
//export(float)
float corner = 0.3;
//type
//repeat
//col_row
//offset
//corner
};
#endif

View File

@ -0,0 +1,104 @@
#include "iching.h"
Ref<Resource> Iching::get_image() {
return image;
}
void Iching::set_image(const Ref<Resource> &val) {
image = val;
}
Vector2 Iching::get_size() {
return size;
}
void Iching::set_size(const Vector2 &val) {
size = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Vector2) ;
Vector2 size = Vector2(4, 4);
void Iching::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void Iching::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 1);
}
void Iching::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color Iching::_get_value_for(const Vector2 &uv, const int pseed) {
float ps = 1.0 / float(pseed);
//IChing(vec2($columns, $rows)*$uv, float($seed));
return MMAlgos.IChingc(uv, size, ps);
}
//size;
Vector2 Iching::get_size() {
return size;
}
void Iching::set_size(const Vector2 &val) {
size = val;
set_dirty(true);
}
}
Iching::Iching() {
image;
size = Vector2(4, 4);
}
Iching::~Iching() {
}
static void Iching::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Iching::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Iching::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_size"), &Iching::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Iching::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &Iching::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Iching::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Iching::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Iching::_get_value_for);
ClassDB::bind_method(D_METHOD("get_size"), &Iching::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &Iching::set_size);
}

View File

@ -0,0 +1,38 @@
#ifndef ICHING_H
#define ICHING_H
class Iching : public MMNode {
GDCLASS(Iching, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Vector2 get_size();
void set_size(const Vector2 &val);
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);
Vector2 get_size();
void set_size(const Vector2 &val);
Iching();
~Iching();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Vector2)
Vector2 size = Vector2(4, 4);
//size
};
#endif

View File

@ -0,0 +1,200 @@
#include "pattern.h"
Ref<Resource> Pattern::get_image() {
return image;
}
void Pattern::set_image(const Ref<Resource> &val) {
image = val;
}
int Pattern::get_combiner_type() const {
return combiner_type;
}
void Pattern::set_combiner_type(const int val) {
combiner_type = val;
}
int Pattern::get_combiner_axis_type_x() const {
return combiner_axis_type_x;
}
void Pattern::set_combiner_axis_type_x(const int val) {
combiner_axis_type_x = val;
}
int Pattern::get_combiner_axis_type_y() const {
return combiner_axis_type_y;
}
void Pattern::set_combiner_axis_type_y(const int val) {
combiner_axis_type_y = val;
}
Vector2 Pattern::get_repeat() {
return repeat;
}
void Pattern::set_repeat(const Vector2 &val) {
repeat = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(int, "Multiply,Add,Max,Min,Xor,Pow") ;
int combiner_type = 0;
//export(int, "Sine,Triangle,Square,Sawtooth,Constant,Bounce") ;
int combiner_axis_type_x = 0;
//export(int, "Sine,Triangle,Square,Sawtooth,Constant,Bounce") ;
int combiner_axis_type_y = 0;
//export(Vector2) ;
Vector2 repeat = Vector2(4, 4);
void Pattern::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void Pattern::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_enum("get_combiner_type", "set_combiner_type", "Combiner Type", [ "Multiply", "Add" , "Max", "Min", "Xor", "Pow" ]);
mm_graph_node.add_slot_enum("get_combiner_axis_type_x", "set_combiner_axis_type_x", "Combiner Axis type", [ "Sine", "Triangle", "Square", "Sawtooth", "Constant", "Bounce" ]);
mm_graph_node.add_slot_enum("get_combiner_axis_type_y", "set_combiner_axis_type_y", "", [ "Sine", "Triangle", "Square", "Sawtooth", "Constant", "Bounce" ]);
//, Vector2(0, 32));
mm_graph_node.add_slot_vector2("get_repeat", "set_repeat", "Repeat", 1);
}
void Pattern::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color Pattern::_get_value_for(const Vector2 &uv, const int pseed) {
float f = MMAlgos.pattern(uv, repeat.x, repeat.y, combiner_type, combiner_axis_type_x, combiner_axis_type_y);
return Color(f, f, f, 1);
}
//combiner_type;
int Pattern::get_combiner_type() {
return combiner_type;
}
void Pattern::set_combiner_type(const int val) {
combiner_type = val;
set_dirty(true);
}
//combiner_axis_type_x;
int Pattern::get_combiner_axis_type_x() {
return combiner_axis_type_x;
}
void Pattern::set_combiner_axis_type_x(const int val) {
combiner_axis_type_x = val;
set_dirty(true);
}
//combiner_axis_type_y;
int Pattern::get_combiner_axis_type_y() {
return combiner_axis_type_y;
}
void Pattern::set_combiner_axis_type_y(const int val) {
combiner_axis_type_y = val;
set_dirty(true);
}
//repeat;
Vector2 Pattern::get_repeat() {
return repeat;
}
void Pattern::set_repeat(const Vector2 &val) {
repeat = val;
set_dirty(true);
}
}
Pattern::Pattern() {
image;
combiner_type = 0;
combiner_axis_type_x = 0;
combiner_axis_type_y = 0;
repeat = Vector2(4, 4);
}
Pattern::~Pattern() {
}
static void Pattern::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Pattern::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Pattern::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_combiner_type"), &Pattern::get_combiner_type);
ClassDB::bind_method(D_METHOD("set_combiner_type", "value"), &Pattern::set_combiner_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "combiner_type"), "set_combiner_type", "get_combiner_type");
ClassDB::bind_method(D_METHOD("get_combiner_axis_type_x"), &Pattern::get_combiner_axis_type_x);
ClassDB::bind_method(D_METHOD("set_combiner_axis_type_x", "value"), &Pattern::set_combiner_axis_type_x);
ADD_PROPERTY(PropertyInfo(Variant::INT, "combiner_axis_type_x"), "set_combiner_axis_type_x", "get_combiner_axis_type_x");
ClassDB::bind_method(D_METHOD("get_combiner_axis_type_y"), &Pattern::get_combiner_axis_type_y);
ClassDB::bind_method(D_METHOD("set_combiner_axis_type_y", "value"), &Pattern::set_combiner_axis_type_y);
ADD_PROPERTY(PropertyInfo(Variant::INT, "combiner_axis_type_y"), "set_combiner_axis_type_y", "get_combiner_axis_type_y");
ClassDB::bind_method(D_METHOD("get_repeat"), &Pattern::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "value"), &Pattern::set_repeat);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "repeat"), "set_repeat", "get_repeat");
ClassDB::bind_method(D_METHOD("_init_properties"), &Pattern::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Pattern::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Pattern::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Pattern::_get_value_for);
ClassDB::bind_method(D_METHOD("get_combiner_type"), &Pattern::get_combiner_type);
ClassDB::bind_method(D_METHOD("set_combiner_type", "val"), &Pattern::set_combiner_type);
ClassDB::bind_method(D_METHOD("get_combiner_axis_type_x"), &Pattern::get_combiner_axis_type_x);
ClassDB::bind_method(D_METHOD("set_combiner_axis_type_x", "val"), &Pattern::set_combiner_axis_type_x);
ClassDB::bind_method(D_METHOD("get_combiner_axis_type_y"), &Pattern::get_combiner_axis_type_y);
ClassDB::bind_method(D_METHOD("set_combiner_axis_type_y", "val"), &Pattern::set_combiner_axis_type_y);
ClassDB::bind_method(D_METHOD("get_repeat"), &Pattern::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "val"), &Pattern::set_repeat);
}

View File

@ -0,0 +1,62 @@
#ifndef PATTERN_H
#define PATTERN_H
class Pattern : public MMNode {
GDCLASS(Pattern, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
int get_combiner_type() const;
void set_combiner_type(const int val);
int get_combiner_axis_type_x() const;
void set_combiner_axis_type_x(const int val);
int get_combiner_axis_type_y() const;
void set_combiner_axis_type_y(const int val);
Vector2 get_repeat();
void set_repeat(const Vector2 &val);
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_combiner_type();
void set_combiner_type(const int val);
int get_combiner_axis_type_x();
void set_combiner_axis_type_x(const int val);
int get_combiner_axis_type_y();
void set_combiner_axis_type_y(const int val);
Vector2 get_repeat();
void set_repeat(const Vector2 &val);
Pattern();
~Pattern();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(int, "Multiply,Add,Max,Min,Xor,Pow")
int combiner_type = 0;
//export(int, "Sine,Triangle,Square,Sawtooth,Constant,Bounce")
int combiner_axis_type_x = 0;
//export(int, "Sine,Triangle,Square,Sawtooth,Constant,Bounce")
int combiner_axis_type_y = 0;
//export(Vector2)
Vector2 repeat = Vector2(4, 4);
//combiner_type
//combiner_axis_type_x
//combiner_axis_type_y
//repeat
};
#endif

View File

@ -0,0 +1,104 @@
#include "runes.h"
Ref<Resource> Runes::get_image() {
return image;
}
void Runes::set_image(const Ref<Resource> &val) {
image = val;
}
Vector2 Runes::get_size() {
return size;
}
void Runes::set_size(const Vector2 &val) {
size = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Vector2) ;
Vector2 size = Vector2(4, 4);
void Runes::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void Runes::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 1);
}
void Runes::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color Runes::_get_value_for(const Vector2 &uv, const int pseed) {
float ps = 1.0 / float(pseed);
//Rune(vec2($columns, $rows)*$uv, float($seed));
return MMAlgos.runesc(uv, size, ps);
}
//size;
Vector2 Runes::get_size() {
return size;
}
void Runes::set_size(const Vector2 &val) {
size = val;
set_dirty(true);
}
}
Runes::Runes() {
image;
size = Vector2(4, 4);
}
Runes::~Runes() {
}
static void Runes::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Runes::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Runes::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_size"), &Runes::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Runes::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &Runes::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Runes::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Runes::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Runes::_get_value_for);
ClassDB::bind_method(D_METHOD("get_size"), &Runes::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &Runes::set_size);
}

View File

@ -0,0 +1,38 @@
#ifndef RUNES_H
#define RUNES_H
class Runes : public MMNode {
GDCLASS(Runes, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Vector2 get_size();
void set_size(const Vector2 &val);
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);
Vector2 get_size();
void set_size(const Vector2 &val);
Runes();
~Runes();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Vector2)
Vector2 size = Vector2(4, 4);
//size
};
#endif

View File

@ -0,0 +1,231 @@
#include "scratches.h"
Ref<Resource> Scratches::get_image() {
return image;
}
void Scratches::set_image(const Ref<Resource> &val) {
image = val;
}
Vector2 Scratches::get_size() {
return size;
}
void Scratches::set_size(const Vector2 &val) {
size = val;
}
int Scratches::get_layers() const {
return layers;
}
void Scratches::set_layers(const int val) {
layers = val;
}
float Scratches::get_waviness() const {
return waviness;
}
void Scratches::set_waviness(const float val) {
waviness = val;
}
int Scratches::get_angle() const {
return angle;
}
void Scratches::set_angle(const int val) {
angle = val;
}
float Scratches::get_randomness() const {
return randomness;
}
void Scratches::set_randomness(const float val) {
randomness = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(Vector2) ;
Vector2 size = Vector2(0.25, 0.4);
//export(int) ;
int layers = 4;
//export(float) ;
float waviness = 0.51;
//export(int) ;
int angle = 0;
//export(float) ;
float randomness = 0.44;
void Scratches::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void Scratches::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 0.01);
mm_graph_node.add_slot_int("get_layers", "set_layers", "Layers");
mm_graph_node.add_slot_float("get_waviness", "set_waviness", "Waviness", 0.01);
mm_graph_node.add_slot_int("get_angle", "set_angle", "Angle");
mm_graph_node.add_slot_float("get_randomness", "set_randomness", "Randomness", 0.01);
}
void Scratches::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color Scratches::_get_value_for(const Vector2 &uv, const int pseed) {
//scratches($uv, int($layers), vec2($length, $width), $waviness, $angle, $randomness, vec2(float($seed), 0.0));
return MMAlgos.scratchesc(uv, layers, size, waviness, angle, randomness, Vector2(pseed, 0.0));
}
//size;
Vector2 Scratches::get_size() {
return size;
}
void Scratches::set_size(const Vector2 &val) {
size = val;
set_dirty(true);
}
//layers;
int Scratches::get_layers() {
return layers;
}
void Scratches::set_layers(const int val) {
layers = val;
set_dirty(true);
}
//waviness;
float Scratches::get_waviness() {
return waviness;
}
void Scratches::set_waviness(const float val) {
waviness = val;
set_dirty(true);
}
//angle;
int Scratches::get_angle() {
return angle;
}
void Scratches::set_angle(const int val) {
angle = val;
set_dirty(true);
}
//randomness;
float Scratches::get_randomness() {
return randomness;
}
void Scratches::set_randomness(const float val) {
randomness = val;
set_dirty(true);
}
}
Scratches::Scratches() {
image;
size = Vector2(0.25, 0.4);
layers = 4;
waviness = 0.51;
angle = 0;
randomness = 0.44;
}
Scratches::~Scratches() {
}
static void Scratches::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Scratches::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Scratches::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_size"), &Scratches::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Scratches::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("get_layers"), &Scratches::get_layers);
ClassDB::bind_method(D_METHOD("set_layers", "value"), &Scratches::set_layers);
ADD_PROPERTY(PropertyInfo(Variant::INT, "layers"), "set_layers", "get_layers");
ClassDB::bind_method(D_METHOD("get_waviness"), &Scratches::get_waviness);
ClassDB::bind_method(D_METHOD("set_waviness", "value"), &Scratches::set_waviness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "waviness"), "set_waviness", "get_waviness");
ClassDB::bind_method(D_METHOD("get_angle"), &Scratches::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "value"), &Scratches::set_angle);
ADD_PROPERTY(PropertyInfo(Variant::INT, "angle"), "set_angle", "get_angle");
ClassDB::bind_method(D_METHOD("get_randomness"), &Scratches::get_randomness);
ClassDB::bind_method(D_METHOD("set_randomness", "value"), &Scratches::set_randomness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "randomness"), "set_randomness", "get_randomness");
ClassDB::bind_method(D_METHOD("_init_properties"), &Scratches::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Scratches::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Scratches::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Scratches::_get_value_for);
ClassDB::bind_method(D_METHOD("get_size"), &Scratches::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &Scratches::set_size);
ClassDB::bind_method(D_METHOD("get_layers"), &Scratches::get_layers);
ClassDB::bind_method(D_METHOD("set_layers", "val"), &Scratches::set_layers);
ClassDB::bind_method(D_METHOD("get_waviness"), &Scratches::get_waviness);
ClassDB::bind_method(D_METHOD("set_waviness", "val"), &Scratches::set_waviness);
ClassDB::bind_method(D_METHOD("get_angle"), &Scratches::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "val"), &Scratches::set_angle);
ClassDB::bind_method(D_METHOD("get_randomness"), &Scratches::get_randomness);
ClassDB::bind_method(D_METHOD("set_randomness", "val"), &Scratches::set_randomness);
}

View File

@ -0,0 +1,70 @@
#ifndef SCRATCHES_H
#define SCRATCHES_H
class Scratches : public MMNode {
GDCLASS(Scratches, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Vector2 get_size();
void set_size(const Vector2 &val);
int get_layers() const;
void set_layers(const int val);
float get_waviness() const;
void set_waviness(const float val);
int get_angle() const;
void set_angle(const int val);
float get_randomness() const;
void set_randomness(const float val);
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);
Vector2 get_size();
void set_size(const Vector2 &val);
int get_layers();
void set_layers(const int val);
float get_waviness();
void set_waviness(const float val);
int get_angle();
void set_angle(const int val);
float get_randomness();
void set_randomness(const float val);
Scratches();
~Scratches();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Vector2)
Vector2 size = Vector2(0.25, 0.4);
//export(int)
int layers = 4;
//export(float)
float waviness = 0.51;
//export(int)
int angle = 0;
//export(float)
float randomness = 0.44;
//size
//layers
//waviness
//angle
//randomness
};
#endif

View File

@ -0,0 +1,167 @@
#include "sine_wave.h"
Ref<Resource> SineWave::get_image() {
return image;
}
void SineWave::set_image(const Ref<Resource> &val) {
image = val;
}
float SineWave::get_amplitude() const {
return amplitude;
}
void SineWave::set_amplitude(const float val) {
amplitude = val;
}
float SineWave::get_frequency() const {
return frequency;
}
void SineWave::set_frequency(const float val) {
frequency = val;
}
float SineWave::get_phase() const {
return phase;
}
void SineWave::set_phase(const float val) {
phase = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(float) ;
float amplitude = 0.5;
//export(float) ;
float frequency = 2;
//export(float) ;
float phase = 0;
void SineWave::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void SineWave::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_float("get_amplitude", "set_amplitude", "Amplitude", 0.01);
mm_graph_node.add_slot_float("get_frequency", "set_frequency", "Frequency", 0.1);
mm_graph_node.add_slot_float("get_phase", "set_phase", "Phase", 0.01);
}
void SineWave::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color SineWave::_get_value_for(const Vector2 &uv, const int pseed) {
float f = 1.0 - abs(2.0 * (uv.y - 0.5) - amplitude *sin((frequency * uv.x + phase)*6.28318530718));
return Color(f, f, f, 1);
}
//amplitude;
float SineWave::get_amplitude() {
return amplitude;
}
void SineWave::set_amplitude(const float val) {
amplitude = val;
set_dirty(true);
}
//frequency;
float SineWave::get_frequency() {
return frequency;
}
void SineWave::set_frequency(const float val) {
frequency = val;
set_dirty(true);
}
//phase;
float SineWave::get_phase() {
return phase;
}
void SineWave::set_phase(const float val) {
phase = val;
set_dirty(true);
}
}
SineWave::SineWave() {
image;
amplitude = 0.5;
frequency = 2;
phase = 0;
}
SineWave::~SineWave() {
}
static void SineWave::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &SineWave::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &SineWave::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_amplitude"), &SineWave::get_amplitude);
ClassDB::bind_method(D_METHOD("set_amplitude", "value"), &SineWave::set_amplitude);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "amplitude"), "set_amplitude", "get_amplitude");
ClassDB::bind_method(D_METHOD("get_frequency"), &SineWave::get_frequency);
ClassDB::bind_method(D_METHOD("set_frequency", "value"), &SineWave::set_frequency);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "frequency"), "set_frequency", "get_frequency");
ClassDB::bind_method(D_METHOD("get_phase"), &SineWave::get_phase);
ClassDB::bind_method(D_METHOD("set_phase", "value"), &SineWave::set_phase);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "phase"), "set_phase", "get_phase");
ClassDB::bind_method(D_METHOD("_init_properties"), &SineWave::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SineWave::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &SineWave::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &SineWave::_get_value_for);
ClassDB::bind_method(D_METHOD("get_amplitude"), &SineWave::get_amplitude);
ClassDB::bind_method(D_METHOD("set_amplitude", "val"), &SineWave::set_amplitude);
ClassDB::bind_method(D_METHOD("get_frequency"), &SineWave::get_frequency);
ClassDB::bind_method(D_METHOD("set_frequency", "val"), &SineWave::set_frequency);
ClassDB::bind_method(D_METHOD("get_phase"), &SineWave::get_phase);
ClassDB::bind_method(D_METHOD("set_phase", "val"), &SineWave::set_phase);
}

View File

@ -0,0 +1,54 @@
#ifndef SINE_WAVE_H
#define SINE_WAVE_H
class SineWave : public MMNode {
GDCLASS(SineWave, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
float get_amplitude() const;
void set_amplitude(const float val);
float get_frequency() const;
void set_frequency(const float val);
float get_phase() const;
void set_phase(const float val);
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_amplitude();
void set_amplitude(const float val);
float get_frequency();
void set_frequency(const float val);
float get_phase();
void set_phase(const float val);
SineWave();
~SineWave();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(float)
float amplitude = 0.5;
//export(float)
float frequency = 2;
//export(float)
float phase = 0;
//amplitude
//frequency
//phase
};
#endif

View File

@ -0,0 +1,144 @@
#include "truchet.h"
Ref<Resource> Truchet::get_image() {
return image;
}
void Truchet::set_image(const Ref<Resource> &val) {
image = val;
}
int Truchet::get_shape() const {
return shape;
}
void Truchet::set_shape(const int val) {
shape = val;
}
float Truchet::get_size() const {
return size;
}
void Truchet::set_size(const float val) {
size = val;
}
//tool;
//export(Resource) ;
Ref<Resource> image;
//export(int, "Line,Circle") ;
int shape = 0;
//export(float) ;
float size = 4;
void Truchet::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
register_output_property(image);
}
void Truchet::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_enum("get_shape", "set_shape", "Shape", [ "Line", "Circle" ]);
mm_graph_node.add_slot_float("get_size", "set_size", "Size", 1);
}
void Truchet::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
}
Color Truchet::_get_value_for(const Vector2 &uv, const int pseed) {
if (shape == 0) {
return MMAlgos.truchet1c(uv, size, pseed);
}
else if (shape == 1) {
return MMAlgos.truchet2c(uv, size, pseed);
}
return Color();
}
//shape;
int Truchet::get_shape() {
return shape;
}
void Truchet::set_shape(const int val) {
shape = val;
set_dirty(true);
}
//size;
float Truchet::get_size() {
return size;
}
void Truchet::set_size(const float val) {
size = val;
set_dirty(true);
}
}
Truchet::Truchet() {
image;
shape = 0;
size = 4;
}
Truchet::~Truchet() {
}
static void Truchet::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Truchet::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Truchet::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_shape"), &Truchet::get_shape);
ClassDB::bind_method(D_METHOD("set_shape", "value"), &Truchet::set_shape);
ADD_PROPERTY(PropertyInfo(Variant::INT, "shape"), "set_shape", "get_shape");
ClassDB::bind_method(D_METHOD("get_size"), &Truchet::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Truchet::set_size);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &Truchet::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Truchet::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Truchet::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Truchet::_get_value_for);
ClassDB::bind_method(D_METHOD("get_shape"), &Truchet::get_shape);
ClassDB::bind_method(D_METHOD("set_shape", "val"), &Truchet::set_shape);
ClassDB::bind_method(D_METHOD("get_size"), &Truchet::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &Truchet::set_size);
}

View File

@ -0,0 +1,46 @@
#ifndef TRUCHET_H
#define TRUCHET_H
class Truchet : public MMNode {
GDCLASS(Truchet, MMNode);
public:
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
int get_shape() const;
void set_shape(const int val);
float get_size() const;
void set_size(const float val);
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_shape();
void set_shape(const int val);
float get_size();
void set_size(const float val);
Truchet();
~Truchet();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(int, "Line,Circle")
int shape = 0;
//export(float)
float size = 4;
//shape
//size
};
#endif

View File

@ -0,0 +1,258 @@
#include "weave.h"
Ref<Resource> Weave::get_out_main() {
return out_main;
}
void Weave::set_out_main(const Ref<Resource> &val) {
out_main = val;
}
Ref<Resource> Weave::get_out_horizontal_map() {
return out_horizontal_map;
}
void Weave::set_out_horizontal_map(const Ref<Resource> &val) {
out_horizontal_map = val;
}
Ref<Resource> Weave::get_out_vertical_map() {
return out_vertical_map;
}
void Weave::set_out_vertical_map(const Ref<Resource> &val) {
out_vertical_map = val;
}
Vector2 Weave::get_size() {
return size;
}
void Weave::set_size(const Vector2 &val) {
size = val;
}
Ref<Resource> Weave::get_width() {
return width;
}
void Weave::set_width(const Ref<Resource> &val) {
width = val;
}
int Weave::get_stitch() const {
return stitch;
}
void Weave::set_stitch(const int val) {
stitch = val;
}
//tool;
//export(Resource) ;
Ref<Resource> out_main;
//export(Resource) ;
Ref<Resource> out_horizontal_map;
//export(Resource) ;
Ref<Resource> out_vertical_map;
//export(Vector2) ;
Vector2 size = Vector2(4, 4);
//export(Resource) ;
Ref<Resource> width;
//export(int) ;
int stitch = 1;
void Weave::_init_properties() {
if (!out_main) {
out_main = MMNodeUniversalProperty.new();
out_main.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_main.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_horizontal_map) {
out_horizontal_map = MMNodeUniversalProperty.new();
out_horizontal_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_horizontal_map.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!out_vertical_map) {
out_vertical_map = MMNodeUniversalProperty.new();
out_vertical_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
}
out_vertical_map.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!width) {
width = MMNodeUniversalProperty.new();
width.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
width.set_default_value(Vector2(0.9, 0.9));
}
width.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
width.slot_name = "Width";
width.value_step = 0.01;
width.value_range = Vector2(0, 1);
register_output_property(out_main);
register_output_property(out_horizontal_map);
register_output_property(out_vertical_map);
register_input_property(width);
}
void Weave::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(out_main);
mm_graph_node.add_slot_texture_universal(out_horizontal_map);
mm_graph_node.add_slot_texture_universal(out_vertical_map);
//, Vector2(1, 32))//, Vector2(0, 32));
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size");
mm_graph_node.add_slot_vector2_universal(width);
mm_graph_node.add_slot_int("get_stitch", "set_stitch", "Stitch");
}
void Weave::_render(const Variant &material) {
Ref<Image> main_pattern = Image.new();
Ref<Image> horizontal_map = Image.new();
Ref<Image> vertical_map = Image.new();
main_pattern.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
horizontal_map.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
vertical_map.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
main_pattern.lock();
horizontal_map.lock();
vertical_map.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);
Vector2 width_val = width.get_value(uv);
//vec3 $(name_uv) = weave2($uv, vec2($columns, $rows), $stitch, $width_x*$width_map($uv), $width_y*$width_map($uv));
Vector3 weave = MMAlgos.weave2(uv, size, stitch, width_val.x, width_val.y);
//Outputs:;
//Output (float) - Shows the generated greyscale weave pattern.;
//$(name_uv).x;
Color main_pattern_col = Color(weave.x, weave.x, weave.x, 1);
//Horizontal mask (float) - Horizontal mask;
//$(name_uv).y;
Color horizontal_map_col = Color(weave.y, weave.y, weave.y, 1);
//Vertical mask (float) - Mask for vertical stripes;
//$(name_uv).z;
Color vertical_map_col = Color(weave.z, weave.z, weave.z, 1);
main_pattern.set_pixel(x, y, main_pattern_col);
horizontal_map.set_pixel(x, y, horizontal_map_col);
vertical_map.set_pixel(x, y, vertical_map_col);
}
}
main_pattern.unlock();
horizontal_map.unlock();
vertical_map.unlock();
out_main.set_value(main_pattern);
out_horizontal_map.set_value(horizontal_map);
out_vertical_map.set_value(vertical_map);
}
Color Weave::_get_value_for(const Vector2 &uv, const int pseed) {
return Color();
}
//size;
Vector2 Weave::get_size() {
return size;
}
void Weave::set_size(const Vector2 &val) {
size = val;
set_dirty(true);
}
//stitch;
int Weave::get_stitch() {
return stitch;
}
void Weave::set_stitch(const int val) {
stitch = val;
set_dirty(true);
}
}
Weave::Weave() {
out_main;
out_horizontal_map;
out_vertical_map;
size = Vector2(4, 4);
width;
stitch = 1;
}
Weave::~Weave() {
}
static void Weave::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_out_main"), &Weave::get_out_main);
ClassDB::bind_method(D_METHOD("set_out_main", "value"), &Weave::set_out_main);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_main", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_main", "get_out_main");
ClassDB::bind_method(D_METHOD("get_out_horizontal_map"), &Weave::get_out_horizontal_map);
ClassDB::bind_method(D_METHOD("set_out_horizontal_map", "value"), &Weave::set_out_horizontal_map);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_horizontal_map", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_horizontal_map", "get_out_horizontal_map");
ClassDB::bind_method(D_METHOD("get_out_vertical_map"), &Weave::get_out_vertical_map);
ClassDB::bind_method(D_METHOD("set_out_vertical_map", "value"), &Weave::set_out_vertical_map);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_vertical_map", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_vertical_map", "get_out_vertical_map");
ClassDB::bind_method(D_METHOD("get_size"), &Weave::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Weave::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("get_width"), &Weave::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &Weave::set_width);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "width", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_width", "get_width");
ClassDB::bind_method(D_METHOD("get_stitch"), &Weave::get_stitch);
ClassDB::bind_method(D_METHOD("set_stitch", "value"), &Weave::set_stitch);
ADD_PROPERTY(PropertyInfo(Variant::INT, "stitch"), "set_stitch", "get_stitch");
ClassDB::bind_method(D_METHOD("_init_properties"), &Weave::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Weave::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Weave::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Weave::_get_value_for);
ClassDB::bind_method(D_METHOD("get_size"), &Weave::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &Weave::set_size);
ClassDB::bind_method(D_METHOD("get_stitch"), &Weave::get_stitch);
ClassDB::bind_method(D_METHOD("set_stitch", "val"), &Weave::set_stitch);
}

View File

@ -0,0 +1,61 @@
#ifndef WEAVE_H
#define WEAVE_H
class Weave : public MMNode {
GDCLASS(Weave, MMNode);
public:
Ref<Resource> get_out_main();
void set_out_main(const Ref<Resource> &val);
Ref<Resource> get_out_horizontal_map();
void set_out_horizontal_map(const Ref<Resource> &val);
Ref<Resource> get_out_vertical_map();
void set_out_vertical_map(const Ref<Resource> &val);
Vector2 get_size();
void set_size(const Vector2 &val);
Ref<Resource> get_width();
void set_width(const Ref<Resource> &val);
int get_stitch() const;
void set_stitch(const int val);
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);
Vector2 get_size();
void set_size(const Vector2 &val);
int get_stitch();
void set_stitch(const int val);
Weave();
~Weave();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> out_main;
//export(Resource)
Ref<Resource> out_horizontal_map;
//export(Resource)
Ref<Resource> out_vertical_map;
//export(Vector2)
Vector2 size = Vector2(4, 4);
//export(Resource)
Ref<Resource> width;
//export(int)
int stitch = 1;
//size
//stitch
};
#endif

View File

@ -0,0 +1,135 @@
#include "sd_op_annular_shape.h"
Ref<Resource> SdOpAnnularShape::get_output() {
return output;
}
void SdOpAnnularShape::set_output(const Ref<Resource> &val) {
output = val;
}
float SdOpAnnularShape::get_width() const {
return width;
}
void SdOpAnnularShape::set_width(const float val) {
width = val;
}
int SdOpAnnularShape::get_ripples() const {
return ripples;
}
void SdOpAnnularShape::set_ripples(const int val) {
ripples = val;
}
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(float) ;
float width = 0.1;
//export(int) ;
int ripples = 1;
void SdOpAnnularShape::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Apply >>>";
output.get_value_from_owner = true;
register_input_property(output);
register_output_property(output);
}
void SdOpAnnularShape::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01);
mm_graph_node.add_slot_int("get_ripples", "set_ripples", "Ripples");
}
void SdOpAnnularShape::_get_property_value(const Vector2 &uv) {
float val = output.get_value(uv, true);
return MMAlgos.sdRipples(val, width, ripples);
}
//width;
float SdOpAnnularShape::get_width() {
return width;
}
void SdOpAnnularShape::set_width(const float val) {
width = val;
emit_changed();
output.emit_changed();
}
//ripples;
int SdOpAnnularShape::get_ripples() {
return ripples;
}
void SdOpAnnularShape::set_ripples(const int val) {
ripples = val;
emit_changed();
output.emit_changed();
}
}
SdOpAnnularShape::SdOpAnnularShape() {
output;
width = 0.1;
ripples = 1;
}
SdOpAnnularShape::~SdOpAnnularShape() {
}
static void SdOpAnnularShape::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdOpAnnularShape::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpAnnularShape::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_width"), &SdOpAnnularShape::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &SdOpAnnularShape::set_width);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
ClassDB::bind_method(D_METHOD("get_ripples"), &SdOpAnnularShape::get_ripples);
ClassDB::bind_method(D_METHOD("set_ripples", "value"), &SdOpAnnularShape::set_ripples);
ADD_PROPERTY(PropertyInfo(Variant::INT, "ripples"), "set_ripples", "get_ripples");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpAnnularShape::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpAnnularShape::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpAnnularShape::_get_property_value);
ClassDB::bind_method(D_METHOD("get_width"), &SdOpAnnularShape::get_width);
ClassDB::bind_method(D_METHOD("set_width", "val"), &SdOpAnnularShape::set_width);
ClassDB::bind_method(D_METHOD("get_ripples"), &SdOpAnnularShape::get_ripples);
ClassDB::bind_method(D_METHOD("set_ripples", "val"), &SdOpAnnularShape::set_ripples);
}

View File

@ -0,0 +1,45 @@
#ifndef SD_OP_ANNULAR_SHAPE_H
#define SD_OP_ANNULAR_SHAPE_H
class SdOpAnnularShape : public MMNode {
GDCLASS(SdOpAnnularShape, MMNode);
public:
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
float get_width() const;
void set_width(const float val);
int get_ripples() const;
void set_ripples(const int val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _get_property_value(const Vector2 &uv);
float get_width();
void set_width(const float val);
int get_ripples();
void set_ripples(const int val);
SdOpAnnularShape();
~SdOpAnnularShape();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(float)
float width = 0.1;
//export(int)
int ripples = 1;
//width
//ripples
};
#endif

View File

@ -0,0 +1,187 @@
#include "sd_op_bool.h"
Ref<Resource> SdOpBool::get_input1() {
return input1;
}
void SdOpBool::set_input1(const Ref<Resource> &val) {
input1 = val;
}
Ref<Resource> SdOpBool::get_input2() {
return input2;
}
void SdOpBool::set_input2(const Ref<Resource> &val) {
input2 = val;
}
Ref<Resource> SdOpBool::get_output() {
return output;
}
void SdOpBool::set_output(const Ref<Resource> &val) {
output = val;
}
int SdOpBool::get_operation() const {
return operation;
}
void SdOpBool::set_operation(const int val) {
operation = val;
}
//tool;
//export(Resource) ;
Ref<Resource> input1;
//export(Resource) ;
Ref<Resource> input2;
//export(Resource) ;
Ref<Resource> output;
//export(int, "Union,Substraction,Intersection") ;
int operation = 0;
void SdOpBool::_init_properties() {
if (!input1) {
input1 = MMNodeUniversalProperty.new();
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input1.slot_name = ">>> Input 1 ";
if (!input1.is_connected("changed", self, "on_input_changed")) {
input1.connect("changed", self, "on_input_changed");
}
if (!input2) {
input2 = MMNodeUniversalProperty.new();
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
// input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input2.slot_name = ">>> Input 2 ";
if (!input2.is_connected("changed", self, "on_input_changed")) {
input2.connect("changed", self, "on_input_changed");
}
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
// output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = " Output >>>";
output.get_value_from_owner = true;
register_input_property(input1);
register_input_property(input2);
register_output_property(output);
}
void SdOpBool::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input1);
mm_graph_node.add_slot_label_universal(input2);
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_enum("get_operation", "set_operation", "Operation", [ "Union", "Substraction", "Intersection" ]);
}
float SdOpBool::_get_property_value(const Vector2 &uv) {
if (operation == 0) {
return MMAlgos.sdf_boolean_union(input1.get_value(uv), input2.get_value(uv));
}
else if (operation == 1) {
return MMAlgos.sdf_boolean_substraction(input1.get_value(uv), input2.get_value(uv));
}
else if (operation == 2) {
return MMAlgos.sdf_boolean_intersection(input1.get_value(uv), input2.get_value(uv));
}
return 0.0;
}
//operation;
int SdOpBool::get_operation() {
return operation;
}
void SdOpBool::set_operation(const int val) {
operation = val;
emit_changed();
output.emit_changed();
}
void SdOpBool::on_input_changed() {
emit_changed();
output.emit_changed();
}
}
SdOpBool::SdOpBool() {
input1;
input2;
output;
operation = 0;
}
SdOpBool::~SdOpBool() {
}
static void SdOpBool::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input1"), &SdOpBool::get_input1);
ClassDB::bind_method(D_METHOD("set_input1", "value"), &SdOpBool::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"), &SdOpBool::get_input2);
ClassDB::bind_method(D_METHOD("set_input2", "value"), &SdOpBool::set_input2);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input2", "get_input2");
ClassDB::bind_method(D_METHOD("get_output"), &SdOpBool::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpBool::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"), &SdOpBool::get_operation);
ClassDB::bind_method(D_METHOD("set_operation", "value"), &SdOpBool::set_operation);
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation"), "set_operation", "get_operation");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpBool::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpBool::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpBool::_get_property_value);
ClassDB::bind_method(D_METHOD("get_operation"), &SdOpBool::get_operation);
ClassDB::bind_method(D_METHOD("set_operation", "val"), &SdOpBool::set_operation);
ClassDB::bind_method(D_METHOD("on_input_changed"), &SdOpBool::on_input_changed);
}

View File

@ -0,0 +1,48 @@
#ifndef SD_OP_BOOL_H
#define SD_OP_BOOL_H
class SdOpBool : public MMNode {
GDCLASS(SdOpBool, MMNode);
public:
Ref<Resource> get_input1();
void set_input1(const Ref<Resource> &val);
Ref<Resource> get_input2();
void set_input2(const Ref<Resource> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
int get_operation() const;
void set_operation(const int val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
float _get_property_value(const Vector2 &uv);
int get_operation();
void set_operation(const int val);
void on_input_changed();
SdOpBool();
~SdOpBool();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> input1;
//export(Resource)
Ref<Resource> input2;
//export(Resource)
Ref<Resource> output;
//export(int, "Union,Substraction,Intersection")
int operation = 0;
//operation
};
#endif

View File

@ -0,0 +1,103 @@
#include "sd_op_circle_repeat.h"
Ref<Resource> SdOpCircleRepeat::get_output() {
return output;
}
void SdOpCircleRepeat::set_output(const Ref<Resource> &val) {
output = val;
}
int SdOpCircleRepeat::get_count() const {
return count;
}
void SdOpCircleRepeat::set_count(const int val) {
count = val;
}
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(int) ;
int count = 6;
void SdOpCircleRepeat::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Apply >>>";
output.get_value_from_owner = true;
register_input_property(output);
register_output_property(output);
}
void SdOpCircleRepeat::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_int("get_count", "set_count", "Count");
}
void SdOpCircleRepeat::_get_property_value(const Vector2 &uv) {
//$in(circle_repeat_transform_2d($uv-vec2(0.5), $c)+vec2(0.5));
Vector2 new_uv = MMAlgos.circle_repeat_transform_2d(uv - Vector2(0.5, 0.5), count) + Vector2(0.5, 0.5);
return output.get_value(new_uv, true);
}
//count;
int SdOpCircleRepeat::get_count() {
return count;
}
void SdOpCircleRepeat::set_count(const int val) {
count = val;
emit_changed();
output.emit_changed();
}
}
SdOpCircleRepeat::SdOpCircleRepeat() {
output;
count = 6;
}
SdOpCircleRepeat::~SdOpCircleRepeat() {
}
static void SdOpCircleRepeat::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdOpCircleRepeat::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpCircleRepeat::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_count"), &SdOpCircleRepeat::get_count);
ClassDB::bind_method(D_METHOD("set_count", "value"), &SdOpCircleRepeat::set_count);
ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpCircleRepeat::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpCircleRepeat::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpCircleRepeat::_get_property_value);
ClassDB::bind_method(D_METHOD("get_count"), &SdOpCircleRepeat::get_count);
ClassDB::bind_method(D_METHOD("set_count", "val"), &SdOpCircleRepeat::set_count);
}

View File

@ -0,0 +1,37 @@
#ifndef SD_OP_CIRCLE_REPEAT_H
#define SD_OP_CIRCLE_REPEAT_H
class SdOpCircleRepeat : public MMNode {
GDCLASS(SdOpCircleRepeat, MMNode);
public:
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
int get_count() const;
void set_count(const int val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _get_property_value(const Vector2 &uv);
int get_count();
void set_count(const int val);
SdOpCircleRepeat();
~SdOpCircleRepeat();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(int)
int count = 6;
//count
};
#endif

View File

@ -0,0 +1,172 @@
#include "sd_op_morph.h"
Ref<Resource> SdOpMorph::get_input1() {
return input1;
}
void SdOpMorph::set_input1(const Ref<Resource> &val) {
input1 = val;
}
Ref<Resource> SdOpMorph::get_input2() {
return input2;
}
void SdOpMorph::set_input2(const Ref<Resource> &val) {
input2 = val;
}
Ref<Resource> SdOpMorph::get_output() {
return output;
}
void SdOpMorph::set_output(const Ref<Resource> &val) {
output = val;
}
float SdOpMorph::get_amount() const {
return amount;
}
void SdOpMorph::set_amount(const float val) {
amount = val;
}
//tool;
//export(Resource) ;
Ref<Resource> input1;
//export(Resource) ;
Ref<Resource> input2;
//export(Resource) ;
Ref<Resource> output;
//export(float) ;
float amount = 0.5;
void SdOpMorph::_init_properties() {
if (!input1) {
input1 = MMNodeUniversalProperty.new();
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input1.slot_name = ">>> Input 1 ";
if (!input1.is_connected("changed", self, "on_input_changed")) {
input1.connect("changed", self, "on_input_changed");
}
if (!input2) {
input2 = MMNodeUniversalProperty.new();
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
// input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input2.slot_name = ">>> Input 2 ";
if (!input2.is_connected("changed", self, "on_input_changed")) {
input2.connect("changed", self, "on_input_changed");
}
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
// output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = " Output >>>";
output.get_value_from_owner = true;
register_input_property(input1);
register_input_property(input2);
register_output_property(output);
}
void SdOpMorph::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input1);
mm_graph_node.add_slot_label_universal(input2);
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_float("get_amount", "set_amount", "Amount", 0.01);
}
float SdOpMorph::_get_property_value(const Vector2 &uv) {
return MMAlgos.sdf_morph(input1.get_value(uv), input2.get_value(uv), amount);
}
//amount;
float SdOpMorph::get_amount() {
return amount;
}
void SdOpMorph::set_amount(const float val) {
amount = val;
emit_changed();
output.emit_changed();
}
void SdOpMorph::on_input_changed() {
emit_changed();
output.emit_changed();
}
}
SdOpMorph::SdOpMorph() {
input1;
input2;
output;
amount = 0.5;
}
SdOpMorph::~SdOpMorph() {
}
static void SdOpMorph::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input1"), &SdOpMorph::get_input1);
ClassDB::bind_method(D_METHOD("set_input1", "value"), &SdOpMorph::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"), &SdOpMorph::get_input2);
ClassDB::bind_method(D_METHOD("set_input2", "value"), &SdOpMorph::set_input2);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input2", "get_input2");
ClassDB::bind_method(D_METHOD("get_output"), &SdOpMorph::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpMorph::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_amount"), &SdOpMorph::get_amount);
ClassDB::bind_method(D_METHOD("set_amount", "value"), &SdOpMorph::set_amount);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "amount"), "set_amount", "get_amount");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpMorph::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpMorph::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpMorph::_get_property_value);
ClassDB::bind_method(D_METHOD("get_amount"), &SdOpMorph::get_amount);
ClassDB::bind_method(D_METHOD("set_amount", "val"), &SdOpMorph::set_amount);
ClassDB::bind_method(D_METHOD("on_input_changed"), &SdOpMorph::on_input_changed);
}

View File

@ -0,0 +1,48 @@
#ifndef SD_OP_MORPH_H
#define SD_OP_MORPH_H
class SdOpMorph : public MMNode {
GDCLASS(SdOpMorph, MMNode);
public:
Ref<Resource> get_input1();
void set_input1(const Ref<Resource> &val);
Ref<Resource> get_input2();
void set_input2(const Ref<Resource> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
float get_amount() const;
void set_amount(const float val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
float _get_property_value(const Vector2 &uv);
float get_amount();
void set_amount(const float val);
void on_input_changed();
SdOpMorph();
~SdOpMorph();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> input1;
//export(Resource)
Ref<Resource> input2;
//export(Resource)
Ref<Resource> output;
//export(float)
float amount = 0.5;
//amount
};
#endif

View File

@ -0,0 +1,171 @@
#include "sd_op_repeat.h"
Ref<Resource> SdOpRepeat::get_output() {
return output;
}
void SdOpRepeat::set_output(const Ref<Resource> &val) {
output = val;
}
int SdOpRepeat::get_x() const {
return x;
}
void SdOpRepeat::set_x(const int val) {
x = val;
}
int SdOpRepeat::get_y() const {
return y;
}
void SdOpRepeat::set_y(const int val) {
y = val;
}
float SdOpRepeat::get_random_rotation() const {
return random_rotation;
}
void SdOpRepeat::set_random_rotation(const float val) {
random_rotation = val;
}
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(int) ;
int x = 3;
//export(int) ;
int y = 3;
//export(float) ;
float random_rotation = 0.5;
void SdOpRepeat::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Apply >>>";
output.get_value_from_owner = true;
register_input_property(output);
register_output_property(output);
}
void SdOpRepeat::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_int("get_x", "set_x", "X");
mm_graph_node.add_slot_int("get_y", "set_y", "Y");
mm_graph_node.add_slot_float("get_random_rotation", "set_random_rotation", "Random rotation", 0.01);
}
void SdOpRepeat::_get_property_value(const Vector2 &uv) {
//todo add this as a parameter;
int pseed = 123123;
//$in(repeat_2d($uv, vec2(1.0/$rx, 1.0/$ry), float($seed), $r));
Vector2 new_uv = MMAlgos.repeat_2d(uv, Vector2(1.0 / float(x), 1.0/ float(y)), 1.0/float(pseed), random_rotation);
return output.get_value(new_uv, true);
}
//x;
int SdOpRepeat::get_x() {
return x;
}
void SdOpRepeat::set_x(const int val) {
x = val;
emit_changed();
output.emit_changed();
}
//y;
int SdOpRepeat::get_y() {
return y;
}
void SdOpRepeat::set_y(const int val) {
y = val;
emit_changed();
output.emit_changed();
}
//random_rotation;
float SdOpRepeat::get_random_rotation() {
return random_rotation;
}
void SdOpRepeat::set_random_rotation(const float val) {
random_rotation = val;
emit_changed();
output.emit_changed();
}
}
SdOpRepeat::SdOpRepeat() {
output;
x = 3;
y = 3;
random_rotation = 0.5;
}
SdOpRepeat::~SdOpRepeat() {
}
static void SdOpRepeat::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdOpRepeat::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpRepeat::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_x"), &SdOpRepeat::get_x);
ClassDB::bind_method(D_METHOD("set_x", "value"), &SdOpRepeat::set_x);
ADD_PROPERTY(PropertyInfo(Variant::INT, "x"), "set_x", "get_x");
ClassDB::bind_method(D_METHOD("get_y"), &SdOpRepeat::get_y);
ClassDB::bind_method(D_METHOD("set_y", "value"), &SdOpRepeat::set_y);
ADD_PROPERTY(PropertyInfo(Variant::INT, "y"), "set_y", "get_y");
ClassDB::bind_method(D_METHOD("get_random_rotation"), &SdOpRepeat::get_random_rotation);
ClassDB::bind_method(D_METHOD("set_random_rotation", "value"), &SdOpRepeat::set_random_rotation);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "random_rotation"), "set_random_rotation", "get_random_rotation");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpRepeat::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpRepeat::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpRepeat::_get_property_value);
ClassDB::bind_method(D_METHOD("get_x"), &SdOpRepeat::get_x);
ClassDB::bind_method(D_METHOD("set_x", "val"), &SdOpRepeat::set_x);
ClassDB::bind_method(D_METHOD("get_y"), &SdOpRepeat::get_y);
ClassDB::bind_method(D_METHOD("set_y", "val"), &SdOpRepeat::set_y);
ClassDB::bind_method(D_METHOD("get_random_rotation"), &SdOpRepeat::get_random_rotation);
ClassDB::bind_method(D_METHOD("set_random_rotation", "val"), &SdOpRepeat::set_random_rotation);
}

View File

@ -0,0 +1,53 @@
#ifndef SD_OP_REPEAT_H
#define SD_OP_REPEAT_H
class SdOpRepeat : public MMNode {
GDCLASS(SdOpRepeat, MMNode);
public:
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
int get_x() const;
void set_x(const int val);
int get_y() const;
void set_y(const int val);
float get_random_rotation() const;
void set_random_rotation(const float val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _get_property_value(const Vector2 &uv);
int get_x();
void set_x(const int val);
int get_y();
void set_y(const int val);
float get_random_rotation();
void set_random_rotation(const float val);
SdOpRepeat();
~SdOpRepeat();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(int)
int x = 3;
//export(int)
int y = 3;
//export(float)
float random_rotation = 0.5;
//x
//y
//random_rotation
};
#endif

View File

@ -0,0 +1,102 @@
#include "sd_op_rounded_shape.h"
Ref<Resource> SdOpRoundedShape::get_output() {
return output;
}
void SdOpRoundedShape::set_output(const Ref<Resource> &val) {
output = val;
}
float SdOpRoundedShape::get_radius() const {
return radius;
}
void SdOpRoundedShape::set_radius(const float val) {
radius = val;
}
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(float) ;
float radius = 0;
void SdOpRoundedShape::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Apply >>>";
output.get_value_from_owner = true;
register_input_property(output);
register_output_property(output);
}
void SdOpRoundedShape::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01);
}
void SdOpRoundedShape::_get_property_value(const Vector2 &uv) {
float val = output.get_value(uv, true);
return MMAlgos.sdf_rounded_shape(val, radius);
}
//radius;
float SdOpRoundedShape::get_radius() {
return radius;
}
void SdOpRoundedShape::set_radius(const float val) {
radius = val;
emit_changed();
output.emit_changed();
}
}
SdOpRoundedShape::SdOpRoundedShape() {
output;
radius = 0;
}
SdOpRoundedShape::~SdOpRoundedShape() {
}
static void SdOpRoundedShape::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdOpRoundedShape::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpRoundedShape::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_radius"), &SdOpRoundedShape::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &SdOpRoundedShape::set_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpRoundedShape::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpRoundedShape::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpRoundedShape::_get_property_value);
ClassDB::bind_method(D_METHOD("get_radius"), &SdOpRoundedShape::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "val"), &SdOpRoundedShape::set_radius);
}

View File

@ -0,0 +1,37 @@
#ifndef SD_OP_ROUNDED_SHAPE_H
#define SD_OP_ROUNDED_SHAPE_H
class SdOpRoundedShape : public MMNode {
GDCLASS(SdOpRoundedShape, MMNode);
public:
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
float get_radius() const;
void set_radius(const float val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _get_property_value(const Vector2 &uv);
float get_radius();
void set_radius(const float val);
SdOpRoundedShape();
~SdOpRoundedShape();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(float)
float radius = 0;
//radius
};
#endif

View File

@ -0,0 +1,220 @@
#include "sd_op_smooth_bool.h"
Ref<Resource> SdOpSmoothBool::get_input1() {
return input1;
}
void SdOpSmoothBool::set_input1(const Ref<Resource> &val) {
input1 = val;
}
Ref<Resource> SdOpSmoothBool::get_input2() {
return input2;
}
void SdOpSmoothBool::set_input2(const Ref<Resource> &val) {
input2 = val;
}
Ref<Resource> SdOpSmoothBool::get_output() {
return output;
}
void SdOpSmoothBool::set_output(const Ref<Resource> &val) {
output = val;
}
int SdOpSmoothBool::get_operation() const {
return operation;
}
void SdOpSmoothBool::set_operation(const int val) {
operation = val;
}
float SdOpSmoothBool::get_smoothness() const {
return smoothness;
}
void SdOpSmoothBool::set_smoothness(const float val) {
smoothness = val;
}
//tool;
//export(Resource) ;
Ref<Resource> input1;
//export(Resource) ;
Ref<Resource> input2;
//export(Resource) ;
Ref<Resource> output;
//export(int, "Union,Substraction,Intersection") ;
int operation = 0;
//export(float) ;
float smoothness = 0.15;
void SdOpSmoothBool::_init_properties() {
if (!input1) {
input1 = MMNodeUniversalProperty.new();
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input1.slot_name = ">>> Input 1 ";
if (!input1.is_connected("changed", self, "on_input_changed")) {
input1.connect("changed", self, "on_input_changed");
}
if (!input2) {
input2 = MMNodeUniversalProperty.new();
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
// input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input2.slot_name = ">>> Input 2 ";
if (!input2.is_connected("changed", self, "on_input_changed")) {
input2.connect("changed", self, "on_input_changed");
}
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
// output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = " Output >>>";
output.get_value_from_owner = true;
register_input_property(input1);
register_input_property(input2);
register_output_property(output);
}
void SdOpSmoothBool::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(input1);
mm_graph_node.add_slot_label_universal(input2);
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_enum("get_operation", "set_operation", "Operation", [ "Union", "Substraction", "Intersection" ]);
mm_graph_node.add_slot_float("get_smoothness", "set_smoothness", "Smoothness", 0.01);
}
float SdOpSmoothBool::_get_property_value(const Vector2 &uv) {
if (operation == 0) {
return MMAlgos.sdf_smooth_boolean_union(input1.get_value(uv), input2.get_value(uv), smoothness);
}
else if (operation == 1) {
return MMAlgos.sdf_smooth_boolean_substraction(input1.get_value(uv), input2.get_value(uv), smoothness);
}
else if (operation == 2) {
return MMAlgos.sdf_smooth_boolean_intersection(input1.get_value(uv), input2.get_value(uv), smoothness);
}
return 0.0;
}
//operation;
int SdOpSmoothBool::get_operation() {
return operation;
}
void SdOpSmoothBool::set_operation(const int val) {
operation = val;
emit_changed();
output.emit_changed();
}
//smoothness;
float SdOpSmoothBool::get_smoothness() {
return smoothness;
}
void SdOpSmoothBool::set_smoothness(const float val) {
smoothness = val;
emit_changed();
output.emit_changed();
}
void SdOpSmoothBool::on_input_changed() {
emit_changed();
output.emit_changed();
}
}
SdOpSmoothBool::SdOpSmoothBool() {
input1;
input2;
output;
operation = 0;
smoothness = 0.15;
}
SdOpSmoothBool::~SdOpSmoothBool() {
}
static void SdOpSmoothBool::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input1"), &SdOpSmoothBool::get_input1);
ClassDB::bind_method(D_METHOD("set_input1", "value"), &SdOpSmoothBool::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"), &SdOpSmoothBool::get_input2);
ClassDB::bind_method(D_METHOD("set_input2", "value"), &SdOpSmoothBool::set_input2);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input2", "get_input2");
ClassDB::bind_method(D_METHOD("get_output"), &SdOpSmoothBool::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpSmoothBool::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"), &SdOpSmoothBool::get_operation);
ClassDB::bind_method(D_METHOD("set_operation", "value"), &SdOpSmoothBool::set_operation);
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation"), "set_operation", "get_operation");
ClassDB::bind_method(D_METHOD("get_smoothness"), &SdOpSmoothBool::get_smoothness);
ClassDB::bind_method(D_METHOD("set_smoothness", "value"), &SdOpSmoothBool::set_smoothness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "smoothness"), "set_smoothness", "get_smoothness");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpSmoothBool::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpSmoothBool::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpSmoothBool::_get_property_value);
ClassDB::bind_method(D_METHOD("get_operation"), &SdOpSmoothBool::get_operation);
ClassDB::bind_method(D_METHOD("set_operation", "val"), &SdOpSmoothBool::set_operation);
ClassDB::bind_method(D_METHOD("get_smoothness"), &SdOpSmoothBool::get_smoothness);
ClassDB::bind_method(D_METHOD("set_smoothness", "val"), &SdOpSmoothBool::set_smoothness);
ClassDB::bind_method(D_METHOD("on_input_changed"), &SdOpSmoothBool::on_input_changed);
}

View File

@ -0,0 +1,56 @@
#ifndef SD_OP_SMOOTH_BOOL_H
#define SD_OP_SMOOTH_BOOL_H
class SdOpSmoothBool : public MMNode {
GDCLASS(SdOpSmoothBool, MMNode);
public:
Ref<Resource> get_input1();
void set_input1(const Ref<Resource> &val);
Ref<Resource> get_input2();
void set_input2(const Ref<Resource> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
int get_operation() const;
void set_operation(const int val);
float get_smoothness() const;
void set_smoothness(const float val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
float _get_property_value(const Vector2 &uv);
int get_operation();
void set_operation(const int val);
float get_smoothness();
void set_smoothness(const float val);
void on_input_changed();
SdOpSmoothBool();
~SdOpSmoothBool();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> input1;
//export(Resource)
Ref<Resource> input2;
//export(Resource)
Ref<Resource> output;
//export(int, "Union,Substraction,Intersection")
int operation = 0;
//export(float)
float smoothness = 0.15;
//operation
//smoothness
};
#endif

View File

@ -0,0 +1,164 @@
#include "sd_shape_arc.h"
Ref<Resource> SdShapeArc::get_output() {
return output;
}
void SdShapeArc::set_output(const Ref<Resource> &val) {
output = val;
}
Vector2 SdShapeArc::get_angle() {
return angle;
}
void SdShapeArc::set_angle(const Vector2 &val) {
angle = val;
}
float SdShapeArc::get_radius() const {
return radius;
}
void SdShapeArc::set_radius(const float val) {
radius = val;
}
float SdShapeArc::get_width() const {
return width;
}
void SdShapeArc::set_width(const float val) {
width = val;
}
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(Vector2) ;
Vector2 angle = Vector2(30, 150);
//export(float) ;
float radius = 0.3;
//export(float) ;
float width = 0.1;
void SdShapeArc::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
register_output_property(output);
}
void SdShapeArc::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_vector2("get_angle", "set_angle", "Angle", 1);
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01);
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01);
}
float SdShapeArc::_get_property_value(const Vector2 &uv) {
return MMAlgos.sdf_arc(uv, angle, Vector2(radius, width));
}
//angle;
Vector2 SdShapeArc::get_angle() {
return angle;
}
void SdShapeArc::set_angle(const Vector2 &val) {
angle = val;
emit_changed();
output.emit_changed();
}
//radius;
float SdShapeArc::get_radius() {
return radius;
}
void SdShapeArc::set_radius(const float val) {
radius = val;
emit_changed();
output.emit_changed();
}
//width;
float SdShapeArc::get_width() {
return width;
}
void SdShapeArc::set_width(const float val) {
width = val;
emit_changed();
output.emit_changed();
}
}
SdShapeArc::SdShapeArc() {
output;
angle = Vector2(30, 150);
radius = 0.3;
width = 0.1;
}
SdShapeArc::~SdShapeArc() {
}
static void SdShapeArc::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdShapeArc::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdShapeArc::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_angle"), &SdShapeArc::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "value"), &SdShapeArc::set_angle);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "angle"), "set_angle", "get_angle");
ClassDB::bind_method(D_METHOD("get_radius"), &SdShapeArc::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &SdShapeArc::set_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
ClassDB::bind_method(D_METHOD("get_width"), &SdShapeArc::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &SdShapeArc::set_width);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdShapeArc::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdShapeArc::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdShapeArc::_get_property_value);
ClassDB::bind_method(D_METHOD("get_angle"), &SdShapeArc::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "val"), &SdShapeArc::set_angle);
ClassDB::bind_method(D_METHOD("get_radius"), &SdShapeArc::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "val"), &SdShapeArc::set_radius);
ClassDB::bind_method(D_METHOD("get_width"), &SdShapeArc::get_width);
ClassDB::bind_method(D_METHOD("set_width", "val"), &SdShapeArc::set_width);
}

View File

@ -0,0 +1,53 @@
#ifndef SD_SHAPE_ARC_H
#define SD_SHAPE_ARC_H
class SdShapeArc : public MMNode {
GDCLASS(SdShapeArc, MMNode);
public:
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
Vector2 get_angle();
void set_angle(const Vector2 &val);
float get_radius() const;
void set_radius(const float val);
float get_width() const;
void set_width(const float val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
float _get_property_value(const Vector2 &uv);
Vector2 get_angle();
void set_angle(const Vector2 &val);
float get_radius();
void set_radius(const float val);
float get_width();
void set_width(const float val);
SdShapeArc();
~SdShapeArc();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(Vector2)
Vector2 angle = Vector2(30, 150);
//export(float)
float radius = 0.3;
//export(float)
float width = 0.1;
//angle
//radius
//width
};
#endif

View File

@ -0,0 +1,131 @@
#include "sd_shape_box.h"
Ref<Resource> SdShapeBox::get_output() {
return output;
}
void SdShapeBox::set_output(const Ref<Resource> &val) {
output = val;
}
Vector2 SdShapeBox::get_center() {
return center;
}
void SdShapeBox::set_center(const Vector2 &val) {
center = val;
}
Vector2 SdShapeBox::get_size() {
return size;
}
void SdShapeBox::set_size(const Vector2 &val) {
size = val;
}
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(Vector2) ;
Vector2 center = Vector2(0, 0);
//export(Vector2) ;
Vector2 size = Vector2(0.3, 0.2);
void SdShapeBox::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
register_output_property(output);
}
void SdShapeBox::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_vector2("get_center", "set_center", "Center", 0.01);
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 0.01);
}
float SdShapeBox::_get_property_value(const Vector2 &uv) {
return MMAlgos.sdf_box(uv, center, size);
}
//center;
Vector2 SdShapeBox::get_center() {
return center;
}
void SdShapeBox::set_center(const Vector2 &val) {
center = val;
emit_changed();
output.emit_changed();
}
//size;
Vector2 SdShapeBox::get_size() {
return size;
}
void SdShapeBox::set_size(const Vector2 &val) {
size = val;
emit_changed();
output.emit_changed();
}
}
SdShapeBox::SdShapeBox() {
output;
center = Vector2(0, 0);
size = Vector2(0.3, 0.2);
}
SdShapeBox::~SdShapeBox() {
}
static void SdShapeBox::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdShapeBox::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdShapeBox::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_center"), &SdShapeBox::get_center);
ClassDB::bind_method(D_METHOD("set_center", "value"), &SdShapeBox::set_center);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center"), "set_center", "get_center");
ClassDB::bind_method(D_METHOD("get_size"), &SdShapeBox::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &SdShapeBox::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdShapeBox::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdShapeBox::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdShapeBox::_get_property_value);
ClassDB::bind_method(D_METHOD("get_center"), &SdShapeBox::get_center);
ClassDB::bind_method(D_METHOD("set_center", "val"), &SdShapeBox::set_center);
ClassDB::bind_method(D_METHOD("get_size"), &SdShapeBox::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &SdShapeBox::set_size);
}

View File

@ -0,0 +1,45 @@
#ifndef SD_SHAPE_BOX_H
#define SD_SHAPE_BOX_H
class SdShapeBox : public MMNode {
GDCLASS(SdShapeBox, MMNode);
public:
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
Vector2 get_center();
void set_center(const Vector2 &val);
Vector2 get_size();
void set_size(const Vector2 &val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
float _get_property_value(const Vector2 &uv);
Vector2 get_center();
void set_center(const Vector2 &val);
Vector2 get_size();
void set_size(const Vector2 &val);
SdShapeBox();
~SdShapeBox();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(Vector2)
Vector2 center = Vector2(0, 0);
//export(Vector2)
Vector2 size = Vector2(0.3, 0.2);
//center
//size
};
#endif

Some files were not shown because too many files have changed in this diff Show More