From 200ff704c12f3a2f34ee8490f93ecc2731c98510 Mon Sep 17 00:00:00 2001 From: MakhamDev Date: Sun, 16 Jan 2022 20:28:57 +0700 Subject: [PATCH] render timing, particle, shape sep improvement --- .../o_dialog_add_multiple_images/Draw_64.gml | 1 + objects/o_dialog_drag_folder/Draw_64.gml | 2 +- .../o_dialog_image_array_edit/Create_0.gml | 2 +- objects/o_dialog_preference/Create_0.gml | 9 +++ objects/o_main/Create_0.gml | 1 + scripts/node_3D_obj/node_3D_obj.gml | 2 +- scripts/node_canvas/node_canvas.gml | 2 +- .../node_checkerboard/node_checkerboard.gml | 2 +- scripts/node_collection/node_collection.gml | 2 + scripts/node_composite/node_composite.gml | 2 +- scripts/node_data/node_data.gml | 78 +++++++++++++++---- scripts/node_gradient/node_gradient.gml | 2 +- scripts/node_grid/node_grid.gml | 2 +- scripts/node_image/node_image.gml | 6 +- .../node_image_animated.gml | 6 +- scripts/node_image_gif/node_image_gif.gml | 8 +- .../node_image_sequence.gml | 6 +- scripts/node_image_sheet/node_image_sheet.gml | 2 +- scripts/node_line/node_line.gml | 2 +- scripts/node_noise_ani/node_noise_ani.gml | 2 +- scripts/node_noise_cell/node_noise_cell.gml | 2 +- scripts/node_noise_grid/node_noise_grid.gml | 2 +- scripts/node_particle/node_particle.gml | 8 +- .../node_particle_effector.gml | 2 +- scripts/node_path/node_path.gml | 2 +- scripts/node_perlin/node_perlin.gml | 2 +- .../node_perlin_smear/node_perlin_smear.gml | 2 +- scripts/node_pin/node_pin.gml | 2 +- .../node_seperate_shapes.gml | 72 +++++++++-------- .../node_simple_shape/node_simple_shape.gml | 2 +- scripts/node_solid/node_solid.gml | 2 +- scripts/node_stripe/node_stripe.gml | 2 +- .../node_surface_data/node_surface_data.gml | 4 +- scripts/node_wrap_mesh/node_wrap_mesh.gml | 2 +- scripts/node_zigzag/node_zigzag.gml | 2 +- scripts/panel_graph/panel_graph.gml | 4 + scripts/preferences/preferences.gml | 1 + scripts/render_data/render_data.gml | 6 +- scripts/save_load/save_load.gml | 2 +- .../sh_seperate_shape_counter.fsh | 9 ++- .../sh_seperate_shape_index.fsh | 2 +- .../sh_seperate_shape_ite.fsh | 25 +++--- .../sh_seperate_shape_sep.fsh | 4 +- 43 files changed, 189 insertions(+), 111 deletions(-) diff --git a/objects/o_dialog_add_multiple_images/Draw_64.gml b/objects/o_dialog_add_multiple_images/Draw_64.gml index 3a2556511..ad990a5e2 100644 --- a/objects/o_dialog_add_multiple_images/Draw_64.gml +++ b/objects/o_dialog_add_multiple_images/Draw_64.gml @@ -21,6 +21,7 @@ if !ready exit; var xx = dialog_x + 16 + 16 + i * (grid_size + grid_space); var yy = dialog_y + 44 + 16; + PANEL_GRAPH.stepBegin(); var nx = PANEL_GRAPH.mouse_grid_x; var ny = PANEL_GRAPH.mouse_grid_y; diff --git a/objects/o_dialog_drag_folder/Draw_64.gml b/objects/o_dialog_drag_folder/Draw_64.gml index 9779a6829..739a9355d 100644 --- a/objects/o_dialog_drag_folder/Draw_64.gml +++ b/objects/o_dialog_drag_folder/Draw_64.gml @@ -35,7 +35,7 @@ if !ready exit; if(target) { var paths = paths_to_array(dir_paths, dir_recursive, dir_filter); target.updatePaths(paths); - target.update(); + target.doUpdate(); } instance_destroy(); } diff --git a/objects/o_dialog_image_array_edit/Create_0.gml b/objects/o_dialog_image_array_edit/Create_0.gml index 69eeec12d..4c436fbde 100644 --- a/objects/o_dialog_image_array_edit/Create_0.gml +++ b/objects/o_dialog_image_array_edit/Create_0.gml @@ -114,7 +114,7 @@ event_inherited(); array_delete(arr, dragging, 1); array_insert(arr, dragging < inb_hover? inb_hover - 1 : inb_hover, val); target.inputs[| 0].setValue(arr); - target.update(); + target.doUpdate(); dragging = -1; } } diff --git a/objects/o_dialog_preference/Create_0.gml b/objects/o_dialog_preference/Create_0.gml index 495e5b950..b8fe9fb01 100644 --- a/objects/o_dialog_preference/Create_0.gml +++ b/objects/o_dialog_preference/Create_0.gml @@ -85,6 +85,15 @@ event_inherited(); }) ]); + ds_list_add(pref_global, [ + "Show node render time", + "node_show_time", + new checkBox(function() { + PREF_MAP[? "node_show_time"] = !PREF_MAP[? "node_show_time"]; + PREF_SAVE(); + }) + ]); + //NODE ds_list_add(pref_node, [ diff --git a/objects/o_main/Create_0.gml b/objects/o_main/Create_0.gml index ba9c36843..958d43e48 100644 --- a/objects/o_main/Create_0.gml +++ b/objects/o_main/Create_0.gml @@ -80,6 +80,7 @@ display_reset(0, 1); setPath(path); } } else { + PANEL_GRAPH.stepBegin(); var ext = filename_ext(path); switch(ext) { diff --git a/scripts/node_3D_obj/node_3D_obj.gml b/scripts/node_3D_obj/node_3D_obj.gml index 4e08c4b7a..63db9ed87 100644 --- a/scripts/node_3D_obj/node_3D_obj.gml +++ b/scripts/node_3D_obj/node_3D_obj.gml @@ -13,7 +13,7 @@ function Node_3D_Obj(_x, _y) : Node(_x, _y) constructor { inputs[| 1] = nodeValue(1, "Generate", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) .setDisplay(VALUE_DISPLAY.button, [ function() { updateObj(); - update(); + doUpdate(); }, "Generate"] ); inputs[| 2] = nodeValue(2, "Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, def_surf_size2, VALUE_TAG.dimension_2d) diff --git a/scripts/node_canvas/node_canvas.gml b/scripts/node_canvas/node_canvas.gml index e7e6996f6..7c643f378 100644 --- a/scripts/node_canvas/node_canvas.gml +++ b/scripts/node_canvas/node_canvas.gml @@ -521,7 +521,7 @@ function Node_Canvas(_x, _y) : Node(_x, _y) constructor { } else surface_size_to(_outSurf, surface_valid(_dim[0]), surface_valid(_dim[1])); } - update(); + doUpdate(); static doSerialize = function(_map) { _map[? "surface"] = buffer_base64_encode(surface_buffer, 0, buffer_get_size(surface_buffer)); diff --git a/scripts/node_checkerboard/node_checkerboard.gml b/scripts/node_checkerboard/node_checkerboard.gml index 2c6a55b64..32077acee 100644 --- a/scripts/node_checkerboard/node_checkerboard.gml +++ b/scripts/node_checkerboard/node_checkerboard.gml @@ -41,5 +41,5 @@ function Node_Checker(_x, _y) : Node(_x, _y) constructor { shader_reset(); surface_reset_target(); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_collection/node_collection.gml b/scripts/node_collection/node_collection.gml index d7e2e421d..cd6127ed5 100644 --- a/scripts/node_collection/node_collection.gml +++ b/scripts/node_collection/node_collection.gml @@ -28,8 +28,10 @@ function Node_Collection(_x, _y) : Node(_x, _y) constructor { } function step() { + render_time = 0; for(var i = 0; i < ds_list_size(nodes); i++) { nodes[| i].step(); + render_time += nodes[| i].render_time; } if(PANEL_GRAPH.node_focus == self && FOCUS == PANEL_GRAPH.panel && DOUBLE_CLICK) { diff --git a/scripts/node_composite/node_composite.gml b/scripts/node_composite/node_composite.gml index e2e5bfba2..ca7e665f3 100644 --- a/scripts/node_composite/node_composite.gml +++ b/scripts/node_composite/node_composite.gml @@ -56,7 +56,7 @@ function Node_Composite(_x, _y) : Node_Processor(_x, _y) constructor { .setDisplay(VALUE_DISPLAY.vector) .setVisible(false); - array_push(input_display_list, ["Surface " + string(_s), false], index + 0, index + 1, index + 2, index + 3); + array_push(input_display_list, ["Surface " + string(_s), true], index + 0, index + 1, index + 2, index + 3); } createNewSurface(); diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index cb4390a79..668e3cf0c 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -48,6 +48,7 @@ function Node(_x, _y) constructor { rendered = false; auto_update = true; update_on_frame = false; + render_time = 0; use_cache = false; cached_output = []; @@ -122,8 +123,10 @@ function Node(_x, _y) constructor { static focusStep = function() {} static doUpdate = function() { + var t = get_timer(); update(); rendered = true; + render_time = get_timer() - t; } static onValueUpdate = function(index) {} @@ -156,6 +159,38 @@ function Node(_x, _y) constructor { return point_in_rectangle(_mx, _my, xx, yy, xx + w, yy + h); } + static preDraw = function(_x, _y, _s) { + var yy = y * _s + _y; + + var _in = yy + junction_shift_y * _s; + var amo = input_display_list == -1? ds_list_size(inputs) : max(ds_list_size(inputs), array_length(input_display_list)); + + for(var i = 0; i < amo; i++) { + if(input_display_list == -1) + jun = inputs[| i]; + else { + var jun_list_arr = input_display_list[i]; + if(is_array(jun_list_arr)) continue; + jun = inputs[| input_display_list[i]]; + } + + if(jun.isVisible()) { + jun.y = _in; + _in += 24 * _s; + } + } + + var _in = yy + junction_shift_y * _s; + for(var i = 0; i < ds_list_size(outputs); i++) { + var jun = outputs[| i]; + + if(jun.isVisible()) { + jun.y = _in; + _in += 24 * _s; + } + } + } + static drawNodeBase = function(xx, yy, _s) { draw_sprite_stretched_ext(bg_spr, 0, xx, yy, w * _s, h * _s, color, 0.75); } @@ -180,10 +215,8 @@ function Node(_x, _y) constructor { static drawJunctions = function(_x, _y, _mx, _my, _s) { var ss = max(0.5, _s); var xx = x * _s + _x; - var yy = y * _s + _y; var hover = noone; - var _in = yy + junction_shift_y * _s; var amo = input_display_list == -1? ds_list_size(inputs) : max(ds_list_size(inputs), array_length(input_display_list)); var _show_in = show_input_name; @@ -193,10 +226,8 @@ function Node(_x, _y) constructor { show_input_name = false; show_output_name = false; + var jx = xx; for(var i = 0; i < amo; i++) { - var jx = xx; - var jy = _in; - if(input_display_list == -1) jun = inputs[| i]; else { @@ -205,9 +236,9 @@ function Node(_x, _y) constructor { jun = inputs[| input_display_list[i]]; } + var jy = jun.y; + if(jun.isVisible()) { - jun.y = jy; - if(point_in_rectangle(_mx, _my, jx - 12 * _s, jy - 12 * _s, jx + 12 * _s, jy + 12 * _s) || DEBUG) { _draw_cc = c_white; hover = jun; @@ -222,19 +253,15 @@ function Node(_x, _y) constructor { draw_set_text(f_p1, fa_right, fa_center, _draw_cc); draw_text(jx - 12 * _s, jy, jun.name); } - - _in += 24 * _s; } } - var _in = yy + junction_shift_y * _s; + var jx = xx + w * _s; for(var i = 0; i < ds_list_size(outputs); i++) { - var jx = xx + w * _s; - var jy = _in; var jun = outputs[| i]; if(jun.isVisible()) { - jun.y = jy; + var jy = jun.y; if(point_in_rectangle(_mx, _my, jx - 12 * _s, jy - 12 * _s, jx + 12 * _s, jy + 12 * _s) || DEBUG) { _draw_cc = c_white; @@ -254,8 +281,6 @@ function Node(_x, _y) constructor { draw_set_text(f_p1, fa_left, fa_center, _draw_cc); draw_text(jx + 12 * _s, jy, jun.name); } - - _in += 24 * _s; } } @@ -312,7 +337,28 @@ function Node(_x, _y) constructor { if(_s * w > 48) { draw_set_text(_s >= 1? f_p1 : f_p2, fa_center, fa_top, c_ui_blue_grey); - draw_text(xx + w * _s / 2, yy + h * _s + 4 * _s, string(pw) + " x " + string(ph) + "px"); + var tx = xx + w * _s / 2; + var ty = yy + (h + 4) * _s; + draw_text(round(tx), round(ty), string(pw) + " x " + string(ph) + "px"); + + if(PREF_MAP[? "node_show_time"]) { + ty += string_height("l") + var rt, unit; + if(render_time < 1000) { + rt = round(render_time / 10) * 10; + unit = "us"; + draw_set_color(c_ui_lime); + } else if(render_time < 1000000) { + rt = round(render_time / 1000); + unit = "ms"; + draw_set_color(c_ui_orange); + } else { + rt = round(render_time / 1000000); + unit = "s"; + draw_set_color(c_ui_red); + } + draw_text(round(tx), round(ty), string(rt) + " " + unit); + } } } } diff --git a/scripts/node_gradient/node_gradient.gml b/scripts/node_gradient/node_gradient.gml index 84a709a44..6db376227 100644 --- a/scripts/node_gradient/node_gradient.gml +++ b/scripts/node_gradient/node_gradient.gml @@ -104,5 +104,5 @@ function Node_Gradient(_x, _y) : Node(_x, _y) constructor { shader_reset(); surface_reset_target(); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_grid/node_grid.gml b/scripts/node_grid/node_grid.gml index ae3f6ab3c..fe316c74d 100644 --- a/scripts/node_grid/node_grid.gml +++ b/scripts/node_grid/node_grid.gml @@ -53,5 +53,5 @@ function Node_Grid(_x, _y) : Node(_x, _y) constructor { shader_reset(); surface_reset_target(); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_image/node_image.gml b/scripts/node_image/node_image.gml index b15c02e29..7ec5d19fb 100644 --- a/scripts/node_image/node_image.gml +++ b/scripts/node_image/node_image.gml @@ -7,7 +7,7 @@ function Node_create_Image(_x, _y) { var node = new Node_Image(_x, _y); node.inputs[| 0].setValue(path); - node.update(); + node.doUpdate(); ds_list_add(PANEL_GRAPH.nodes_list, node); return node; @@ -18,7 +18,7 @@ function Node_create_Image_path(_x, _y, path) { var node = new Node_Image(_x, _y); node.inputs[| 0].setValue(path); - node.update(); + node.doUpdate(); ds_list_add(PANEL_GRAPH.nodes_list, node); return node; @@ -46,7 +46,7 @@ function Node_Image(_x, _y) : Node(_x, _y) constructor { on_dragdrop_file = function(path) { if(updatePaths(path)) { - update(); + doUpdate(); return true; } diff --git a/scripts/node_image_animated/node_image_animated.gml b/scripts/node_image_animated/node_image_animated.gml index ea9741d6b..124e50f69 100644 --- a/scripts/node_image_animated/node_image_animated.gml +++ b/scripts/node_image_animated/node_image_animated.gml @@ -8,7 +8,7 @@ function Node_create_Image_Animated(_x, _y) { var node = new Node_Image_Animated(_x, _y); var paths = paths_to_array(path); node.inputs[| 0].setValue(paths); - node.update(); + node.doUpdate(); ds_list_add(PANEL_GRAPH.nodes_list, node); return node; @@ -18,7 +18,7 @@ function Node_create_Image_Animated_path(_x, _y, _path) { var node = new Node_Image_Animated(_x, _y); node.inputs[| 0].setValue(_path); - node.update(); + node.doUpdate(); ds_list_add(PANEL_GRAPH.nodes_list, node); return node; @@ -78,7 +78,7 @@ function Node_Image_Animated(_x, _y) : Node(_x, _y) constructor { var paths = paths_to_array(path); if(updatePaths(paths)) { - update(); + doUpdate(); return true; } diff --git a/scripts/node_image_gif/node_image_gif.gml b/scripts/node_image_gif/node_image_gif.gml index 0a47935a5..003a1d731 100644 --- a/scripts/node_image_gif/node_image_gif.gml +++ b/scripts/node_image_gif/node_image_gif.gml @@ -7,7 +7,7 @@ function Node_create_Image_gif(_x, _y) { var node = new Node_Image_gif(_x, _y); node.inputs[| 0].setValue(path); - node.update(); + node.doUpdate(); ds_list_add(PANEL_GRAPH.nodes_list, node); return node; @@ -18,7 +18,7 @@ function Node_create_Image_gif_path(_x, _y, path) { var node = new Node_Image_gif(_x, _y); node.inputs[| 0].setValue(path); - node.update(); + node.doUpdate(); ds_list_add(PANEL_GRAPH.nodes_list, node); return node; @@ -52,7 +52,7 @@ function Node_Image_gif(_x, _y) : Node(_x, _y) constructor { on_dragdrop_file = function(path) { if(updatePaths(path)) { - update(); + doUpdate(); return true; } @@ -94,7 +94,7 @@ function Node_Image_gif(_x, _y) : Node(_x, _y) constructor { if(loading == 2 && spr_builder != noone) { if(spr_builder.building()) { spr = spr_builder._spr; - update(); + doUpdate(); loading = 0; delete spr_builder; diff --git a/scripts/node_image_sequence/node_image_sequence.gml b/scripts/node_image_sequence/node_image_sequence.gml index 8eab90409..310709f94 100644 --- a/scripts/node_image_sequence/node_image_sequence.gml +++ b/scripts/node_image_sequence/node_image_sequence.gml @@ -8,7 +8,7 @@ function Node_create_Image_Sequence(_x, _y) { var node = new Node_Image_Sequence(_x, _y); var paths = paths_to_array(path); node.inputs[| 0].setValue(paths); - node.update(); + node.doUpdate(); ds_list_add(PANEL_GRAPH.nodes_list, node); return node; @@ -17,7 +17,7 @@ function Node_create_Image_Sequence(_x, _y) { function Node_create_Image_Sequence_path(_x, _y, _path) { var node = new Node_Image_Sequence(_x, _y); node.inputs[| 0].setValue(_path); - node.update(); + node.doUpdate(); ds_list_add(PANEL_GRAPH.nodes_list, node); return node; @@ -82,7 +82,7 @@ function Node_Image_Sequence(_x, _y) : Node(_x, _y) constructor { var paths = paths_to_array(path); if(updatePaths(paths)) { - update(); + doUpdate(); return true; } diff --git a/scripts/node_image_sheet/node_image_sheet.gml b/scripts/node_image_sheet/node_image_sheet.gml index 88e92ded2..1fe7d12de 100644 --- a/scripts/node_image_sheet/node_image_sheet.gml +++ b/scripts/node_image_sheet/node_image_sheet.gml @@ -66,7 +66,7 @@ function Node_Image_Sheet(_x, _y) : Node(_x, _y) constructor { inputs[| 2].setValue(amo); inputs[| 3].setValue(row); - update(); + doUpdate(); }, "Generate"] ); input_display_list = [ diff --git a/scripts/node_line/node_line.gml b/scripts/node_line/node_line.gml index bd989110f..6488f65f0 100644 --- a/scripts/node_line/node_line.gml +++ b/scripts/node_line/node_line.gml @@ -187,5 +187,5 @@ function Node_Line(_x, _y) : Node(_x, _y) constructor { } surface_reset_target(); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_noise_ani/node_noise_ani.gml b/scripts/node_noise_ani/node_noise_ani.gml index 5d5912841..25e8bbc1a 100644 --- a/scripts/node_noise_ani/node_noise_ani.gml +++ b/scripts/node_noise_ani/node_noise_ani.gml @@ -53,5 +53,5 @@ function Node_Noise_Aniso(_x, _y) : Node(_x, _y) constructor { shader_reset(); surface_reset_target(); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_noise_cell/node_noise_cell.gml b/scripts/node_noise_cell/node_noise_cell.gml index fe2e134d5..558211c59 100644 --- a/scripts/node_noise_cell/node_noise_cell.gml +++ b/scripts/node_noise_cell/node_noise_cell.gml @@ -112,5 +112,5 @@ function Node_Cellular(_x, _y) : Node(_x, _y) constructor { shader_reset(); surface_reset_target(); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_noise_grid/node_noise_grid.gml b/scripts/node_noise_grid/node_noise_grid.gml index ff589bc02..8867a857b 100644 --- a/scripts/node_noise_grid/node_noise_grid.gml +++ b/scripts/node_noise_grid/node_noise_grid.gml @@ -61,5 +61,5 @@ function Node_Grid_Noise(_x, _y) : Node(_x, _y) constructor { shader_reset(); surface_reset_target(); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_particle/node_particle.gml b/scripts/node_particle/node_particle.gml index b5858be5a..1675b807f 100644 --- a/scripts/node_particle/node_particle.gml +++ b/scripts/node_particle/node_particle.gml @@ -16,7 +16,7 @@ function __part() constructor { g = 0; wig = 0; - boundary_data = []; + boundary_data = -1; fx = 0; fy = 0; @@ -368,6 +368,8 @@ function Node_Particle(_x, _y) : Node(_x, _y) constructor { var sp = area_get_random_point(_spawn_area, _distrib, _scatter, spawn_index, _spawn_amount); xx = sp[0]; yy = sp[1]; + + parts[| i].boundary_data = -1; } var _lif = random_range(_life[0], _life[1]); @@ -422,7 +424,7 @@ function Node_Particle(_x, _y) : Node(_x, _y) constructor { var jun = outputs[| 1]; for(var j = 0; j < ds_list_size(jun.value_to); j++) { if(jun.value_to[| j].value_from == jun) { - jun.value_to[| j].node.update(); + jun.value_to[| j].node.doUpdate(); } } @@ -536,6 +538,6 @@ function Node_Particle(_x, _y) : Node(_x, _y) constructor { function update() { reset(); } - update(); + doUpdate(); render(); } \ No newline at end of file diff --git a/scripts/node_particle_effector/node_particle_effector.gml b/scripts/node_particle_effector/node_particle_effector.gml index a76b76487..6b2668789 100644 --- a/scripts/node_particle_effector/node_particle_effector.gml +++ b/scripts/node_particle_effector/node_particle_effector.gml @@ -209,7 +209,7 @@ function Node_Particle_Effector(_x, _y) : Node(_x, _y) constructor { var jun = outputs[| 0]; for(var j = 0; j < ds_list_size(jun.value_to); j++) { if(jun.value_to[| j].value_from == jun) { - jun.value_to[| j].node.update(); + jun.value_to[| j].node.doUpdate(); } } diff --git a/scripts/node_path/node_path.gml b/scripts/node_path/node_path.gml index b58daca09..93168867f 100644 --- a/scripts/node_path/node_path.gml +++ b/scripts/node_path/node_path.gml @@ -191,7 +191,7 @@ function Node_Path(_x, _y) : Node(_x, _y) constructor { if(_active && mouse_check_button_pressed(mb_left)) { ds_list_delete(inputs, list_start + anchor_hover); - update(); + doUpdate(); } } else { draw_sprite(s_cursor_path_move, 0, _mx + 16, _my + 16); diff --git a/scripts/node_perlin/node_perlin.gml b/scripts/node_perlin/node_perlin.gml index b496114db..8f6486c40 100644 --- a/scripts/node_perlin/node_perlin.gml +++ b/scripts/node_perlin/node_perlin.gml @@ -55,5 +55,5 @@ function Node_Perlin(_x, _y) : Node(_x, _y) constructor { shader_reset(); surface_reset_target(); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_perlin_smear/node_perlin_smear.gml b/scripts/node_perlin_smear/node_perlin_smear.gml index f3429e5d9..e9fadccf7 100644 --- a/scripts/node_perlin_smear/node_perlin_smear.gml +++ b/scripts/node_perlin_smear/node_perlin_smear.gml @@ -55,5 +55,5 @@ function Node_Perlin_Smear(_x, _y) : Node(_x, _y) constructor { shader_reset(); surface_reset_target(); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_pin/node_pin.gml b/scripts/node_pin/node_pin.gml index f9a38b95a..3781d0b8d 100644 --- a/scripts/node_pin/node_pin.gml +++ b/scripts/node_pin/node_pin.gml @@ -25,5 +25,5 @@ function Node_Pin(_x, _y) : Node(_x, _y) constructor { outputs[| 0].value_from = inputs[| 0].value_from; } } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_seperate_shapes/node_seperate_shapes.gml b/scripts/node_seperate_shapes/node_seperate_shapes.gml index 21e235c7a..ad5b9d298 100644 --- a/scripts/node_seperate_shapes/node_seperate_shapes.gml +++ b/scripts/node_seperate_shapes/node_seperate_shapes.gml @@ -30,11 +30,7 @@ function Node_Seperate_Shape(_x, _y) : Node(_x, _y) constructor { function get_color_buffer(_x, _y, w, h) { buffer_seek(surface_buffer, buffer_seek_start, (w * _y + _x) * 4); var c = buffer_read(surface_buffer, buffer_u32); - var _r = c & 255; - var _g = (c >> 8) & 255; - var _b = (c >> 16) & 255; - - return make_color_rgb(_r, _g, _b); + return c; } _prev_type = -1; @@ -42,6 +38,7 @@ function Node_Seperate_Shape(_x, _y) : Node(_x, _y) constructor { function update() { var _inSurf = inputs[| 0].getValue(); var _out_type = inputs[| 1].getValue(); + var t = current_time; if(!is_surface(_inSurf)) return; @@ -49,8 +46,8 @@ function Node_Seperate_Shape(_x, _y) : Node(_x, _y) constructor { var hh = surface_get_height(_inSurf); for(var i = 0; i < 2; i++) { - if(!is_surface(temp_surf[i])) temp_surf[i] = surface_create(surface_get_width(_inSurf), surface_get_height(_inSurf)); - else surface_size_to(temp_surf[i], surface_get_width(_inSurf), surface_get_height(_inSurf)); + if(!is_surface(temp_surf[i])) temp_surf[i] = surface_create(ww, hh); + else surface_size_to(temp_surf[i], ww, hh); surface_set_target(temp_surf[i]); draw_clear_alpha(0, 0); @@ -64,10 +61,11 @@ function Node_Seperate_Shape(_x, _y) : Node(_x, _y) constructor { shader_reset(); shader_set(sh_seperate_shape_ite); - shader_set_uniform_f_array(uniform_it_dim, [ surface_get_width(_inSurf), surface_get_height(_inSurf) ]); + shader_set_uniform_f_array(uniform_it_dim, [ ww, hh ]); shader_reset(); - var res_index, iteration = surface_get_width(_inSurf) + surface_get_height(_inSurf); + t = get_timer(); + var res_index = 0, iteration = ww + hh; for(var i = 0; i <= iteration; i++) { var bg = i % 2; var fg = (i + 1) % 2; @@ -83,19 +81,23 @@ function Node_Seperate_Shape(_x, _y) : Node(_x, _y) constructor { res_index = bg; } + //show_debug_message("iteration time : " + string(get_timer() - t)); + t = get_timer(); var _pixel_surface = surface_create(PREF_MAP[? "shape_separation_max"], 1); surface_set_target(_pixel_surface); draw_clear_alpha(0, 0); BLEND_ADD shader_set(sh_seperate_shape_counter); texture_set_stage(shader_get_sampler_index(sh_seperate_shape_counter, "surface"), surface_get_texture(temp_surf[res_index])); - shader_set_uniform_f_array(shader_get_uniform(sh_seperate_shape_counter, "dimension"), [ surface_get_width(_inSurf), surface_get_height(_inSurf) ]); + shader_set_uniform_f_array(shader_get_uniform(sh_seperate_shape_counter, "dimension"), [ ww, hh ]); draw_sprite_ext(s_fx_pixel, 0, 0, 0, PREF_MAP[? "shape_separation_max"], 1, 0, c_white, 1); shader_reset(); BLEND_NORMAL surface_reset_target(); + //show_debug_message("count time : " + string(get_timer() - t)); + var px = surface_getpixel(_pixel_surface, 0, 0); if(px > 0) { @@ -119,13 +121,12 @@ function Node_Seperate_Shape(_x, _y) : Node(_x, _y) constructor { } var _boundary = array_create(px); - var _sw = surface_get_width(temp_surf[res_index]); - var _sh = surface_get_height(temp_surf[res_index]); buffer_delete(surface_buffer); - surface_buffer = buffer_create(_sw * _sh * 4, buffer_fixed, 2); + surface_buffer = buffer_create(ww * hh * 4, buffer_fixed, 2); buffer_get_surface(surface_buffer, temp_surf[res_index], 0); - + + t = get_timer(); for(var i = 0; i < px; i++) { if(_out_type == 0) { if(i >= ds_list_size(outputs)) { @@ -143,24 +144,31 @@ function Node_Seperate_Shape(_x, _y) : Node(_x, _y) constructor { draw_clear_alpha(0, 0); BLEND_ADD shader_set(sh_seperate_shape_sep); - var cc = surface_getpixel(_pixel_surface, 1 + i, 0); + var ccx = surface_getpixel_ext(_pixel_surface, 1 + i, 0); + var alpha = (ccx >> 24) & 255; + var blue = (ccx >> 16) & 255; + var green = (ccx >> 8) & 255; + var red = ccx & 255; - #region boundary search (brute force) + #region boundary search if(_out_type == 1) { - var t = _sh; - var b = 0; - var l = 0; - var r = _sw; - - for( var j = 0; j < surface_get_width(_inSurf); j++ ) { - for( var k = 0; k < surface_get_height(_inSurf); k++ ) { - var _sc = get_color_buffer(j, k, _sw, _sh); - if(_sc == cc) { - t = min(t, k); - b = max(b, k); - l = max(l, j); - r = min(r, j); - } + var min_x = floor(red / 255 * ww); + var min_y = floor(green / 255 * hh); + var max_x = ceil(blue / 255 * ww); + var max_y = ceil(alpha / 255 * hh); + var t = max_y; + var b = min_y; + var l = max_x; + var r = min_x; + + for( var j = min_x; j < max_x; j++ ) + for( var k = min_y; k < max_y; k++ ) { + var _sc = get_color_buffer(j, k, ww, hh); + if(_sc == ccx) { + t = min(t, k); + b = max(b, k); + l = min(l, j); + r = max(r, j); } } @@ -169,7 +177,7 @@ function Node_Seperate_Shape(_x, _y) : Node(_x, _y) constructor { #endregion texture_set_stage(shader_get_sampler_index(sh_seperate_shape_sep, "original"), surface_get_texture(_inSurf)); - shader_set_uniform_f_array(shader_get_uniform(sh_seperate_shape_sep, "color"), [ color_get_red(cc), color_get_green(cc) ]); + shader_set_uniform_f(shader_get_uniform(sh_seperate_shape_sep, "color"), red, green, blue, alpha); draw_surface_safe(temp_surf[res_index], 0, 0); shader_reset(); BLEND_NORMAL @@ -180,5 +188,7 @@ function Node_Seperate_Shape(_x, _y) : Node(_x, _y) constructor { outputs[| 2].setValue(_boundary); } } + + //show_debug_message("separate time : " + string(get_timer() - t)); } } \ No newline at end of file diff --git a/scripts/node_simple_shape/node_simple_shape.gml b/scripts/node_simple_shape/node_simple_shape.gml index 0939ddd1c..29516dfce 100644 --- a/scripts/node_simple_shape/node_simple_shape.gml +++ b/scripts/node_simple_shape/node_simple_shape.gml @@ -159,5 +159,5 @@ function Node_Shape(_x, _y) : Node_Processor(_x, _y) constructor { shader_reset(); surface_reset_target(); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_solid/node_solid.gml b/scripts/node_solid/node_solid.gml index c3e424178..8f860b112 100644 --- a/scripts/node_solid/node_solid.gml +++ b/scripts/node_solid/node_solid.gml @@ -29,5 +29,5 @@ function Node_Solid(_x, _y) : Node(_x, _y) constructor { draw_clear(_col); surface_reset_target(); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_stripe/node_stripe.gml b/scripts/node_stripe/node_stripe.gml index b0fa58d03..f5fb46180 100644 --- a/scripts/node_stripe/node_stripe.gml +++ b/scripts/node_stripe/node_stripe.gml @@ -46,5 +46,5 @@ function Node_Stripe(_x, _y) : Node(_x, _y) constructor { shader_reset(); surface_reset_target(); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_surface_data/node_surface_data.gml b/scripts/node_surface_data/node_surface_data.gml index d37c05102..c5b24f0af 100644 --- a/scripts/node_surface_data/node_surface_data.gml +++ b/scripts/node_surface_data/node_surface_data.gml @@ -24,7 +24,7 @@ function Node_Surface_data(_x, _y) : Node(_x, _y) constructor { var len = array_length(_insurf); var _dim = array_create(len); - for( var i = 0; i < len; i++ ) { + for( var i = 0; i < len; i++ ) { _dim[i][0] = surface_get_width(_insurf[i]); _dim[i][1] = surface_get_height(_insurf[i]); } @@ -38,5 +38,5 @@ function Node_Surface_data(_x, _y) : Node(_x, _y) constructor { outputs[| 0].setValue([ surface_get_width(_insurf), surface_get_height(_insurf) ]); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/node_wrap_mesh/node_wrap_mesh.gml b/scripts/node_wrap_mesh/node_wrap_mesh.gml index a42296611..ed948d3bc 100644 --- a/scripts/node_wrap_mesh/node_wrap_mesh.gml +++ b/scripts/node_wrap_mesh/node_wrap_mesh.gml @@ -20,7 +20,7 @@ function Node_Mesh_Warp(_x, _y) : Node(_x, _y) constructor { .setDisplay(VALUE_DISPLAY.slider, [ 0, 1, 0.01 ] ); inputs[| 3] = nodeValue(3, "Mesh", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) - .setDisplay(VALUE_DISPLAY.button, [ function() { setTriangle(); update(); }, "Generate"] ); + .setDisplay(VALUE_DISPLAY.button, [ function() { setTriangle(); doUpdate(); }, "Generate"] ); control_index = ds_list_size(inputs); diff --git a/scripts/node_zigzag/node_zigzag.gml b/scripts/node_zigzag/node_zigzag.gml index 30f46bbe0..7ef8f1c5b 100644 --- a/scripts/node_zigzag/node_zigzag.gml +++ b/scripts/node_zigzag/node_zigzag.gml @@ -35,5 +35,5 @@ function Node_Zigzag(_x, _y) : Node(_x, _y) constructor { shader_reset(); surface_reset_target(); } - update(); + doUpdate(); } \ No newline at end of file diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index ad6fa0a04..5ba900965 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -201,6 +201,10 @@ function Panel_Graph(_panel) : PanelContent(_panel) constructor { var gr_x = graph_x * graph_s; var gr_y = graph_y * graph_s; + for(var i = 0; i < ds_list_size(nodes_list); i++) { + nodes_list[| i].preDraw(gr_x, gr_y, graph_s); + } + #region hover node_hovering = noone; for(var i = 0; i < ds_list_size(nodes_list); i++) { diff --git a/scripts/preferences/preferences.gml b/scripts/preferences/preferences.gml index bf565cb70..074a7d1d5 100644 --- a/scripts/preferences/preferences.gml +++ b/scripts/preferences/preferences.gml @@ -27,6 +27,7 @@ PREF_MAP[? "panel_collection"] = true; PREF_MAP[? "node_snapping"] = 32; + PREF_MAP[? "node_show_time"] = true; PREF_MAP[? "shape_separation_max"] = 32; #endregion diff --git a/scripts/render_data/render_data.gml b/scripts/render_data/render_data.gml index 303164208..2f34f1a8c 100644 --- a/scripts/render_data/render_data.gml +++ b/scripts/render_data/render_data.gml @@ -46,7 +46,7 @@ function renderAll() { if(_ready) { if(!rendering.rendered && (LOADING || APPENDING || rendering.auto_update)) - rendering.update(); + rendering.doUpdate(); } else { ds_queue_enqueue(render_q, rendering); } @@ -119,9 +119,9 @@ function renderNodeBackward(_node) { _rendering.rendered = true; if(_rendering.use_cache) { if(!_rendering.recoverCache()) - _rendering.update(); + _rendering.doUpdate(); } else - _rendering.update(); + _rendering.doUpdate(); ds_stack_pop(render_st); } } diff --git a/scripts/save_load/save_load.gml b/scripts/save_load/save_load.gml index d2cbde879..1a7a1c442 100644 --- a/scripts/save_load/save_load.gml +++ b/scripts/save_load/save_load.gml @@ -175,7 +175,7 @@ function LOAD_PATH(path, readonly = false) { var _node = NODE_MAP[? _key]; if(_node.is_dynamic_output) { _node.connect(); - _node.update(); + _node.doUpdate(); } _key = ds_map_find_next(NODE_MAP, _key); diff --git a/shaders/sh_seperate_shape_counter/sh_seperate_shape_counter.fsh b/shaders/sh_seperate_shape_counter/sh_seperate_shape_counter.fsh index b7b7e6d1c..d260adcf5 100644 --- a/shaders/sh_seperate_shape_counter/sh_seperate_shape_counter.fsh +++ b/shaders/sh_seperate_shape_counter/sh_seperate_shape_counter.fsh @@ -8,21 +8,22 @@ uniform vec2 dimension; uniform sampler2D surface; void main() { + vec4 zero = vec4(0.); vec2 pxPos = v_vTexcoord * vec2(32., 1.); int amo = 0; - vec2 list[32]; + vec4 list[32]; for(float i = 0.; i <= dimension.x; i++) for(float j = 0.; j <= dimension.y; j++) { if(amo > 32) break; vec4 col = texture2D( surface, vec2(i, j) / dimension ); - if(col.a > 0.) { + if(col != zero) { bool dup = false; for(int k = 0; k < amo; k++) { - if(col.rg == list[k]) { + if(col == list[k]) { dup = true; break; } @@ -33,7 +34,7 @@ void main() { amo = 999; break; } - list[amo] = col.rg; + list[amo] = col; amo++; } } diff --git a/shaders/sh_seperate_shape_index/sh_seperate_shape_index.fsh b/shaders/sh_seperate_shape_index/sh_seperate_shape_index.fsh index 854d3089c..e0421ac69 100644 --- a/shaders/sh_seperate_shape_index/sh_seperate_shape_index.fsh +++ b/shaders/sh_seperate_shape_index/sh_seperate_shape_index.fsh @@ -8,7 +8,7 @@ void main() { vec4 col = texture2D( gm_BaseTexture, v_vTexcoord ); if(length(col.rgb * col.a) > 0.2) - gl_FragColor = vec4(v_vTexcoord, (col.r + col.g + col.b) / 3., 1.); + gl_FragColor = vec4(v_vTexcoord.x, v_vTexcoord.y, v_vTexcoord.x, v_vTexcoord.y); else gl_FragColor = vec4(0.); } diff --git a/shaders/sh_seperate_shape_ite/sh_seperate_shape_ite.fsh b/shaders/sh_seperate_shape_ite/sh_seperate_shape_ite.fsh index 73750fc08..34d380d47 100644 --- a/shaders/sh_seperate_shape_ite/sh_seperate_shape_ite.fsh +++ b/shaders/sh_seperate_shape_ite/sh_seperate_shape_ite.fsh @@ -7,23 +7,24 @@ varying vec4 v_vColour; uniform vec2 dimension; void main() { - vec2 _index = v_vTexcoord; - + vec4 zero = vec4(0.); vec4 col = texture2D( gm_BaseTexture, v_vTexcoord ); - float bright = dot(col.rgb, vec3(0.2126, 0.7152, 0.0722)); - if(col.a > 0. && bright > 0.) { + if(col != zero) { + vec2 _index_min = v_vTexcoord; + vec2 _index_max = v_vTexcoord; + for(float i = -1.; i <= 1.; i++) for(float j = -1.; j <= 1.; j++) { - vec4 _col = texture2D( gm_BaseTexture, v_vTexcoord + vec2(i, j) / dimension ); - float _bright = dot(_col.rgb, vec3(0.2126, 0.7152, 0.0722)); - if(_col.a > 0. && abs(bright - _bright) < 0.1) { - _index.x = min(_index.x, _col.r); - _index.y = min(_index.y, _col.g); + vec4 _col = texture2D( gm_BaseTexture, clamp(v_vTexcoord + vec2(i, j) / dimension, 0., 1.) ); + if(_col != zero) { + _index_min.x = min(_index_min.x, _col.r); + _index_min.y = min(_index_min.y, _col.g); + + _index_max.x = max(_index_max.x, _col.b); + _index_max.y = max(_index_max.y, _col.a); } } - gl_FragColor = vec4(_index, 1., 1.); - } else { - gl_FragColor = vec4(0.); + gl_FragColor = vec4(_index_min.x, _index_min.y, _index_max.x, _index_max.y ); } } diff --git a/shaders/sh_seperate_shape_sep/sh_seperate_shape_sep.fsh b/shaders/sh_seperate_shape_sep/sh_seperate_shape_sep.fsh index 06e5cea29..45cc8fc8c 100644 --- a/shaders/sh_seperate_shape_sep/sh_seperate_shape_sep.fsh +++ b/shaders/sh_seperate_shape_sep/sh_seperate_shape_sep.fsh @@ -5,12 +5,12 @@ varying vec2 v_vTexcoord; varying vec4 v_vColour; uniform sampler2D original; -uniform vec2 color; +uniform vec4 color; void main() { vec4 col = texture2D( gm_BaseTexture, v_vTexcoord ); - if(distance(col.rg * 255., color) < 1.) { + if(distance(col * 255., color) < 1.) { gl_FragColor = texture2D( original, v_vTexcoord ); } else gl_FragColor = vec4(0.);