mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-14 23:58:26 +02:00
Cleaned up MMCircleMap, MMColorTiler, and the MMKaleidoscope nodes.
This commit is contained in:
parent
e1493ecac6
commit
0c759b2f16
@ -61,6 +61,9 @@ sources = [
|
|||||||
"nodes/transform/rotate.cpp",
|
"nodes/transform/rotate.cpp",
|
||||||
"nodes/transform/repeat.cpp",
|
"nodes/transform/repeat.cpp",
|
||||||
"nodes/transform/mirror.cpp",
|
"nodes/transform/mirror.cpp",
|
||||||
|
"nodes/transform/kaleidoscope.cpp",
|
||||||
|
"nodes/transform/color_tiler.cpp",
|
||||||
|
"nodes/transform/circle_map.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
if env["tools"]:
|
if env["tools"]:
|
||||||
|
@ -31,6 +31,8 @@ def get_doc_classes():
|
|||||||
"MMRotate",
|
"MMRotate",
|
||||||
"MMRepeat",
|
"MMRepeat",
|
||||||
"MMMirror",
|
"MMMirror",
|
||||||
|
"MMKaleidoscope",
|
||||||
|
"MMColorTiler",
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_doc_path():
|
def get_doc_path():
|
||||||
|
@ -1,106 +1,31 @@
|
|||||||
|
|
||||||
#include "circle_map.h"
|
#include "circle_map.h"
|
||||||
|
|
||||||
|
#include "../../algos/mm_algos.h"
|
||||||
|
#include "../../editor/mm_graph_node.h"
|
||||||
|
#include "../mm_material.h"
|
||||||
|
|
||||||
Ref<Resource> CircleMap::get_image() {
|
Ref<MMNodeUniversalProperty> MMCircleMap::get_image() {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CircleMap::set_image(const Ref<Resource> &val) {
|
void MMCircleMap::set_image(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
image = val;
|
image = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<MMNodeUniversalProperty> MMCircleMap::get_input() {
|
||||||
Ref<Resource> CircleMap::get_input() {
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CircleMap::set_input(const Ref<Resource> &val) {
|
void MMCircleMap::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
input = val;
|
input = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMCircleMap::get_radius() const {
|
||||||
float CircleMap::get_radius() const {
|
|
||||||
return radius;
|
return radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CircleMap::set_radius(const float val) {
|
void MMCircleMap::set_radius(const float val) {
|
||||||
radius = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CircleMap::get_repeat() const {
|
|
||||||
return repeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CircleMap::set_repeat(const int val) {
|
|
||||||
repeat = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//tool;
|
|
||||||
//export(Resource) ;
|
|
||||||
Ref<Resource> image;
|
|
||||||
//export(Resource) ;
|
|
||||||
Ref<Resource> input;
|
|
||||||
//export(float) ;
|
|
||||||
float radius = 1;
|
|
||||||
//export(int) ;
|
|
||||||
int repeat = 1;
|
|
||||||
|
|
||||||
void CircleMap::_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 CircleMap::_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_radius", "set_radius", "Radius", 0.01);
|
|
||||||
mm_graph_node.add_slot_int("get_repeat", "set_repeat", "Repeat");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CircleMap::_render(const Variant &material) {
|
|
||||||
Ref<Image> img = render_image(material);
|
|
||||||
image.set_value(img);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Color CircleMap::_get_value_for(const Vector2 &uv, const int pseed) {
|
|
||||||
//$in(vec2(fract($repeat*atan($uv.y-0.5, $uv.x-0.5)*0.15915494309), min(0.99999, 2.0/$radius*length($uv-vec2(0.5)))))",;
|
|
||||||
Vector2 nuv = Vector2(MMAlgos.fractf(repeat*atan2(uv.y - 0.5, uv.x - 0.5) * 0.15915494309), min(0.99999, 2.0 / radius * (uv - Vector2(0.5, 0.5)).length()));
|
|
||||||
return input.get_value(nuv);
|
|
||||||
}
|
|
||||||
|
|
||||||
//radius;
|
|
||||||
|
|
||||||
float CircleMap::get_radius() {
|
|
||||||
return radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CircleMap::set_radius(const float val) {
|
|
||||||
radius = val;
|
radius = val;
|
||||||
|
|
||||||
if (radius == 0) {
|
if (radius == 0) {
|
||||||
@ -110,62 +35,78 @@ repeat = val;
|
|||||||
set_dirty(true);
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//repeat;
|
int MMCircleMap::get_repeat() const {
|
||||||
|
|
||||||
int CircleMap::get_repeat() {
|
|
||||||
return repeat;
|
return repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMCircleMap::set_repeat(const int val) {
|
||||||
void CircleMap::set_repeat(const int val) {
|
|
||||||
repeat = val;
|
repeat = val;
|
||||||
set_dirty(true);
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMCircleMap::_init_properties() {
|
||||||
|
if (!input.is_valid()) {
|
||||||
|
input.instance();
|
||||||
|
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
|
||||||
|
input->set_default_value(Color(0, 0, 0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
CircleMap::CircleMap() {
|
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||||
image;
|
input->set_slot_name(">>> Input ");
|
||||||
input;
|
|
||||||
|
if (!image.is_valid()) {
|
||||||
|
image.instance();
|
||||||
|
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||||
|
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
|
||||||
|
//image.force_override = true;
|
||||||
|
|
||||||
|
register_input_property(input);
|
||||||
|
register_output_property(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MMCircleMap::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
|
mm_graph_node->add_slot_label_universal(input);
|
||||||
|
mm_graph_node->add_slot_texture_universal(image);
|
||||||
|
mm_graph_node->add_slot_float("get_radius", "set_radius", "Radius", 0.01);
|
||||||
|
mm_graph_node->add_slot_int("get_repeat", "set_repeat", "Repeat");
|
||||||
|
}
|
||||||
|
|
||||||
|
void MMCircleMap::_render(const Ref<MMMaterial> &material) {
|
||||||
|
Ref<Image> img = render_image(material);
|
||||||
|
image->set_value(img);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color MMCircleMap::_get_value_for(const Vector2 &uv, const int pseed) {
|
||||||
|
//$in(vec2(fract($repeat*atan($uv.y-0.5, $uv.x-0.5)*0.15915494309), min(0.99999, 2.0/$radius*length($uv-vec2(0.5)))))",;
|
||||||
|
Vector2 nuv = Vector2(MMAlgos::fractf(repeat * Math::atan2(uv.y - 0.5, uv.x - 0.5) * 0.15915494309), MIN(0.99999, 2.0 / radius * (uv - Vector2(0.5, 0.5)).length()));
|
||||||
|
return input->get_value(nuv);
|
||||||
|
}
|
||||||
|
|
||||||
|
MMCircleMap::MMCircleMap() {
|
||||||
radius = 1;
|
radius = 1;
|
||||||
repeat = 1;
|
repeat = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CircleMap::~CircleMap() {
|
MMCircleMap::~MMCircleMap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMCircleMap::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_image"), &MMCircleMap::get_image);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMCircleMap::set_image);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
|
||||||
|
|
||||||
static void CircleMap::_bind_methods() {
|
ClassDB::bind_method(D_METHOD("get_input"), &MMCircleMap::get_input);
|
||||||
ClassDB::bind_method(D_METHOD("get_image"), &CircleMap::get_image);
|
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMCircleMap::set_input);
|
||||||
ClassDB::bind_method(D_METHOD("set_image", "value"), &CircleMap::set_image);
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
|
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_radius"), &MMCircleMap::get_radius);
|
||||||
ClassDB::bind_method(D_METHOD("get_input"), &CircleMap::get_input);
|
ClassDB::bind_method(D_METHOD("set_radius", "value"), &MMCircleMap::set_radius);
|
||||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &CircleMap::set_input);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_radius"), &CircleMap::get_radius);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_radius", "value"), &CircleMap::set_radius);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_repeat"), &MMCircleMap::get_repeat);
|
||||||
ClassDB::bind_method(D_METHOD("get_repeat"), &CircleMap::get_repeat);
|
ClassDB::bind_method(D_METHOD("set_repeat", "value"), &MMCircleMap::set_repeat);
|
||||||
ClassDB::bind_method(D_METHOD("set_repeat", "value"), &CircleMap::set_repeat);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "repeat"), "set_repeat", "get_repeat");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "repeat"), "set_repeat", "get_repeat");
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_init_properties"), &CircleMap::_init_properties);
|
|
||||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &CircleMap::_register_methods);
|
|
||||||
ClassDB::bind_method(D_METHOD("_render", "material"), &CircleMap::_render);
|
|
||||||
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &CircleMap::_get_value_for);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_radius"), &CircleMap::get_radius);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_radius", "val"), &CircleMap::set_radius);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_repeat"), &CircleMap::get_repeat);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_repeat", "val"), &CircleMap::set_repeat);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
#ifndef CIRCLE_MAP_H
|
#ifndef MM_CIRCLE_MAP_H
|
||||||
#define CIRCLE_MAP_H
|
#define MM_CIRCLE_MAP_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class CircleMap : public MMNode {
|
class MMCircleMap : public MMNode {
|
||||||
GDCLASS(CircleMap, MMNode);
|
GDCLASS(MMCircleMap, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_image();
|
||||||
|
void set_image(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_image();
|
Ref<MMNodeUniversalProperty> get_input();
|
||||||
void set_image(const Ref<Resource> &val);
|
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_input();
|
|
||||||
void set_input(const Ref<Resource> &val);
|
|
||||||
|
|
||||||
float get_radius() const;
|
float get_radius() const;
|
||||||
void set_radius(const float val);
|
void set_radius(const float val);
|
||||||
@ -20,32 +21,20 @@ class CircleMap : public MMNode {
|
|||||||
void set_repeat(const int val);
|
void set_repeat(const int val);
|
||||||
|
|
||||||
void _init_properties();
|
void _init_properties();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
void _render(const Variant &material);
|
void _render(const Ref<MMMaterial> &material);
|
||||||
Color _get_value_for(const Vector2 &uv, const int pseed);
|
Color _get_value_for(const Vector2 &uv, const int pseed);
|
||||||
float get_radius();
|
|
||||||
void set_radius(const float val);
|
|
||||||
int get_repeat();
|
|
||||||
void set_repeat(const int val);
|
|
||||||
|
|
||||||
CircleMap();
|
MMCircleMap();
|
||||||
~CircleMap();
|
~MMCircleMap();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
//tool
|
Ref<MMNodeUniversalProperty> image;
|
||||||
//export(Resource)
|
Ref<MMNodeUniversalProperty> input;
|
||||||
Ref<Resource> image;
|
|
||||||
//export(Resource)
|
|
||||||
Ref<Resource> input;
|
|
||||||
//export(float)
|
|
||||||
float radius = 1;
|
float radius = 1;
|
||||||
//export(int)
|
|
||||||
int repeat = 1;
|
int repeat = 1;
|
||||||
//radius
|
|
||||||
//repeat
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,235 +1,211 @@
|
|||||||
|
|
||||||
#include "color_tiler.h"
|
#include "color_tiler.h"
|
||||||
|
|
||||||
|
#include "../../algos/mm_algos.h"
|
||||||
|
#include "../../editor/mm_graph_node.h"
|
||||||
|
#include "../mm_material.h"
|
||||||
|
|
||||||
Ref<Resource> ColorTiler::get_input() {
|
Ref<MMNodeUniversalProperty> MMColorTiler::get_input() {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_input(const Ref<Resource> &val) {
|
void MMColorTiler::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
input = val;
|
input = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<MMNodeUniversalProperty> MMColorTiler::get_in_mask() {
|
||||||
Ref<Resource> ColorTiler::get_in_mask() {
|
|
||||||
return in_mask;
|
return in_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_in_mask(const Ref<Resource> &val) {
|
void MMColorTiler::set_in_mask(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
in_mask = val;
|
in_mask = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<MMNodeUniversalProperty> MMColorTiler::get_output() {
|
||||||
Ref<Resource> ColorTiler::get_output() {
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_output(const Ref<Resource> &val) {
|
void MMColorTiler::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
output = val;
|
output = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<MMNodeUniversalProperty> MMColorTiler::get_instance_map() {
|
||||||
Ref<Resource> ColorTiler::get_instance_map() {
|
|
||||||
return instance_map;
|
return instance_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_instance_map(const Ref<Resource> &val) {
|
void MMColorTiler::set_instance_map(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
instance_map = val;
|
instance_map = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMColorTiler::get_tile() {
|
||||||
Vector2 ColorTiler::get_tile() {
|
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_tile(const Vector2 &val) {
|
void MMColorTiler::set_tile(const Vector2 &val) {
|
||||||
tile = val;
|
tile = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMColorTiler::get_overlap() const {
|
||||||
float ColorTiler::get_overlap() const {
|
|
||||||
return overlap;
|
return overlap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_overlap(const float val) {
|
void MMColorTiler::set_overlap(const float val) {
|
||||||
overlap = val;
|
overlap = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MMColorTiler::get_select_inputs() const {
|
||||||
int ColorTiler::get_select_inputs() const {
|
|
||||||
return select_inputs;
|
return select_inputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_select_inputs(const int val) {
|
void MMColorTiler::set_select_inputs(const int val) {
|
||||||
select_inputs = val;
|
select_inputs = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMColorTiler::get_scale() {
|
||||||
Vector2 ColorTiler::get_scale() {
|
|
||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_scale(const Vector2 &val) {
|
void MMColorTiler::set_scale(const Vector2 &val) {
|
||||||
scale = val;
|
scale = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMColorTiler::get_fixed_offset() const {
|
||||||
float ColorTiler::get_fixed_offset() const {
|
|
||||||
return fixed_offset;
|
return fixed_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_fixed_offset(const float val) {
|
void MMColorTiler::set_fixed_offset(const float val) {
|
||||||
fixed_offset = val;
|
fixed_offset = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMColorTiler::get_rnd_offset() const {
|
||||||
float ColorTiler::get_rnd_offset() const {
|
|
||||||
return rnd_offset;
|
return rnd_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_rnd_offset(const float val) {
|
void MMColorTiler::set_rnd_offset(const float val) {
|
||||||
rnd_offset = val;
|
rnd_offset = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMColorTiler::get_rnd_rotate() const {
|
||||||
float ColorTiler::get_rnd_rotate() const {
|
|
||||||
return rnd_rotate;
|
return rnd_rotate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_rnd_rotate(const float val) {
|
void MMColorTiler::set_rnd_rotate(const float val) {
|
||||||
rnd_rotate = val;
|
rnd_rotate = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMColorTiler::get_rnd_scale() const {
|
||||||
float ColorTiler::get_rnd_scale() const {
|
|
||||||
return rnd_scale;
|
return rnd_scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_rnd_scale(const float val) {
|
void MMColorTiler::set_rnd_scale(const float val) {
|
||||||
rnd_scale = val;
|
rnd_scale = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMColorTiler::get_rnd_opacity() const {
|
||||||
float ColorTiler::get_rnd_opacity() const {
|
|
||||||
return rnd_opacity;
|
return rnd_opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_rnd_opacity(const float val) {
|
void MMColorTiler::set_rnd_opacity(const float val) {
|
||||||
rnd_opacity = val;
|
rnd_opacity = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MMColorTiler::get_variations() const {
|
||||||
bool ColorTiler::get_variations() const {
|
|
||||||
return variations;
|
return variations;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTiler::set_variations(const bool val) {
|
void MMColorTiler::set_variations(const bool val) {
|
||||||
variations = val;
|
variations = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMColorTiler::_init_properties() {
|
||||||
|
if (!input.is_valid()) {
|
||||||
//tool;
|
input.instance();
|
||||||
//export(Resource) ;
|
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
|
||||||
Ref<Resource> input;
|
input->set_default_value(Color(0, 0, 0, 1));
|
||||||
//export(Resource) ;
|
|
||||||
Ref<Resource> in_mask;
|
|
||||||
//export(Resource) ;
|
|
||||||
Ref<Resource> output;
|
|
||||||
//export(Resource) ;
|
|
||||||
Ref<Resource> instance_map;
|
|
||||||
//export(Vector2) ;
|
|
||||||
Vector2 tile = Vector2(4, 4);
|
|
||||||
//export(float) ;
|
|
||||||
float overlap = 1;
|
|
||||||
//export(int, "1,4,16") ;
|
|
||||||
int select_inputs = 0;
|
|
||||||
//export(Vector2) ;
|
|
||||||
Vector2 scale = Vector2(0.5, 0.5);
|
|
||||||
//export(float) ;
|
|
||||||
float fixed_offset = 0;
|
|
||||||
//export(float) ;
|
|
||||||
float rnd_offset = 0.25;
|
|
||||||
//export(float) ;
|
|
||||||
float rnd_rotate = 45;
|
|
||||||
//export(float) ;
|
|
||||||
float rnd_scale = 0.2;
|
|
||||||
//export(float) ;
|
|
||||||
float rnd_opacity = 0;
|
|
||||||
//export(bool) ;
|
|
||||||
bool variations = false;
|
|
||||||
|
|
||||||
void ColorTiler::_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->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||||
input.slot_name = ">>> Input ";
|
input->set_slot_name(">>> Input ");
|
||||||
|
|
||||||
if (!in_mask) {
|
if (!in_mask.is_valid()) {
|
||||||
in_mask = MMNodeUniversalProperty.new();
|
in_mask.instance();
|
||||||
in_mask.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
|
in_mask->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
|
||||||
in_mask.set_default_value(1);
|
in_mask->set_default_value(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
in_mask.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
in_mask->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||||
in_mask.slot_name = ">>> Mask ";
|
in_mask->set_slot_name(">>> Mask ");
|
||||||
|
|
||||||
if (!output) {
|
if (!output.is_valid()) {
|
||||||
output = MMNodeUniversalProperty.new();
|
output.instance();
|
||||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
|
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
|
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
|
||||||
|
|
||||||
if (!instance_map) {
|
if (!instance_map.is_valid()) {
|
||||||
instance_map = MMNodeUniversalProperty.new();
|
instance_map.instance();
|
||||||
instance_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
|
instance_map->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
instance_map.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
|
instance_map->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
|
||||||
|
|
||||||
register_input_property(input);
|
register_input_property(input);
|
||||||
register_input_property(in_mask);
|
register_input_property(in_mask);
|
||||||
register_output_property(output);
|
register_output_property(output);
|
||||||
register_output_property(instance_map);
|
register_output_property(instance_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMColorTiler::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
|
mm_graph_node->add_slot_label_universal(input);
|
||||||
|
mm_graph_node->add_slot_label_universal(in_mask);
|
||||||
|
mm_graph_node->add_slot_texture_universal(output);
|
||||||
|
mm_graph_node->add_slot_texture_universal(instance_map);
|
||||||
|
mm_graph_node->add_slot_vector2("get_tile", "set_tile", "Tile", 1);
|
||||||
|
mm_graph_node->add_slot_float("get_overlap", "set_overlap", "Overlap", 1);
|
||||||
|
|
||||||
void ColorTiler::_register_methods(const Variant &mm_graph_node) {
|
Array arr;
|
||||||
mm_graph_node.add_slot_label_universal(input);
|
arr.push_back("1");
|
||||||
mm_graph_node.add_slot_label_universal(in_mask);
|
arr.push_back("4");
|
||||||
mm_graph_node.add_slot_texture_universal(output);
|
arr.push_back("16");
|
||||||
mm_graph_node.add_slot_texture_universal(instance_map);
|
|
||||||
mm_graph_node.add_slot_vector2("get_tile", "set_tile", "Tile", 1);
|
mm_graph_node->add_slot_enum("get_select_inputs", "set_select_inputs", "Select inputs", arr);
|
||||||
mm_graph_node.add_slot_float("get_overlap", "set_overlap", "Overlap", 1);
|
mm_graph_node->add_slot_vector2("get_scale", "set_scale", "Scale", 0.01);
|
||||||
mm_graph_node.add_slot_enum("get_select_inputs", "set_select_inputs", "Select inputs", [ "1", "4", "16" ]);
|
mm_graph_node->add_slot_float("get_fixed_offset", "set_fixed_offset", "Fixed Offset", 0.01);
|
||||||
mm_graph_node.add_slot_vector2("get_scale", "set_scale", "Scale", 0.01);
|
mm_graph_node->add_slot_float("get_rnd_offset", "set_rnd_offset", "Rnd Offset", 0.01);
|
||||||
mm_graph_node.add_slot_float("get_fixed_offset", "set_fixed_offset", "Fixed Offset", 0.01);
|
mm_graph_node->add_slot_float("get_rnd_rotate", "set_rnd_rotate", "Rnd Rotate", 0.1);
|
||||||
mm_graph_node.add_slot_float("get_rnd_offset", "set_rnd_offset", "Rnd Offset", 0.01);
|
mm_graph_node->add_slot_float("get_rnd_scale", "set_rnd_scale", "Rnd Scale", 0.01);
|
||||||
mm_graph_node.add_slot_float("get_rnd_rotate", "set_rnd_rotate", "Rnd Rotate", 0.1);
|
mm_graph_node->add_slot_float("get_rnd_opacity", "set_rnd_opacity", "Rnd Opacity", 0.01);
|
||||||
mm_graph_node.add_slot_float("get_rnd_scale", "set_rnd_scale", "Rnd Scale", 0.01);
|
|
||||||
mm_graph_node.add_slot_float("get_rnd_opacity", "set_rnd_opacity", "Rnd Opacity", 0.01);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//mm_graph_node.add_slot_bool("get_variations", "set_variations", "Variations");
|
//mm_graph_node.add_slot_bool("get_variations", "set_variations", "Variations");
|
||||||
|
|
||||||
void ColorTiler::_render(const Variant &material) {
|
void MMColorTiler::_render(const Ref<MMMaterial> &material) {
|
||||||
Ref<Image> output_img = Image.new();
|
Ref<Image> output_img;
|
||||||
Ref<Image> instance_map_img = Image.new();
|
output_img.instance();
|
||||||
output_img.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
|
Ref<Image> instance_map_img;
|
||||||
instance_map_img.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
|
instance_map_img.instance();
|
||||||
output_img.lock();
|
|
||||||
instance_map_img.lock();
|
output_img->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
|
||||||
float w = material.image_size.x;
|
instance_map_img->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
|
||||||
float h = material.image_size.y;
|
output_img->lock();
|
||||||
float pseed = randf() + randi();
|
instance_map_img->lock();
|
||||||
|
float w = material->image_size.x;
|
||||||
|
float h = material->image_size.y;
|
||||||
|
float pseed = Math::randf() + Math::rand();
|
||||||
float ps = 1.0 / float(pseed);
|
float ps = 1.0 / float(pseed);
|
||||||
int ix = int(material.image_size.x);
|
int ix = int(material->image_size.x);
|
||||||
int iy = int(material.image_size.y);
|
int iy = int(material->image_size.y);
|
||||||
|
|
||||||
for (int x = 0; x < ix; ++x) { //x in range(ix)
|
for (int x = 0; x < ix; ++x) { //x in range(ix)
|
||||||
|
|
||||||
@ -238,143 +214,21 @@ variations = val;
|
|||||||
//vec3 $(name_uv)_random_color;
|
//vec3 $(name_uv)_random_color;
|
||||||
//vec4 $(name_uv)_tiled_output = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), vec2(float($seed)), $(name_uv)_random_color);
|
//vec4 $(name_uv)_tiled_output = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), vec2(float($seed)), $(name_uv)_random_color);
|
||||||
PoolColorArray rch = tiler_calc(uv, tile, overlap, Vector2(ps, ps));
|
PoolColorArray rch = tiler_calc(uv, tile, overlap, Vector2(ps, ps));
|
||||||
output_img.set_pixel(x, y, rch[1]);
|
output_img->set_pixel(x, y, rch[1]);
|
||||||
instance_map_img.set_pixel(x, y, rch[0]);
|
instance_map_img->set_pixel(x, y, rch[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output_img->unlock();
|
||||||
|
instance_map_img->unlock();
|
||||||
|
output->set_value(output_img);
|
||||||
|
instance_map->set_value(instance_map_img);
|
||||||
}
|
}
|
||||||
|
|
||||||
output_img.unlock();
|
Color MMColorTiler::_get_value_for(const Vector2 &uv, const int pseed) {
|
||||||
instance_map_img.unlock();
|
|
||||||
output.set_value(output_img);
|
|
||||||
instance_map.set_value(instance_map_img);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Color ColorTiler::_get_value_for(const Vector2 &uv, const int pseed) {
|
|
||||||
return Color();
|
return Color();
|
||||||
}
|
}
|
||||||
|
|
||||||
//tile;
|
|
||||||
|
|
||||||
Vector2 ColorTiler::get_tile() {
|
|
||||||
return tile;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorTiler::set_tile(const Vector2 &val) {
|
|
||||||
tile = val;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//overlap;
|
|
||||||
|
|
||||||
float ColorTiler::get_overlap() {
|
|
||||||
return overlap;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorTiler::set_overlap(const float val) {
|
|
||||||
overlap = val;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//select_inputs;
|
|
||||||
|
|
||||||
int ColorTiler::get_select_inputs() {
|
|
||||||
return select_inputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorTiler::set_select_inputs(const int val) {
|
|
||||||
select_inputs = val;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//scale;
|
|
||||||
|
|
||||||
Vector2 ColorTiler::get_scale() {
|
|
||||||
return scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorTiler::set_scale(const Vector2 &val) {
|
|
||||||
scale = val;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//fixed_offset;
|
|
||||||
|
|
||||||
float ColorTiler::get_fixed_offset() {
|
|
||||||
return fixed_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorTiler::set_fixed_offset(const float val) {
|
|
||||||
fixed_offset = val;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//rnd_offset;
|
|
||||||
|
|
||||||
float ColorTiler::get_rnd_offset() {
|
|
||||||
return rnd_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorTiler::set_rnd_offset(const float val) {
|
|
||||||
rnd_offset = val;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//rnd_rotate;
|
|
||||||
|
|
||||||
float ColorTiler::get_rnd_rotate() {
|
|
||||||
return rnd_rotate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorTiler::set_rnd_rotate(const float val) {
|
|
||||||
rnd_rotate = val;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//rnd_scale;
|
|
||||||
|
|
||||||
float ColorTiler::get_rnd_scale() {
|
|
||||||
return rnd_scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorTiler::set_rnd_scale(const float val) {
|
|
||||||
rnd_scale = val;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//rnd_opacity;
|
|
||||||
|
|
||||||
float ColorTiler::get_rnd_opacity() {
|
|
||||||
return rnd_opacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorTiler::set_rnd_opacity(const float val) {
|
|
||||||
rnd_opacity = val;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//variations;
|
|
||||||
|
|
||||||
bool ColorTiler::get_variations() {
|
|
||||||
return variations;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorTiler::set_variations(const bool val) {
|
|
||||||
variations = val;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------;
|
//----------------------;
|
||||||
//color_tiler.mmg;
|
//color_tiler.mmg;
|
||||||
//Tiles several occurences of an input image while adding randomness.;
|
//Tiles several occurences of an input image while adding randomness.;
|
||||||
@ -424,7 +278,7 @@ variations = val;
|
|||||||
//4, "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));";
|
//4, "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));";
|
||||||
//16, "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));";
|
//16, "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));";
|
||||||
|
|
||||||
PoolColorArray ColorTiler::tiler_calc(const Vector2 &uv, const Vector2 &tile, const int overlap, const Vector2 &_seed) {
|
PoolColorArray MMColorTiler::tiler_calc(const Vector2 &uv, const Vector2 &tile, const int overlap, const Vector2 &_seed) {
|
||||||
Color c = Color();
|
Color c = Color();
|
||||||
Vector3 rc = Vector3();
|
Vector3 rc = Vector3();
|
||||||
Vector3 rc1 = Vector3();
|
Vector3 rc1 = Vector3();
|
||||||
@ -434,15 +288,15 @@ variations = val;
|
|||||||
//for (int dy = -overlap; dy <= overlap; ++dy) {;
|
//for (int dy = -overlap; dy <= overlap; ++dy) {;
|
||||||
|
|
||||||
for (int dy = -overlap; dy < overlap; ++dy) { //dy in range(-overlap, overlap)
|
for (int dy = -overlap; dy < overlap; ++dy) { //dy in range(-overlap, overlap)
|
||||||
Vector2 pos = MMAlgos.fractv2((MMAlgos.floorv2(uv * tile) + Vector2(dx, dy) + Vector2(0.5, 0.5)) / tile - Vector2(0.5, 0.5));
|
Vector2 pos = MMAlgos::fractv2((MMAlgos::floorv2(uv * tile) + Vector2(dx, dy) + Vector2(0.5, 0.5)) / tile - Vector2(0.5, 0.5));
|
||||||
Vector2 vseed = MMAlgos.rand2(pos + _seed);
|
Vector2 vseed = MMAlgos::rand2(pos + _seed);
|
||||||
rc1 = MMAlgos.rand3(vseed);
|
rc1 = MMAlgos::rand3(vseed);
|
||||||
pos = MMAlgos.fractv2(pos + Vector2(fixed_offset / tile.x, 0.0) * floor(MMAlgos.modf(pos.y * tile.y, 2.0)) + rnd_offset * vseed / tile);
|
pos = MMAlgos::fractv2(pos + Vector2(fixed_offset / tile.x, 0.0) * floor(MMAlgos::modf(pos.y * tile.y, 2.0)) + rnd_offset * vseed / tile);
|
||||||
float mask = in_mask.get_value(MMAlgos.fractv2(pos + Vector2(0.5, 0.5)));
|
float mask = in_mask->get_value(MMAlgos::fractv2(pos + Vector2(0.5, 0.5)));
|
||||||
|
|
||||||
if ((mask > 0.01)) {
|
if ((mask > 0.01)) {
|
||||||
Vector2 pv = MMAlgos.fractv2(uv - pos) - Vector2(0.5, 0.5);
|
Vector2 pv = MMAlgos::fractv2(uv - pos) - Vector2(0.5, 0.5);
|
||||||
vseed = MMAlgos.rand2(vseed);
|
vseed = MMAlgos::rand2(vseed);
|
||||||
float angle = (vseed.x * 2.0 - 1.0) * rnd_rotate * 0.01745329251;
|
float angle = (vseed.x * 2.0 - 1.0) * rnd_rotate * 0.01745329251;
|
||||||
float ca = cos(angle);
|
float ca = cos(angle);
|
||||||
float sa = sin(angle);
|
float sa = sin(angle);
|
||||||
@ -450,31 +304,29 @@ variations = val;
|
|||||||
pv *= (vseed.y - 0.5) * 2.0 * rnd_scale + 1.0;
|
pv *= (vseed.y - 0.5) * 2.0 * rnd_scale + 1.0;
|
||||||
pv /= scale;
|
pv /= scale;
|
||||||
pv += Vector2(0.5, 0.5);
|
pv += Vector2(0.5, 0.5);
|
||||||
pv = MMAlgos.clampv2(pv, Vector2(), Vector2(1, 1));
|
pv = MMAlgos::clampv2(pv, Vector2(), Vector2(1, 1));
|
||||||
//1, " ";
|
//1, " ";
|
||||||
//4, "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));";
|
//4, "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));";
|
||||||
//16, "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));";
|
//16, "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));";
|
||||||
|
|
||||||
if (select_inputs == 1) {
|
if (select_inputs == 1) {
|
||||||
pv = MMAlgos.clampv2(0.5*(pv + MMAlgos.floorv2(MMAlgos.rand2(vseed)*2.0)), Vector2(), Vector2(1, 1));
|
pv = MMAlgos::clampv2(0.5 * (pv + MMAlgos::floorv2(MMAlgos::rand2(vseed) * 2.0)), Vector2(), Vector2(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
else if (select_inputs == 2) {
|
else if (select_inputs == 2) {
|
||||||
pv = MMAlgos.clampv2(0.25*(pv + MMAlgos.floorv2(MMAlgos.rand2(vseed)*4.0)), Vector2(), Vector2(1, 1));
|
pv = MMAlgos::clampv2(0.25 * (pv + MMAlgos::floorv2(MMAlgos::rand2(vseed) * 4.0)), Vector2(), Vector2(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// vec4 n = $in.variation(pv, $variations ? seed.x : 0.0);
|
// vec4 n = $in.variation(pv, $variations ? seed.x : 0.0);
|
||||||
Color n = input.get_value(pv) * mask * (1.0 - rnd_opacity * vseed.x);
|
Color inc = input->get_value(pv);
|
||||||
vseed = MMAlgos.rand2(vseed);
|
Color n = inc * mask * (1.0 - rnd_opacity * vseed.x);
|
||||||
|
vseed = MMAlgos::rand2(vseed);
|
||||||
float na = n.a * mask * (1.0 - rnd_opacity * vseed.x);
|
float na = n.a * mask * (1.0 - rnd_opacity * vseed.x);
|
||||||
float a = (1.0 - c.a) * (1.0 * na);
|
//float a = (1.0 - c.a) * (1.0 * na);
|
||||||
c = lerp(c, n, na);
|
c = c.linear_interpolate(n, na);
|
||||||
rc = lerp(rc, rc1, n.a);
|
rc = rc.linear_interpolate(rc1, n.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolColorArray pc = PoolColorArray();
|
PoolColorArray pc = PoolColorArray();
|
||||||
@ -483,13 +335,7 @@ variations = val;
|
|||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
MMColorTiler::MMColorTiler() {
|
||||||
|
|
||||||
ColorTiler::ColorTiler() {
|
|
||||||
input;
|
|
||||||
in_mask;
|
|
||||||
output;
|
|
||||||
instance_map;
|
|
||||||
tile = Vector2(4, 4);
|
tile = Vector2(4, 4);
|
||||||
overlap = 1;
|
overlap = 1;
|
||||||
select_inputs = 0;
|
select_inputs = 0;
|
||||||
@ -502,108 +348,65 @@ variations = val;
|
|||||||
variations = false;
|
variations = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorTiler::~ColorTiler() {
|
MMColorTiler::~MMColorTiler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMColorTiler::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_input"), &MMColorTiler::get_input);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMColorTiler::set_input);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
|
||||||
|
|
||||||
static void ColorTiler::_bind_methods() {
|
ClassDB::bind_method(D_METHOD("get_in_mask"), &MMColorTiler::get_in_mask);
|
||||||
ClassDB::bind_method(D_METHOD("get_input"), &ColorTiler::get_input);
|
ClassDB::bind_method(D_METHOD("set_in_mask", "value"), &MMColorTiler::set_in_mask);
|
||||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &ColorTiler::set_input);
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "in_mask", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_in_mask", "get_in_mask");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_output"), &MMColorTiler::get_output);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMColorTiler::set_output);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_in_mask"), &ColorTiler::get_in_mask);
|
ClassDB::bind_method(D_METHOD("get_instance_map"), &MMColorTiler::get_instance_map);
|
||||||
ClassDB::bind_method(D_METHOD("set_in_mask", "value"), &ColorTiler::set_in_mask);
|
ClassDB::bind_method(D_METHOD("set_instance_map", "value"), &MMColorTiler::set_instance_map);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "in_mask", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_in_mask", "get_in_mask");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "instance_map", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_instance_map", "get_instance_map");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_tile"), &MMColorTiler::get_tile);
|
||||||
ClassDB::bind_method(D_METHOD("get_output"), &ColorTiler::get_output);
|
ClassDB::bind_method(D_METHOD("set_tile", "value"), &MMColorTiler::set_tile);
|
||||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &ColorTiler::set_output);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_instance_map"), &ColorTiler::get_instance_map);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_instance_map", "value"), &ColorTiler::set_instance_map);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "instance_map", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_instance_map", "get_instance_map");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_tile"), &ColorTiler::get_tile);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_tile", "value"), &ColorTiler::set_tile);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "tile"), "set_tile", "get_tile");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "tile"), "set_tile", "get_tile");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_overlap"), &MMColorTiler::get_overlap);
|
||||||
ClassDB::bind_method(D_METHOD("get_overlap"), &ColorTiler::get_overlap);
|
ClassDB::bind_method(D_METHOD("set_overlap", "value"), &MMColorTiler::set_overlap);
|
||||||
ClassDB::bind_method(D_METHOD("set_overlap", "value"), &ColorTiler::set_overlap);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "overlap"), "set_overlap", "get_overlap");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "overlap"), "set_overlap", "get_overlap");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_select_inputs"), &MMColorTiler::get_select_inputs);
|
||||||
ClassDB::bind_method(D_METHOD("get_select_inputs"), &ColorTiler::get_select_inputs);
|
ClassDB::bind_method(D_METHOD("set_select_inputs", "value"), &MMColorTiler::set_select_inputs);
|
||||||
ClassDB::bind_method(D_METHOD("set_select_inputs", "value"), &ColorTiler::set_select_inputs);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "select_inputs"), "set_select_inputs", "get_select_inputs");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "select_inputs"), "set_select_inputs", "get_select_inputs");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_scale"), &MMColorTiler::get_scale);
|
||||||
ClassDB::bind_method(D_METHOD("get_scale"), &ColorTiler::get_scale);
|
ClassDB::bind_method(D_METHOD("set_scale", "value"), &MMColorTiler::set_scale);
|
||||||
ClassDB::bind_method(D_METHOD("set_scale", "value"), &ColorTiler::set_scale);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_fixed_offset"), &MMColorTiler::get_fixed_offset);
|
||||||
ClassDB::bind_method(D_METHOD("get_fixed_offset"), &ColorTiler::get_fixed_offset);
|
ClassDB::bind_method(D_METHOD("set_fixed_offset", "value"), &MMColorTiler::set_fixed_offset);
|
||||||
ClassDB::bind_method(D_METHOD("set_fixed_offset", "value"), &ColorTiler::set_fixed_offset);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "fixed_offset"), "set_fixed_offset", "get_fixed_offset");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "fixed_offset"), "set_fixed_offset", "get_fixed_offset");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_rnd_offset"), &MMColorTiler::get_rnd_offset);
|
||||||
ClassDB::bind_method(D_METHOD("get_rnd_offset"), &ColorTiler::get_rnd_offset);
|
ClassDB::bind_method(D_METHOD("set_rnd_offset", "value"), &MMColorTiler::set_rnd_offset);
|
||||||
ClassDB::bind_method(D_METHOD("set_rnd_offset", "value"), &ColorTiler::set_rnd_offset);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rnd_offset"), "set_rnd_offset", "get_rnd_offset");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rnd_offset"), "set_rnd_offset", "get_rnd_offset");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_rnd_rotate"), &MMColorTiler::get_rnd_rotate);
|
||||||
ClassDB::bind_method(D_METHOD("get_rnd_rotate"), &ColorTiler::get_rnd_rotate);
|
ClassDB::bind_method(D_METHOD("set_rnd_rotate", "value"), &MMColorTiler::set_rnd_rotate);
|
||||||
ClassDB::bind_method(D_METHOD("set_rnd_rotate", "value"), &ColorTiler::set_rnd_rotate);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rnd_rotate"), "set_rnd_rotate", "get_rnd_rotate");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rnd_rotate"), "set_rnd_rotate", "get_rnd_rotate");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_rnd_scale"), &MMColorTiler::get_rnd_scale);
|
||||||
ClassDB::bind_method(D_METHOD("get_rnd_scale"), &ColorTiler::get_rnd_scale);
|
ClassDB::bind_method(D_METHOD("set_rnd_scale", "value"), &MMColorTiler::set_rnd_scale);
|
||||||
ClassDB::bind_method(D_METHOD("set_rnd_scale", "value"), &ColorTiler::set_rnd_scale);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rnd_scale"), "set_rnd_scale", "get_rnd_scale");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rnd_scale"), "set_rnd_scale", "get_rnd_scale");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_rnd_opacity"), &MMColorTiler::get_rnd_opacity);
|
||||||
ClassDB::bind_method(D_METHOD("get_rnd_opacity"), &ColorTiler::get_rnd_opacity);
|
ClassDB::bind_method(D_METHOD("set_rnd_opacity", "value"), &MMColorTiler::set_rnd_opacity);
|
||||||
ClassDB::bind_method(D_METHOD("set_rnd_opacity", "value"), &ColorTiler::set_rnd_opacity);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rnd_opacity"), "set_rnd_opacity", "get_rnd_opacity");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rnd_opacity"), "set_rnd_opacity", "get_rnd_opacity");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_variations"), &MMColorTiler::get_variations);
|
||||||
ClassDB::bind_method(D_METHOD("get_variations"), &ColorTiler::get_variations);
|
ClassDB::bind_method(D_METHOD("set_variations", "value"), &MMColorTiler::set_variations);
|
||||||
ClassDB::bind_method(D_METHOD("set_variations", "value"), &ColorTiler::set_variations);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "variations"), "set_variations", "get_variations");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "variations"), "set_variations", "get_variations");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("tiler_calc", "uv", "tile", "overlap", "_seed"), &MMColorTiler::tiler_calc);
|
||||||
ClassDB::bind_method(D_METHOD("_init_properties"), &ColorTiler::_init_properties);
|
|
||||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &ColorTiler::_register_methods);
|
|
||||||
ClassDB::bind_method(D_METHOD("_render", "material"), &ColorTiler::_render);
|
|
||||||
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &ColorTiler::_get_value_for);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_tile"), &ColorTiler::get_tile);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_tile", "val"), &ColorTiler::set_tile);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_overlap"), &ColorTiler::get_overlap);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_overlap", "val"), &ColorTiler::set_overlap);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_select_inputs"), &ColorTiler::get_select_inputs);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_select_inputs", "val"), &ColorTiler::set_select_inputs);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_scale"), &ColorTiler::get_scale);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_scale", "val"), &ColorTiler::set_scale);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_fixed_offset"), &ColorTiler::get_fixed_offset);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_fixed_offset", "val"), &ColorTiler::set_fixed_offset);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_rnd_offset"), &ColorTiler::get_rnd_offset);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_rnd_offset", "val"), &ColorTiler::set_rnd_offset);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_rnd_rotate"), &ColorTiler::get_rnd_rotate);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_rnd_rotate", "val"), &ColorTiler::set_rnd_rotate);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_rnd_scale"), &ColorTiler::get_rnd_scale);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_rnd_scale", "val"), &ColorTiler::set_rnd_scale);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_rnd_opacity"), &ColorTiler::get_rnd_opacity);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_rnd_opacity", "val"), &ColorTiler::set_rnd_opacity);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_variations"), &ColorTiler::get_variations);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_variations", "val"), &ColorTiler::set_variations);
|
|
||||||
ClassDB::bind_method(D_METHOD("tiler_calc", "uv", "tile", "overlap", "_seed"), &ColorTiler::tiler_calc);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
#ifndef COLOR_TILER_H
|
#ifndef MM_COLOR_TILER_H
|
||||||
#define COLOR_TILER_H
|
#define MM_COLOR_TILER_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class ColorTiler : public MMNode {
|
class MMColorTiler : public MMNode {
|
||||||
GDCLASS(ColorTiler, MMNode);
|
GDCLASS(MMColorTiler, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_input();
|
||||||
|
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_input();
|
Ref<MMNodeUniversalProperty> get_in_mask();
|
||||||
void set_input(const Ref<Resource> &val);
|
void set_in_mask(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_in_mask();
|
Ref<MMNodeUniversalProperty> get_output();
|
||||||
void set_in_mask(const Ref<Resource> &val);
|
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_output();
|
Ref<MMNodeUniversalProperty> get_instance_map();
|
||||||
void set_output(const Ref<Resource> &val);
|
void set_instance_map(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_instance_map();
|
|
||||||
void set_instance_map(const Ref<Resource> &val);
|
|
||||||
|
|
||||||
Vector2 get_tile();
|
Vector2 get_tile();
|
||||||
void set_tile(const Vector2 &val);
|
void set_tile(const Vector2 &val);
|
||||||
@ -50,126 +51,34 @@ class ColorTiler : public MMNode {
|
|||||||
void set_variations(const bool val);
|
void set_variations(const bool val);
|
||||||
|
|
||||||
void _init_properties();
|
void _init_properties();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
void _render(const Variant &material);
|
void _render(const Ref<MMMaterial> &material);
|
||||||
Color _get_value_for(const Vector2 &uv, const int pseed);
|
Color _get_value_for(const Vector2 &uv, const int pseed);
|
||||||
Vector2 get_tile();
|
|
||||||
void set_tile(const Vector2 &val);
|
|
||||||
float get_overlap();
|
|
||||||
void set_overlap(const float val);
|
|
||||||
int get_select_inputs();
|
|
||||||
void set_select_inputs(const int val);
|
|
||||||
Vector2 get_scale();
|
|
||||||
void set_scale(const Vector2 &val);
|
|
||||||
float get_fixed_offset();
|
|
||||||
void set_fixed_offset(const float val);
|
|
||||||
float get_rnd_offset();
|
|
||||||
void set_rnd_offset(const float val);
|
|
||||||
float get_rnd_rotate();
|
|
||||||
void set_rnd_rotate(const float val);
|
|
||||||
float get_rnd_scale();
|
|
||||||
void set_rnd_scale(const float val);
|
|
||||||
float get_rnd_opacity();
|
|
||||||
void set_rnd_opacity(const float val);
|
|
||||||
bool get_variations();
|
|
||||||
void set_variations(const bool val);
|
|
||||||
PoolColorArray tiler_calc(const Vector2 &uv, const Vector2 &tile, const int overlap, const Vector2 &_seed);
|
PoolColorArray tiler_calc(const Vector2 &uv, const Vector2 &tile, const int overlap, const Vector2 &_seed);
|
||||||
|
|
||||||
ColorTiler();
|
MMColorTiler();
|
||||||
~ColorTiler();
|
~MMColorTiler();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
//tool
|
Ref<MMNodeUniversalProperty> input;
|
||||||
//export(Resource)
|
Ref<MMNodeUniversalProperty> in_mask;
|
||||||
Ref<Resource> input;
|
Ref<MMNodeUniversalProperty> output;
|
||||||
//export(Resource)
|
Ref<MMNodeUniversalProperty> instance_map;
|
||||||
Ref<Resource> in_mask;
|
|
||||||
//export(Resource)
|
|
||||||
Ref<Resource> output;
|
|
||||||
//export(Resource)
|
|
||||||
Ref<Resource> instance_map;
|
|
||||||
//export(Vector2)
|
|
||||||
Vector2 tile = Vector2(4, 4);
|
Vector2 tile = Vector2(4, 4);
|
||||||
//export(float)
|
|
||||||
float overlap = 1;
|
float overlap = 1;
|
||||||
//export(int, "1,4,16")
|
//export(int, "1,4,16")
|
||||||
int select_inputs = 0;
|
int select_inputs = 0;
|
||||||
//export(Vector2)
|
|
||||||
Vector2 scale = Vector2(0.5, 0.5);
|
Vector2 scale = Vector2(0.5, 0.5);
|
||||||
//export(float)
|
|
||||||
float fixed_offset = 0;
|
float fixed_offset = 0;
|
||||||
//export(float)
|
|
||||||
float rnd_offset = 0.25;
|
float rnd_offset = 0.25;
|
||||||
//export(float)
|
|
||||||
float rnd_rotate = 45;
|
float rnd_rotate = 45;
|
||||||
//export(float)
|
|
||||||
float rnd_scale = 0.2;
|
float rnd_scale = 0.2;
|
||||||
//export(float)
|
|
||||||
float rnd_opacity = 0;
|
float rnd_opacity = 0;
|
||||||
//export(bool)
|
|
||||||
bool variations = false;
|
bool variations = false;
|
||||||
//mm_graph_node.add_slot_bool("get_variations", "set_variations", "Variations")
|
|
||||||
//tile
|
|
||||||
//overlap
|
|
||||||
//select_inputs
|
|
||||||
//scale
|
|
||||||
//fixed_offset
|
|
||||||
//rnd_offset
|
|
||||||
//rnd_rotate
|
|
||||||
//rnd_scale
|
|
||||||
//rnd_opacity
|
|
||||||
//variations
|
|
||||||
//----------------------
|
|
||||||
//color_tiler.mmg
|
|
||||||
//Tiles several occurences of an input image while adding randomness.
|
|
||||||
//vec4 tiler_$(name)(vec2 uv, vec2 tile, int overlap, vec2 _seed, out vec3 random_color) {
|
|
||||||
// vec4 c = vec4(0.0);
|
|
||||||
// vec3 rc = vec3(0.0);
|
|
||||||
// vec3 rc1;
|
|
||||||
//
|
|
||||||
// for (int dx = -overlap; dx <= overlap; ++dx) {
|
|
||||||
// for (int dy = -overlap; dy <= overlap; ++dy) {
|
|
||||||
// vec2 pos = fract((floor(uv*tile)+vec2(float(dx), float(dy))+vec2(0.5))/tile-vec2(0.5));
|
|
||||||
// vec2 seed = rand2(pos+_seed);
|
|
||||||
// rc1 = rand3(seed);
|
|
||||||
// pos = fract(pos+vec2($fixed_offset/tile.x, 0.0)*floor(mod(pos.y*tile.y, 2.0))+$offset*seed/tile);
|
|
||||||
// float mask = $mask(fract(pos+vec2(0.5)));
|
|
||||||
// if (mask > 0.01) {
|
|
||||||
// vec2 pv = fract(uv - pos)-vec2(0.5);
|
|
||||||
// seed = rand2(seed);
|
|
||||||
// float angle = (seed.x * 2.0 - 1.0) * $rotate * 0.01745329251;
|
|
||||||
// float ca = cos(angle);
|
|
||||||
// float sa = sin(angle);
|
|
||||||
// pv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);
|
|
||||||
// pv *= (seed.y-0.5)*2.0*$scale+1.0;
|
|
||||||
// pv /= vec2($scale_x, $scale_y);
|
|
||||||
// pv += vec2(0.5);
|
|
||||||
// pv = clamp(pv, vec2(0.0), vec2(1.0));
|
|
||||||
//
|
|
||||||
// $select_inputs
|
|
||||||
//
|
|
||||||
// vec4 n = $in.variation(pv, $variations ? seed.x : 0.0);
|
|
||||||
//
|
|
||||||
// seed = rand2(seed);
|
|
||||||
// float na = n.a*mask*(1.0-$opacity*seed.x);
|
|
||||||
// float a = (1.0-c.a)*(1.0*na);
|
|
||||||
//
|
|
||||||
// c = mix(c, n, na);
|
|
||||||
// rc = mix(rc, rc1, n.a);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// random_color = rc;
|
|
||||||
// return c;
|
|
||||||
//}
|
|
||||||
//select_inputs enum
|
|
||||||
//1, " "
|
|
||||||
//4, "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));"
|
|
||||||
//16, "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,165 +1,105 @@
|
|||||||
|
|
||||||
#include "kaleidoscope.h"
|
#include "kaleidoscope.h"
|
||||||
|
|
||||||
|
#include "../../algos/mm_algos.h"
|
||||||
|
#include "../../editor/mm_graph_node.h"
|
||||||
|
#include "../mm_material.h"
|
||||||
|
|
||||||
Ref<Resource> Kaleidoscope::get_image() {
|
Ref<MMNodeUniversalProperty> MMKaleidoscope::get_image() {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kaleidoscope::set_image(const Ref<Resource> &val) {
|
void MMKaleidoscope::set_image(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
image = val;
|
image = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<MMNodeUniversalProperty> MMKaleidoscope::get_input() {
|
||||||
Ref<Resource> Kaleidoscope::get_input() {
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kaleidoscope::set_input(const Ref<Resource> &val) {
|
void MMKaleidoscope::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
input = val;
|
input = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MMKaleidoscope::get_count() const {
|
||||||
int Kaleidoscope::get_count() const {
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kaleidoscope::set_count(const int val) {
|
void MMKaleidoscope::set_count(const int val) {
|
||||||
count = val;
|
count = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMKaleidoscope::get_offset() const {
|
||||||
float Kaleidoscope::get_offset() const {
|
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kaleidoscope::set_offset(const float val) {
|
void MMKaleidoscope::set_offset(const float val) {
|
||||||
offset = val;
|
offset = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMKaleidoscope::_init_properties() {
|
||||||
|
if (!input.is_valid()) {
|
||||||
//tool;
|
input.instance();
|
||||||
//export(Resource) ;
|
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
|
||||||
Ref<Resource> image;
|
input->set_default_value(Color(0, 0, 0, 1));
|
||||||
//export(Resource) ;
|
|
||||||
Ref<Resource> input;
|
|
||||||
//export(int) ;
|
|
||||||
int count = 5;
|
|
||||||
//export(float) ;
|
|
||||||
float offset = 0;
|
|
||||||
|
|
||||||
void Kaleidoscope::_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->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||||
input.slot_name = ">>> Input ";
|
input->set_slot_name(">>> Input ");
|
||||||
|
|
||||||
if (!image) {
|
if (!image.is_valid()) {
|
||||||
image = MMNodeUniversalProperty.new();
|
image.instance();
|
||||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
|
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
|
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
|
||||||
//image.force_override = true;
|
//image.force_override = true;
|
||||||
register_input_property(input);
|
register_input_property(input);
|
||||||
register_output_property(image);
|
register_output_property(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMKaleidoscope::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
void Kaleidoscope::_register_methods(const Variant &mm_graph_node) {
|
mm_graph_node->add_slot_label_universal(input);
|
||||||
mm_graph_node.add_slot_label_universal(input);
|
mm_graph_node->add_slot_texture_universal(image);
|
||||||
mm_graph_node.add_slot_texture_universal(image);
|
mm_graph_node->add_slot_int("get_count", "set_count", "Count");
|
||||||
mm_graph_node.add_slot_int("get_count", "set_count", "Count");
|
mm_graph_node->add_slot_float("get_offset", "set_offset", "Offset", 0.5);
|
||||||
mm_graph_node.add_slot_float("get_offset", "set_offset", "Offset", 0.5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMKaleidoscope::_render(const Ref<MMMaterial> &material) {
|
||||||
void Kaleidoscope::_render(const Variant &material) {
|
|
||||||
Ref<Image> img = render_image(material);
|
Ref<Image> img = render_image(material);
|
||||||
image.set_value(img);
|
image->set_value(img);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color MMKaleidoscope::_get_value_for(const Vector2 &uv, const int pseed) {
|
||||||
Color Kaleidoscope::_get_value_for(const Vector2 &uv, const int pseed) {
|
|
||||||
//$i(kal_rotate($uv, $count, $offset));
|
//$i(kal_rotate($uv, $count, $offset));
|
||||||
return input.get_value(MMAlgos.kal_rotate(uv, count, offset));
|
return input->get_value(MMAlgos::kal_rotate(uv, count, offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
//count;
|
MMKaleidoscope::MMKaleidoscope() {
|
||||||
|
|
||||||
int Kaleidoscope::get_count() {
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Kaleidoscope::set_count(const int val) {
|
|
||||||
count = val;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//offset;
|
|
||||||
|
|
||||||
float Kaleidoscope::get_offset() {
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Kaleidoscope::set_offset(const float val) {
|
|
||||||
offset = val;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Kaleidoscope::Kaleidoscope() {
|
|
||||||
image;
|
|
||||||
input;
|
|
||||||
count = 5;
|
count = 5;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Kaleidoscope::~Kaleidoscope() {
|
MMKaleidoscope::~MMKaleidoscope() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMKaleidoscope::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_image"), &MMKaleidoscope::get_image);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMKaleidoscope::set_image);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<MMNodeUniversalProperty>"), "set_image", "get_image");
|
||||||
|
|
||||||
static void Kaleidoscope::_bind_methods() {
|
ClassDB::bind_method(D_METHOD("get_input"), &MMKaleidoscope::get_input);
|
||||||
ClassDB::bind_method(D_METHOD("get_image"), &Kaleidoscope::get_image);
|
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMKaleidoscope::set_input);
|
||||||
ClassDB::bind_method(D_METHOD("set_image", "value"), &Kaleidoscope::set_image);
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<MMNodeUniversalProperty>"), "set_input", "get_input");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
|
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_count"), &MMKaleidoscope::get_count);
|
||||||
ClassDB::bind_method(D_METHOD("get_input"), &Kaleidoscope::get_input);
|
ClassDB::bind_method(D_METHOD("set_count", "value"), &MMKaleidoscope::set_count);
|
||||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &Kaleidoscope::set_input);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_count"), &Kaleidoscope::get_count);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_count", "value"), &Kaleidoscope::set_count);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_offset"), &MMKaleidoscope::get_offset);
|
||||||
ClassDB::bind_method(D_METHOD("get_offset"), &Kaleidoscope::get_offset);
|
ClassDB::bind_method(D_METHOD("set_offset", "value"), &MMKaleidoscope::set_offset);
|
||||||
ClassDB::bind_method(D_METHOD("set_offset", "value"), &Kaleidoscope::set_offset);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset"), "set_offset", "get_offset");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset"), "set_offset", "get_offset");
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Kaleidoscope::_init_properties);
|
|
||||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Kaleidoscope::_register_methods);
|
|
||||||
ClassDB::bind_method(D_METHOD("_render", "material"), &Kaleidoscope::_render);
|
|
||||||
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Kaleidoscope::_get_value_for);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_count"), &Kaleidoscope::get_count);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_count", "val"), &Kaleidoscope::set_count);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_offset"), &Kaleidoscope::get_offset);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_offset", "val"), &Kaleidoscope::set_offset);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
#ifndef KALEIDOSCOPE_H
|
#ifndef MM_KALEIDOSCOPE_H
|
||||||
#define KALEIDOSCOPE_H
|
#define MM_KALEIDOSCOPE_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class Kaleidoscope : public MMNode {
|
class MMKaleidoscope : public MMNode {
|
||||||
GDCLASS(Kaleidoscope, MMNode);
|
GDCLASS(MMKaleidoscope, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_image();
|
||||||
|
void set_image(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_image();
|
Ref<MMNodeUniversalProperty> get_input();
|
||||||
void set_image(const Ref<Resource> &val);
|
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_input();
|
|
||||||
void set_input(const Ref<Resource> &val);
|
|
||||||
|
|
||||||
int get_count() const;
|
int get_count() const;
|
||||||
void set_count(const int val);
|
void set_count(const int val);
|
||||||
@ -20,25 +21,21 @@ class Kaleidoscope : public MMNode {
|
|||||||
void set_offset(const float val);
|
void set_offset(const float val);
|
||||||
|
|
||||||
void _init_properties();
|
void _init_properties();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
void _render(const Variant &material);
|
void _render(const Ref<MMMaterial> &material);
|
||||||
Color _get_value_for(const Vector2 &uv, const int pseed);
|
Color _get_value_for(const Vector2 &uv, const int pseed);
|
||||||
int get_count();
|
|
||||||
void set_count(const int val);
|
|
||||||
float get_offset();
|
|
||||||
void set_offset(const float val);
|
|
||||||
|
|
||||||
Kaleidoscope();
|
MMKaleidoscope();
|
||||||
~Kaleidoscope();
|
~MMKaleidoscope();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
//tool
|
//tool
|
||||||
//export(Resource)
|
//export(MMNodeUniversalProperty)
|
||||||
Ref<Resource> image;
|
Ref<MMNodeUniversalProperty> image;
|
||||||
//export(Resource)
|
//export(MMNodeUniversalProperty)
|
||||||
Ref<Resource> input;
|
Ref<MMNodeUniversalProperty> input;
|
||||||
//export(int)
|
//export(int)
|
||||||
int count = 5;
|
int count = 5;
|
||||||
//export(float)
|
//export(float)
|
||||||
@ -47,5 +44,4 @@ class Kaleidoscope : public MMNode {
|
|||||||
//offset
|
//offset
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,6 +45,9 @@ SOFTWARE.
|
|||||||
#include "nodes/uniform/greyscale_uniform.h"
|
#include "nodes/uniform/greyscale_uniform.h"
|
||||||
#include "nodes/uniform/uniform.h"
|
#include "nodes/uniform/uniform.h"
|
||||||
|
|
||||||
|
#include "nodes/transform/circle_map.h"
|
||||||
|
#include "nodes/transform/color_tiler.h"
|
||||||
|
#include "nodes/transform/kaleidoscope.h"
|
||||||
#include "nodes/transform/mirror.h"
|
#include "nodes/transform/mirror.h"
|
||||||
#include "nodes/transform/repeat.h"
|
#include "nodes/transform/repeat.h"
|
||||||
#include "nodes/transform/rotate.h"
|
#include "nodes/transform/rotate.h"
|
||||||
@ -91,6 +94,12 @@ void register_material_maker_types() {
|
|||||||
MMAlgos::register_node_class("Transform", "MMRepeat");
|
MMAlgos::register_node_class("Transform", "MMRepeat");
|
||||||
ClassDB::register_class<MMMirror>();
|
ClassDB::register_class<MMMirror>();
|
||||||
MMAlgos::register_node_class("Transform", "MMMirror");
|
MMAlgos::register_node_class("Transform", "MMMirror");
|
||||||
|
ClassDB::register_class<MMKaleidoscope>();
|
||||||
|
MMAlgos::register_node_class("Transform", "MMKaleidoscope");
|
||||||
|
ClassDB::register_class<MMColorTiler>();
|
||||||
|
MMAlgos::register_node_class("Transform", "MMColorTiler");
|
||||||
|
ClassDB::register_class<MMCircleMap>();
|
||||||
|
MMAlgos::register_node_class("Transform", "MMCircleMap");
|
||||||
|
|
||||||
_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()));
|
||||||
|
Loading…
Reference in New Issue
Block a user