[Region Fill] Fix empty result in random color mode.

This commit is contained in:
Tanasart 2024-10-19 10:57:57 +07:00
parent db274ac2d6
commit 84fa9459b7
26 changed files with 435 additions and 121 deletions

View file

@ -102,6 +102,7 @@
{"name":"VFX","order":6,"path":"folders/nodes/data/simulation/VFX.yy",},
{"name":"generators","order":1,"path":"folders/nodes/data/simulation/VFX/generators.yy",},
{"name":"tiler","order":31,"path":"folders/nodes/data/tiler.yy",},
{"name":"shaders","order":2,"path":"folders/nodes/data/tiler/shaders.yy",},
{"name":"tools","order":1,"path":"folders/nodes/data/tiler/tools.yy",},
{"name":"transform","order":28,"path":"folders/nodes/data/transform.yy",},
{"name":"value","order":29,"path":"folders/nodes/data/value.yy",},
@ -167,7 +168,6 @@
{"name":"color_picker","order":4,"path":"folders/shader/color_picker.yy",},
{"name":"color_selector","order":5,"path":"folders/shader/color_selector.yy",},
{"name":"draw","order":6,"path":"folders/shader/draw.yy",},
{"name":"tiler","order":17,"path":"folders/shader/draw/tiler.yy",},
{"name":"filter","order":7,"path":"folders/shader/filter.yy",},
{"name":"blend_edge","order":40,"path":"folders/shader/filter/blend_edge.yy",},
{"name":"blur","order":50,"path":"folders/shader/filter/blur.yy",},
@ -1376,8 +1376,11 @@
{"name":"textInput","order":3,"path":"scripts/textInput/textInput.yy",},
{"name":"texture_set_repeat","order":1,"path":"scripts/texture_set_repeat/texture_set_repeat.yy",},
{"name":"theme_definition","order":14,"path":"scripts/theme_definition/theme_definition.yy",},
{"name":"tiler_tool_brush_shape","order":3,"path":"scripts/tiler_tool_brush_shape/tiler_tool_brush_shape.yy",},
{"name":"tiler_tool_brush","order":1,"path":"scripts/tiler_tool_brush/tiler_tool_brush.yy",},
{"name":"tiler_tool_fill","order":2,"path":"scripts/tiler_tool_fill/tiler_tool_fill.yy",},
{"name":"tiler_tool_selection_shape","order":5,"path":"scripts/tiler_tool_selection_shape/tiler_tool_selection_shape.yy",},
{"name":"tiler_tool_selection","order":4,"path":"scripts/tiler_tool_selection/tiler_tool_selection.yy",},
{"name":"time_source","order":25,"path":"scripts/time_source/time_source.yy",},
{"name":"timeline_data","order":18,"path":"scripts/timeline_data/timeline_data.yy",},
{"name":"toggleGroup","order":7,"path":"scripts/toggleGroup/toggleGroup.yy",},
@ -1549,10 +1552,12 @@
{"name":"sh_draw_surface_part_tiled","order":1,"path":"shaders/sh_draw_surface_part_tiled/sh_draw_surface_part_tiled.yy",},
{"name":"sh_draw_surface","order":52,"path":"shaders/sh_draw_surface/sh_draw_surface.yy",},
{"name":"sh_draw_texture","order":5,"path":"shaders/sh_draw_texture/sh_draw_texture.yy",},
{"name":"sh_draw_tile_apply_selection","order":6,"path":"shaders/sh_draw_tile_apply_selection/sh_draw_tile_apply_selection.yy",},
{"name":"sh_draw_tile_apply","order":2,"path":"shaders/sh_draw_tile_apply/sh_draw_tile_apply.yy",},
{"name":"sh_draw_tile_brush","order":3,"path":"shaders/sh_draw_tile_brush/sh_draw_tile_brush.yy",},
{"name":"sh_draw_tile_clear","order":4,"path":"shaders/sh_draw_tile_clear/sh_draw_tile_clear.yy",},
{"name":"sh_draw_tile_map","order":1,"path":"shaders/sh_draw_tile_map/sh_draw_tile_map.yy",},
{"name":"sh_draw_tile_map","order":5,"path":"shaders/sh_draw_tile_map/sh_draw_tile_map.yy",},
{"name":"sh_draw_tile","order":1,"path":"shaders/sh_draw_tile/sh_draw_tile.yy",},
{"name":"sh_edge_detect","order":35,"path":"shaders/sh_edge_detect/sh_edge_detect.yy",},
{"name":"sh_edge_shade_apply","order":2,"path":"shaders/sh_edge_shade_apply/sh_edge_shade_apply.yy",},
{"name":"sh_edge_shade_convert","order":1,"path":"shaders/sh_edge_shade_convert/sh_edge_shade_convert.yy",},

View file

@ -200,6 +200,7 @@
{"$GMFolder":"","%Name":"affector","folderPath":"folders/nodes/data/simulation/VFX/affector.yy","name":"affector","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"generators","folderPath":"folders/nodes/data/simulation/VFX/generators.yy","name":"generators","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"tiler","folderPath":"folders/nodes/data/tiler.yy","name":"tiler","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"shaders","folderPath":"folders/nodes/data/tiler/shaders.yy","name":"shaders","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"tools","folderPath":"folders/nodes/data/tiler/tools.yy","name":"tools","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"transform","folderPath":"folders/nodes/data/transform.yy","name":"transform","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"value","folderPath":"folders/nodes/data/value.yy","name":"value","resourceType":"GMFolder","resourceVersion":"2.0",},
@ -278,7 +279,6 @@
{"$GMFolder":"","%Name":"color_picker","folderPath":"folders/shader/color_picker.yy","name":"color_picker","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"color_selector","folderPath":"folders/shader/color_selector.yy","name":"color_selector","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"draw","folderPath":"folders/shader/draw.yy","name":"draw","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"tiler","folderPath":"folders/shader/draw/tiler.yy","name":"tiler","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"filter","folderPath":"folders/shader/filter.yy","name":"filter","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"blend_edge","folderPath":"folders/shader/filter/blend_edge.yy","name":"blend_edge","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"blur","folderPath":"folders/shader/filter/blur.yy","name":"blur","resourceType":"GMFolder","resourceVersion":"2.0",},
@ -2016,8 +2016,11 @@
{"id":{"name":"texture_set_interpolation","path":"scripts/texture_set_interpolation/texture_set_interpolation.yy",},},
{"id":{"name":"texture_set_repeat","path":"scripts/texture_set_repeat/texture_set_repeat.yy",},},
{"id":{"name":"theme_definition","path":"scripts/theme_definition/theme_definition.yy",},},
{"id":{"name":"tiler_tool_brush_shape","path":"scripts/tiler_tool_brush_shape/tiler_tool_brush_shape.yy",},},
{"id":{"name":"tiler_tool_brush","path":"scripts/tiler_tool_brush/tiler_tool_brush.yy",},},
{"id":{"name":"tiler_tool_fill","path":"scripts/tiler_tool_fill/tiler_tool_fill.yy",},},
{"id":{"name":"tiler_tool_selection_shape","path":"scripts/tiler_tool_selection_shape/tiler_tool_selection_shape.yy",},},
{"id":{"name":"tiler_tool_selection","path":"scripts/tiler_tool_selection/tiler_tool_selection.yy",},},
{"id":{"name":"time_source","path":"scripts/time_source/time_source.yy",},},
{"id":{"name":"timeline_data","path":"scripts/timeline_data/timeline_data.yy",},},
{"id":{"name":"timer_function","path":"scripts/timer_function/timer_function.yy",},},
@ -2211,6 +2214,7 @@
{"id":{"name":"sh_draw_surface_part_tiled","path":"shaders/sh_draw_surface_part_tiled/sh_draw_surface_part_tiled.yy",},},
{"id":{"name":"sh_draw_surface","path":"shaders/sh_draw_surface/sh_draw_surface.yy",},},
{"id":{"name":"sh_draw_texture","path":"shaders/sh_draw_texture/sh_draw_texture.yy",},},
{"id":{"name":"sh_draw_tile_apply_selection","path":"shaders/sh_draw_tile_apply_selection/sh_draw_tile_apply_selection.yy",},},
{"id":{"name":"sh_draw_tile_apply","path":"shaders/sh_draw_tile_apply/sh_draw_tile_apply.yy",},},
{"id":{"name":"sh_draw_tile_brush","path":"shaders/sh_draw_tile_brush/sh_draw_tile_brush.yy",},},
{"id":{"name":"sh_draw_tile_clear","path":"shaders/sh_draw_tile_clear/sh_draw_tile_clear.yy",},},

View file

@ -82,12 +82,19 @@ event_inherited();
for(var i = 0; i < array_length(data); i++) {
var _val = data[i];
var txt = is_instanceof(_val, scrollItem)? _val.name : _val;
var _spr = is_instanceof(_val, scrollItem) && _val.spr;
var _tol = is_instanceof(_val, scrollItem) && _val.tooltip != "";
var _txt = _val, _spr = noone, _tol = false, _act = true, _sub = false;
var clickable = !string_starts_with(txt, "-");
if(!clickable) txt = string_delete(txt, 1, 1);
if(is(_val, scrollItem)) {
_act = _val.active;
_txt = _val.name;
_spr = _val.spr;
_tol = _val.tooltip != "";
} else {
_act = !string_starts_with(_txt, "-");
_sub = string_starts_with(_txt, ">");
_txt = string_trim_start(_txt, ["-", ">", " "]);
}
if(data[i] == -1) {
draw_set_color(CDEF.main_mdblack);
@ -100,7 +107,7 @@ event_inherited();
var _yy = _ly + hght / 2;
if(clickable) {
if(_act) {
if(sc_content.hover && point_in_rectangle(_m[0], _m[1], 0, _ly, _dw, _ly + hght - 1)) {
sc_content.hover_content = true;
selecting = i;
@ -129,17 +136,17 @@ event_inherited();
draw_sprite_ui(THEME.info, 0, tx, ty, .75, .75, 0, COLORS._main_icon, 0.75);
}
if(is_string(txt)) {
draw_set_text(font, align, fa_center, clickable? COLORS._main_text : COLORS._main_text_sub);
if(is_string(_txt)) {
draw_set_text(font, align, fa_center, _act? COLORS._main_text : COLORS._main_text_sub);
if(align == fa_center) {
var _xc = _spr? hght + (_dw - hght) / 2 : _dw / 2;
draw_text_add(_xc, _yy, txt);
draw_text_add(_xc, _yy, _txt);
} else if(align == fa_left)
draw_text_add(text_pad + _spr * hght, _yy, txt);
draw_text_add(text_pad + _spr * hght, _yy, _txt);
} else if(sprite_exists(txt)) {
draw_sprite_ext(txt, i, _dw / 2, _yy);
} else if(sprite_exists(_txt)) {
draw_sprite_ext(_txt, i, _dw / 2, _yy);
}
if(_spr) draw_sprite_ext(_val.spr, _val.spr_ind, ui(8) + hght / 2, _yy, 1, 1, 0, _val.spr_blend, 1);

View file

@ -166,17 +166,23 @@ event_inherited();
continue;
}
var txt = is_instanceof(_val, scrollItem)? _val.name : _val;
var _spr = is_instanceof(_val, scrollItem) && _val.spr;
var _tol = is_instanceof(_val, scrollItem) && _val.tooltip != "";
var _txt = _val, _spr = noone, _tol = false, _act = true, _sub = false;
var clickable = !string_starts_with(txt, "-");
var subitem = string_starts_with(txt, ">");
txt = string_trim_start(txt, ["-", ">", " "]);
if(is(_val, scrollItem)) {
_act = _val.active;
_txt = _val.name;
_spr = _val.spr;
_tol = _val.tooltip != "";
} else {
_act = !string_starts_with(_txt, "-");
_sub = string_starts_with(_txt, ">");
_txt = string_trim_start(_txt, ["-", ">", " "]);
}
var _hov = false;
if(clickable) {
if(_act) {
if(sc_content.hover && point_in_rectangle(_m[0], _m[1], _lx, _ly, _lx + _dw, _ly + hght - 1)) {
sc_content.hover_content = true;
_hov = true;
@ -198,13 +204,13 @@ event_inherited();
align = fa_left;
draw_set_text(font, align, fa_center, subitem? COLORS._main_text_sub : COLORS._main_text);
draw_set_text(font, align, fa_center, _sub? COLORS._main_text_sub : COLORS._main_text);
if(align == fa_center) {
var _xc = _spr? hght + (_dw - hght) / 2 : _dw / 2;
draw_text_add(_lx + _xc, _ly + hght / 2, txt);
draw_text_add(_lx + _xc, _ly + hght / 2, _txt);
} else if(align == fa_left)
draw_text_add(_tpad + _lx + _spr * (_tpad * 2 + hght), _ly + hght / 2, txt);
draw_text_add(_tpad + _lx + _spr * (_tpad * 2 + hght), _ly + hght / 2, _txt);
if(_spr) draw_sprite_ext(_val.spr, _val.spr_ind, _lx + ui(8) + hght / 2, _ly + hght / 2, 1, 1, 0, _val.spr_blend, 1);

View file

@ -3,9 +3,9 @@ function tiler_brush(node) constructor {
brush_indices = [[]];
brush_width = 0;
brush_height = 0;
brush_surface = noone;
brush_erase = false;
autotiler = noone;
brush_sizing = false;
brush_sizing_s = 0;
@ -120,3 +120,101 @@ function tiler_draw_line_brush(brush, _x0, _y0, _x1, _y1) {
BLEND_NORMAL
shader_reset();
}
function tiler_draw_rect_brush(brush, _x0, _y0, _x1, _y1, _fill) {
if(_x0 == _x1 && _y0 == _y1) {
tiler_draw_point_brush(brush, _x0, _y0);
return;
} else if(_x0 == _x1) {
tiler_draw_point_brush(brush, _x0, _y0);
tiler_draw_point_brush(brush, _x1, _y1);
tiler_draw_line_brush(brush, _x0, _y0, _x0, _y1);
return;
} else if(_y0 == _y1) {
tiler_draw_point_brush(brush, _x0, _y0);
tiler_draw_point_brush(brush, _x1, _y1);
tiler_draw_line_brush(brush, _x0, _y0, _x1, _y0);
return;
}
var _min_x = min(_x0, _x1);
var _max_x = max(_x0, _x1);
var _min_y = min(_y0, _y1);
var _may_y = max(_y0, _y1);
if(_fill) draw_rectangle(_min_x, _min_y, _max_x, _may_y, 0);
if(brush.brush_size == 1 && !is_surface(brush.brush_surface))
draw_rectangle(_min_x + 1, _min_y + 1, _max_x - 1, _may_y - 1, 1);
else {
tiler_draw_line_brush(brush, _min_x, _min_y, _max_x, _min_y);
tiler_draw_line_brush(brush, _min_x, _min_y, _min_x, _may_y);
tiler_draw_line_brush(brush, _max_x, _may_y, _max_x, _min_y);
tiler_draw_line_brush(brush, _max_x, _may_y, _min_x, _may_y);
}
}
function tiler_draw_ellp_brush(brush, _x0, _y0, _x1, _y1, _fill) {
if(_x0 == _x1 && _y0 == _y1) {
tiler_draw_point_brush(brush, _x0, _y0);
return;
} else if(_x0 == _x1) {
tiler_draw_point_brush(brush, _x0, _y0);
tiler_draw_point_brush(brush, _x1, _y1);
tiler_draw_line_brush(brush, _x0, _y0, _x0, _y1);
return;
} else if(_y0 == _y1) {
tiler_draw_point_brush(brush, _x0, _y0);
tiler_draw_point_brush(brush, _x1, _y1);
tiler_draw_line_brush(brush, _x0, _y0, _x1, _y0);
return;
}
draw_set_circle_precision(64);
var _min_x = min(_x0, _x1) - 0.5;
var _max_x = max(_x0, _x1) - 0.5;
var _min_y = min(_y0, _y1) - 0.5;
var _max_y = max(_y0, _y1) - 0.5;
if(!is_surface(brush.brush_surface)) {
if(_fill) draw_ellipse(_min_x, _min_y, _max_x, _max_y, 0);
if(brush.brush_size == 1) {
draw_ellipse(_min_x, _min_y, _max_x, _max_y, 1);
} else if(brush.brush_size < global.FIX_POINTS_AMOUNT) {
var fx = global.FIX_POINTS[brush.brush_size];
for( var i = 0, n = array_length(fx); i < n; i++ )
draw_ellipse(_min_x + fx[i][0], _min_y + fx[i][1], _max_x + fx[i][0], _max_y + fx[i][1], 1);
} else {
draw_ellipse(_min_x, _min_y, _max_x, _max_y, brush.brush_size);
}
return;
}
if(_fill) draw_ellipse(_min_x, _min_y, _max_x, _max_y, 0);
var samp = 64;
var cx = (_min_x + _max_x) / 2;
var cy = (_min_y + _max_y) / 2;
var rx = abs(_x0 - _x1) / 2;
var ry = abs(_y0 - _y1) / 2;
var ox, oy, nx, ny;
for( var i = 0; i <= samp; i++ ) {
nx = round(cx + lengthdir_x(rx, 360 / samp * i));
ny = round(cy + lengthdir_y(ry, 360 / samp * i));
if(i) tiler_draw_line_brush(brush, ox, oy, nx, ny);
ox = nx;
oy = ny;
}
}

View file

@ -1,18 +1,18 @@
#region attribute
global.SURFACE_INTERPOLATION = [
"-Group",
"Pixel",
"Bilinear",
"Bicubic",
"radSin"
new scrollItem("Group").setTooltip("Inherit from parent group.").setActive(false),
new scrollItem("Pixel"),
new scrollItem("Bilinear"),
new scrollItem("Bicubic"),
new scrollItem("radSin"),
];
global.SURFACE_OVERSAMPLE = [
"-Group",
"Empty",
"Clamp",
"Repeat",
"Black"
new scrollItem("Group").setTooltip("Inherit from parent group.").setActive(false),
new scrollItem("Empty"),
new scrollItem("Clamp"),
new scrollItem("Repeat"),
new scrollItem("Black"),
];
function __initSurfaceFormat() {
@ -29,15 +29,15 @@
];
var surface_format_name = [
"-Input",
"-Group",
"4 bit RGBA",
"8 bit RGBA",
"16 bit RGBA",
"32 bit RGBA",
"8 bit Greyscale",
"16 bit Greyscale",
"32 bit Greyscale"
new scrollItem("Input" ).setTooltip("Inherit from input surface.").setActive(false),
new scrollItem("Group" ).setTooltip("Inherit from parent group.").setActive(false),
new scrollItem("4 bit RGBA" ).setTooltip("Normalized 4 bit, 4 channels RGBA"),
new scrollItem("8 bit RGBA" ).setTooltip("Normalized 8 bit, 4 channels RGBA"),
new scrollItem("16 bit RGBA" ).setTooltip("16 bit float, 4 channels RGBA"),
new scrollItem("32 bit RGBA" ).setTooltip("32 bit float, 4 channels RGBA"),
new scrollItem("8 bit Greyscale" ).setTooltip("Normalized 8 bit, single channel"),
new scrollItem("16 bit Greyscale").setTooltip("16 bit float, single channel"),
new scrollItem("32 bit Greyscale").setTooltip("32 bit float, single channel"),
];
global.SURFACE_FORMAT = [];
@ -48,9 +48,12 @@
var _supp = _form < 0 || surface_format_is_supported(_form);
array_push(global.SURFACE_FORMAT, _form);
array_push(global.SURFACE_FORMAT_NAME, (_supp? "" : "-") + surface_format_name[i]);
array_push(global.SURFACE_FORMAT_NAME, surface_format_name[i]);
if(!_supp) log_message("WARNING", $"Surface format [{surface_format_name[i]}] not supported in this device.");
if(!_supp) {
log_message("WARNING", $"Surface format [{surface_format_name[i].name}] not supported in this device.");
surface_format_name[i].setActive(false);
}
}
}
@ -71,10 +74,8 @@
}
function attribute_surface_depth(label = true) {
attr_depth_array = array_clone(global.SURFACE_FORMAT_NAME);
if(!array_empty(inputs) && inputs[0].type == VALUE_TYPE.surface)
attr_depth_array[0] = "Input";
attr_depth_array = variable_clone(global.SURFACE_FORMAT_NAME);
attr_depth_array[0].setActive(!array_empty(inputs) && inputs[0].type == VALUE_TYPE.surface);
attributes.color_depth = 3;
if(label) array_push(attributeEditors, "Surface");
@ -83,7 +84,7 @@
}
function attribute_interpolation(label = false) {
attr_interpolate_array = array_clone(global.SURFACE_INTERPOLATION);
attr_interpolate_array = variable_clone(global.SURFACE_INTERPOLATION);
attributes.interpolate = 1;
attributes.oversample = 1;
@ -93,7 +94,7 @@
}
function attribute_oversample(label = false) {
attr_oversample_array = array_clone(global.SURFACE_OVERSAMPLE);
attr_oversample_array = variable_clone(global.SURFACE_OVERSAMPLE);
attributes.interpolate = 1;
attributes.oversample = 1;

View file

@ -2699,46 +2699,26 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
static checkGroup = function() {
if(group == noone) {
for( var i = 0, n = array_length(attributeEditors); i < n; i++ ) {
var _att = attributeEditors[i];
if(!is_array(_att)) continue;
var _wid = _att[2];
if(!is(_wid, scrollBox)) continue;
if(is(_wid, scrollBox)) {
var _key = array_safe_get(_att, 3, "");
var _l = _wid.data_list;
var _lin = array_get_index(_l, "Group");
if(_lin != -1) {
_wid.data_list[_lin] = "-Group";
for( var j = 0, m = array_length(_l); j < m; j++ ) {
var _scl = _l[j];
if(!is(_scl, scrollItem)) continue;
if(_scl.name != "Group") continue;
var _key = _att[3];
if(attributes[$ _key] == _lin)
attributes[$ _key] = _att[0] == "Color depth"? 3 : 1;
_scl.active = group != noone;
if(!_scl.active && attributes[$ _key] == j) attributes[$ _key] = _att[0] == "Color depth"? 3 : 1;
break;
}
}
}
} else {
for( var i = 0, n = array_length(attributeEditors); i < n; i++ ) {
var _att = attributeEditors[i];
if(!is_array(_att)) continue;
var _wid = _att[2];
if(is(_wid, scrollBox)) {
var _l = _wid.data_list;
var _lin = array_get_index(_l, "-Group");
if(_lin != -1) {
_wid.data_list[_lin] = "Group";
}
}
}
}
} run_in(1, function() /*=>*/ { checkGroup(); });

View file

@ -30,7 +30,7 @@ function Node_Region_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
input_display_list = [ 4,
["Surfaces", false], 0, 1,
["Regions Filter", false, 11], 5, 6,
["Region Filter", false, 11], 5, 6,
["Fill", false], 8, 2, 9, 10,
["Render", false], 7,
];
@ -169,7 +169,7 @@ function Node_Region_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
case 0 : // Random colors
shader_set(sh_region_fill_color);
shader_set_palette(_colr, "color", "colorAmount");
shader_set_palette(_colr, "colors", "colorAmount");
shader_set_f("seed", _seed);
draw_surface_safe(cmap);

View file

@ -1,3 +1,7 @@
enum AUTOTILE_TYPE {
box3_3,
}
function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Tile Drawer";
bypass_grid = true;
@ -100,6 +104,8 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
draw_set_color(COLORS.panel_preview_surface_outline);
draw_rectangle(tile_selector_x, tile_selector_y, tile_selector_x + _tdim[0] * tile_selector_s - 1, tile_selector_y + _tdim[1] * tile_selector_s - 1, true);
draw_set_color(c_white);
draw_rectangle_width(_tileHov_x - 1, _tileHov_y - 1, _tileHov_x + _tileSel_w, _tileHov_y + _tileSel_h, 1);
draw_set_color(c_black);
draw_rectangle_width(_tileHov_x, _tileHov_y, _tileHov_x + _tileSel_w - 1, _tileHov_y + _tileSel_h - 1, 1);
@ -204,10 +210,32 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
});
#endregion
#region ++++ auto tile ++++
autotiles = [
{
type: AUTOTILE_TYPE.box3_3,
indexes: [
0, 1, 2,
3, 4, 5,
6, 7, 8,
],
}
];
autotile_selecting = noone;
autotile_selector = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus, _panel = noone) {
var _hh = 0;
return _hh;
});
#endregion
input_display_list = [
["Tileset", false], 0, 2,
["Map", false], 1,
["Tiles", false], tile_selector,
["Autotiles",false], autotile_selector,
]
newOutput(0, nodeValue_Output("Tile output", self, VALUE_TYPE.surface, noone));
@ -233,6 +261,16 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
attributes.dimension = [ 1, 1 ];
temp_surface = [ 0 ];
selection_mask = noone;
#endregion
#region ++++ selection ++++
selecting = false;
selection_x = 0;
selection_y = 0;
selection_mask = noone;
#endregion
#region ++++ tool object ++++
@ -241,6 +279,9 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
tool_brush = new tiler_tool_brush(self, brush, false);
tool_eraser = new tiler_tool_brush(self, brush, true);
tool_fill = new tiler_tool_fill( self, brush, tool_attribute);
tool_rectangle = new tiler_tool_shape(self, brush, CANVAS_TOOL_SHAPE.rectangle);
tool_ellipse = new tiler_tool_shape(self, brush, CANVAS_TOOL_SHAPE.ellipse);
#endregion
#region ++++ tools ++++
@ -266,6 +307,14 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
.setSetting(tool_size)
.setToolObject(tool_eraser),
new NodeTool( "Rectangle", [ THEME.canvas_tools_rect, THEME.canvas_tools_rect_fill ])
.setSetting(tool_size)
.setToolObject(tool_rectangle),
new NodeTool( "Ellipse", [ THEME.canvas_tools_ellip, THEME.canvas_tools_ellip_fill ])
.setSetting(tool_size)
.setToolObject(tool_ellipse),
new NodeTool( "Fill", THEME.canvas_tools_bucket)
.setSetting(tool_fil8)
.setToolObject(tool_fill),
@ -276,10 +325,18 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
if(!is_surface(canvas_surface)) return;
if(!is_surface(drawing_surface)) return;
surface_set_shader(canvas_surface, noone, true, BLEND.over);
if(selecting) {
surface_set_shader(canvas_surface, sh_draw_tile_apply_selection, true, BLEND.over);
shader_set_surface("selectionMask", selection_mask);
draw_surface(drawing_surface, 0, 0);
surface_reset_shader();
} else {
surface_set_shader(canvas_surface, sh_draw_tile_apply, true, BLEND.over);
draw_surface(drawing_surface, 0, 0);
surface_reset_shader();
}
triggerRender();
}
@ -318,6 +375,7 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
var _tool = _currTool == noone? noone : _currTool.getToolObject();
brush.brush_size = tool_attribute.size;
brush.autotiler = autotile_selecting == noone? noone : autotiles[autotile_selecting];
if(_tool) {
_tool.subtool = _currTool.selecting;
@ -329,12 +387,12 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
surface_set_target(preview_draw_overlay);
DRAW_CLEAR
_tool.drawPreview();
_tool.drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
surface_reset_target();
surface_set_target(_preview_draw_mask);
DRAW_CLEAR
_tool.drawMask();
_tool.drawMask(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
surface_reset_target();
surface_set_target(preview_draw_mask);

View file

@ -6,8 +6,10 @@ function scrollItem(name, spr = noone, spr_ind = 0, spr_blend = COLORS._main_ico
self.spr_ind = spr_ind;
self.spr_blend = spr_blend;
active = true;
tooltip = "";
static setActive = function(_ac) { active = _ac; return self; }
static setTooltip = function(_tt) { tooltip = _tt; return self; }
}

View file

@ -0,0 +1,69 @@
function tiler_tool_shape(node, _brush, _shape) : tiler_tool(node) constructor {
self.brush = _brush;
self.shape = _shape;
brush_resizable = true;
mouse_holding = false;
mouse_cur_x = 0;
mouse_cur_y = 0;
mouse_pre_x = 0;
mouse_pre_y = 0;
function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
mouse_cur_x = floor(round((_mx - _x) / _s - 0.5) / tile_size[0]);
mouse_cur_y = floor(round((_my - _y) / _s - 0.5) / tile_size[1]);
if(mouse_holding && key_mod_press(SHIFT)) {
var ww = mouse_cur_x - mouse_pre_x;
var hh = mouse_cur_y - mouse_pre_y;
var ss = max(abs(ww), abs(hh));
mouse_cur_x = mouse_pre_x + ss * sign(ww);
mouse_cur_y = mouse_pre_y + ss * sign(hh);
}
if(mouse_holding) {
surface_set_shader(drawing_surface, noone);
switch(shape) {
case CANVAS_TOOL_SHAPE.rectangle : tiler_draw_rect_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); break;
case CANVAS_TOOL_SHAPE.ellipse : tiler_draw_ellp_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); break;
}
surface_reset_shader();
if(mouse_release(mb_left)) {
apply_draw_surface();
mouse_holding = false;
}
} else if(mouse_press(mb_left, active)) {
mouse_pre_x = mouse_cur_x;
mouse_pre_y = mouse_cur_y;
mouse_holding = true;
node.tool_pick_color(mouse_cur_x, mouse_cur_y);
}
}
function drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
if(!mouse_holding) {
tiler_draw_point_brush(brush, mouse_cur_x, mouse_cur_y);
return;
}
switch(shape) {
case CANVAS_TOOL_SHAPE.rectangle : tiler_draw_rect_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); break;
case CANVAS_TOOL_SHAPE.ellipse : tiler_draw_ellp_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); break;
}
}
static drawMask = function() {
draw_set_color(c_white);
tiler_draw_point_brush(brush, mouse_cur_x, mouse_cur_y);
}
}

View file

@ -0,0 +1,13 @@
{
"$GMScript":"v1",
"%Name":"tiler_tool_brush_shape",
"isCompatibility":false,
"isDnD":false,
"name":"tiler_tool_brush_shape",
"parent":{
"name":"tools",
"path":"folders/nodes/data/tiler/tools.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",
}

View file

@ -0,0 +1,3 @@
function tiler_tool_selection(node) : tiler_tool(node) constructor {
}

View file

@ -0,0 +1,13 @@
{
"$GMScript":"v1",
"%Name":"tiler_tool_selection",
"isCompatibility":false,
"isDnD":false,
"name":"tiler_tool_selection",
"parent":{
"name":"tools",
"path":"folders/nodes/data/tiler/tools.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",
}

View file

@ -0,0 +1,3 @@
function tiler_tool_selection_shape(node, _shape) : tiler_tool_selection(node) constructor {
}

View file

@ -0,0 +1,13 @@
{
"$GMScript":"v1",
"%Name":"tiler_tool_selection_shape",
"isCompatibility":false,
"isDnD":false,
"name":"tiler_tool_selection_shape",
"parent":{
"name":"tools",
"path":"folders/nodes/data/tiler/tools.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",
}

View file

@ -3,8 +3,8 @@
"%Name":"sh_draw_tile",
"name":"sh_draw_tile",
"parent":{
"name":"tiler",
"path":"folders/shader/draw/tiler.yy",
"name":"shaders",
"path":"folders/nodes/data/tiler/shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",

View file

@ -1,13 +1,9 @@
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
// uniform sampler2D canvas;
// uniform sampler2D drawing;
void main() {
gl_FragColor = vec4(0.);
// vec4 c = texture2D( canvas, v_vTexcoord );
// vec4 d = texture2D( drawing, v_vTexcoord );
vec4 draw = texture2D( gm_BaseTexture, v_vTexcoord );
// gl_FragColor = d.r > 0.? d : c;
if(draw.r < 0.) discard;
gl_FragColor = draw;
}

View file

@ -3,8 +3,8 @@
"%Name":"sh_draw_tile_apply",
"name":"sh_draw_tile_apply",
"parent":{
"name":"tiler",
"path":"folders/shader/draw/tiler.yy",
"name":"shaders",
"path":"folders/nodes/data/tiler/shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",

View file

@ -0,0 +1,14 @@
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform sampler2D selectionMask;
void main() {
vec4 draw = texture2D( gm_BaseTexture, v_vTexcoord );
vec4 mask = texture2D( selectionMask, v_vTexcoord );
if(mask.r == 0.) discard;
if(draw.r < 0.) discard;
gl_FragColor = draw;
}

View file

@ -0,0 +1,19 @@
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}

View file

@ -0,0 +1,12 @@
{
"$GMShader":"",
"%Name":"sh_draw_tile_apply_selection",
"name":"sh_draw_tile_apply_selection",
"parent":{
"name":"shaders",
"path":"folders/nodes/data/tiler/shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"type":1,
}

View file

@ -3,8 +3,8 @@
"%Name":"sh_draw_tile_brush",
"name":"sh_draw_tile_brush",
"parent":{
"name":"tiler",
"path":"folders/shader/draw/tiler.yy",
"name":"shaders",
"path":"folders/nodes/data/tiler/shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",

View file

@ -3,8 +3,8 @@
"%Name":"sh_draw_tile_clear",
"name":"sh_draw_tile_clear",
"parent":{
"name":"tiler",
"path":"folders/shader/draw/tiler.yy",
"name":"shaders",
"path":"folders/nodes/data/tiler/shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",

View file

@ -3,8 +3,8 @@
"%Name":"sh_draw_tile_map",
"name":"sh_draw_tile_map",
"parent":{
"name":"tiler",
"path":"folders/shader/draw/tiler.yy",
"name":"shaders",
"path":"folders/nodes/data/tiler/shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",

View file

@ -1,6 +1,3 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
@ -9,8 +6,9 @@ varying vec4 v_vColour;
#else
#define PALETTE_LIMIT 256
#endif
uniform vec4 colors[PALETTE_LIMIT];
uniform float colorAmount;
uniform int colorAmount;
uniform float seed;
float random (in vec2 st) { return fract(sin(dot(st.xy + seed / 100., vec2(12.9898, 78.233))) * 43758.5453123); }
@ -21,6 +19,6 @@ void main() {
if(c.rgb == vec3(0.)) return;
int ind = int(floor(random(gl_FragColor.xy) * colorAmount));
int ind = int(floor(random(gl_FragColor.xy) * float(colorAmount)));
gl_FragColor = colors[ind];
}