Cleaned up gradients.

This commit is contained in:
Relintai 2022-06-18 16:49:53 +02:00
parent cbb5142be6
commit e8cb984e21
9 changed files with 273 additions and 464 deletions

View File

@ -131,6 +131,10 @@ sources = [
"nodes/noise/color_value.cpp", "nodes/noise/color_value.cpp",
"nodes/noise/color_noise.cpp", "nodes/noise/color_noise.cpp",
"nodes/noise/anisotropic_noise.cpp", "nodes/noise/anisotropic_noise.cpp",
"nodes/gradient/radial_gradient.cpp",
"nodes/gradient/gradient.cpp",
"nodes/gradient/circular_gradient.cpp",
] ]
if env["tools"]: if env["tools"]:

View File

@ -101,6 +101,10 @@ def get_doc_classes():
"MMColorValue", "MMColorValue",
"MMColorNoise", "MMColorNoise",
"MMAnisotropicNoise", "MMAnisotropicNoise",
"MMRadialGradient",
"MMGradient",
"MMCircularGradient",
] ]
def get_doc_path(): def get_doc_path():

View File

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

@ -1,38 +1,33 @@
#ifndef CIRCULAR_GRADIENT_H #ifndef MM_CIRCULAR_GRADIENT_H
#define CIRCULAR_GRADIENT_H #define MM_CIRCULAR_GRADIENT_H
#include "../bases/gradient_base.h"
#include "../mm_node_universal_property.h"
class CircularGradient : public GradientBase { class MMCircularGradient : public GradientBase {
GDCLASS(CircularGradient, GradientBase); GDCLASS(MMCircularGradient, GradientBase);
public: public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image(); float get_repeat() const;
void set_image(const Ref<Resource> &val); void set_repeat(const float val);
float get_repeat() const; void _init_properties();
void set_repeat(const float val); void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
Color _get_gradient_color(const float x);
void _init_properties(); MMCircularGradient();
void _register_methods(const Variant &mm_graph_node); ~MMCircularGradient();
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(); protected:
~CircularGradient(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> image;
static void _bind_methods(); float repeat;
//tool
//export(Resource)
Ref<Resource> image;
//export(float)
float repeat = 1;
}; };
#endif #endif

View File

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

@ -1,45 +1,37 @@
#ifndef GRADIENT_H #ifndef MM_GRADIENT_H
#define GRADIENT_H #define MM_GRADIENT_H
#include "../bases/gradient_base.h"
#include "../mm_node_universal_property.h"
class Gradient : public GradientBase { class MMGradient : public GradientBase {
GDCLASS(Gradient, GradientBase); GDCLASS(MMGradient, GradientBase);
public: public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image(); float get_repeat() const;
void set_image(const Ref<Resource> &val); void set_repeat(const float val);
float get_repeat() const; float get_rotate() const;
void set_repeat(const float val); void set_rotate(const float val);
float get_rotate() const; void _init_properties();
void set_rotate(const float val); void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
Color _get_gradient_color(const float x);
void _init_properties(); MMGradient();
void _register_methods(const Variant &mm_graph_node); ~MMGradient();
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(); protected:
~Gradient(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> image;
static void _bind_methods(); float repeat;
float rotate;
//tool
//export(Resource)
Ref<Resource> image;
//export(float)
float repeat = 1;
//export(float)
float rotate = 0;
}; };
#endif #endif

View File

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

@ -1,38 +1,33 @@
#ifndef RADIAL_GRADIENT_H #ifndef MM_RADIAL_GRADIENT_H
#define RADIAL_GRADIENT_H #define MM_RADIAL_GRADIENT_H
#include "../bases/gradient_base.h"
#include "../mm_node_universal_property.h"
class RadialGradient : public GradientBase { class MMRadialGradient : public GradientBase {
GDCLASS(RadialGradient, GradientBase); GDCLASS(MMRadialGradient, GradientBase);
public: public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image(); float get_repeat() const;
void set_image(const Ref<Resource> &val); void set_repeat(const float val);
float get_repeat() const; void _init_properties();
void set_repeat(const float val); void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
Color _get_gradient_color(const float x);
void _init_properties(); MMRadialGradient();
void _register_methods(const Variant &mm_graph_node); ~MMRadialGradient();
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(); protected:
~RadialGradient(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> image;
static void _bind_methods(); float repeat;
//tool
//export(Resource)
Ref<Resource> image;
//export(float)
float repeat = 1;
}; };
#endif #endif

View File

@ -126,6 +126,10 @@ SOFTWARE.
#include "nodes/noise/noise.h" #include "nodes/noise/noise.h"
#include "nodes/noise/voronoi.h" #include "nodes/noise/voronoi.h"
#include "nodes/gradient/circular_gradient.h"
#include "nodes/gradient/gradient.h"
#include "nodes/gradient/radial_gradient.h"
static _MMAlgos *_mm_algos_singleton = nullptr; static _MMAlgos *_mm_algos_singleton = nullptr;
void register_material_maker_types() { void register_material_maker_types() {
@ -292,6 +296,13 @@ void register_material_maker_types() {
ClassDB::register_class<MMAnisotropicNoise>(); ClassDB::register_class<MMAnisotropicNoise>();
MMAlgos::register_node_class("Noise", "MMAnisotropicNoise"); MMAlgos::register_node_class("Noise", "MMAnisotropicNoise");
ClassDB::register_class<MMRadialGradient>();
MMAlgos::register_node_class("Gradient", "MMRadialGradient");
ClassDB::register_class<MMGradient>();
MMAlgos::register_node_class("Gradient", "MMGradient");
ClassDB::register_class<MMCircularGradient>();
MMAlgos::register_node_class("Gradient", "MMCircularGradient");
_mm_algos_singleton = memnew(_MMAlgos); _mm_algos_singleton = memnew(_MMAlgos);
Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton()));