diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 876d620ba..93c118460 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -186,6 +186,7 @@ {"name":"sh_noise_grid_hex","order":24,"path":"shaders/sh_noise_grid_hex/sh_noise_grid_hex.yy",}, {"name":"node_3d_obj","order":8,"path":"scripts/node_3d_obj/node_3d_obj.yy",}, {"name":"__path","order":1,"path":"scripts/__path/__path.yy",}, + {"name":"sh_brush_outline","order":7,"path":"shaders/sh_brush_outline/sh_brush_outline.yy",}, {"name":"s_node_grid_tri_noise","order":22,"path":"sprites/s_node_grid_tri_noise/s_node_grid_tri_noise.yy",}, {"name":"o_dialog_menubox","order":1,"path":"objects/o_dialog_menubox/o_dialog_menubox.yy",}, {"name":"s_node_blend","order":7,"path":"sprites/s_node_blend/s_node_blend.yy",}, @@ -247,6 +248,7 @@ {"name":"draw_set_blend_mode_ext","order":2,"path":"scripts/draw_set_blend_mode_ext/draw_set_blend_mode_ext.yy",}, {"name":"s_node_json_parse","order":2,"path":"sprites/s_node_json_parse/s_node_json_parse.yy",}, {"name":"s_node_noise_simplex","order":20,"path":"sprites/s_node_noise_simplex/s_node_noise_simplex.yy",}, + {"name":"s_node_armature_sample","order":18,"path":"sprites/s_node_armature_sample/s_node_armature_sample.yy",}, {"name":"o_dialog_notifications","order":6,"path":"objects/o_dialog_notifications/o_dialog_notifications.yy",}, {"name":"s_node_array_find","order":2,"path":"sprites/s_node_array_find/s_node_array_find.yy",}, {"name":"fd_rectangle_set_velocity_time_step","order":17,"path":"scripts/fd_rectangle_set_velocity_time_step/fd_rectangle_set_velocity_time_step.yy",}, @@ -392,6 +394,7 @@ {"name":"s_node_vfx_wind","order":3,"path":"sprites/s_node_vfx_wind/s_node_vfx_wind.yy",}, {"name":"s_node_rigidSim_global","order":4,"path":"sprites/s_node_rigidSim_global/s_node_rigidSim_global.yy",}, {"name":"sh_channel_G_grey","order":8,"path":"shaders/sh_channel_G_grey/sh_channel_G_grey.yy",}, + {"name":"node_3d_depth","order":32,"path":"scripts/node_3d_depth/node_3d_depth.yy",}, {"name":"s_node_vec4","order":9,"path":"sprites/s_node_vec4/s_node_vec4.yy",}, {"name":"node_to_number","order":13,"path":"scripts/node_to_number/node_to_number.yy",}, {"name":"buttonGroup","order":5,"path":"scripts/buttonGroup/buttonGroup.yy",}, @@ -506,6 +509,7 @@ {"name":"node_string_regex_replace","order":9,"path":"scripts/node_string_regex_replace/node_string_regex_replace.yy",}, {"name":"s_node_particle","order":12,"path":"sprites/s_node_particle/s_node_particle.yy",}, {"name":"s_node_random","order":3,"path":"sprites/s_node_random/s_node_random.yy",}, + {"name":"sh_3d_extrude_filler","order":8,"path":"shaders/sh_3d_extrude_filler/sh_3d_extrude_filler.yy",}, {"name":"s_window_exit","order":2,"path":"sprites/s_window_exit/s_window_exit.yy",}, {"name":"s_node_color_remove","order":7,"path":"sprites/s_node_color_remove/s_node_color_remove.yy",}, {"name":"sh_average","order":7,"path":"shaders/sh_average/sh_average.yy",}, @@ -812,6 +816,7 @@ {"name":"s_node_vfx_spawn","order":2,"path":"sprites/s_node_vfx_spawn/s_node_vfx_spawn.yy",}, {"name":"texture_set_repeat","order":1,"path":"scripts/texture_set_repeat/texture_set_repeat.yy",}, {"name":"fd_rectangle_update_velocity","order":22,"path":"scripts/fd_rectangle_update_velocity/fd_rectangle_update_velocity.yy",}, + {"name":"sh_3d_extrude_filler_depth","order":10,"path":"shaders/sh_3d_extrude_filler_depth/sh_3d_extrude_filler_depth.yy",}, {"name":"sh_draw_mapping","order":4,"path":"shaders/sh_draw_mapping/sh_draw_mapping.yy",}, {"name":"__bbox","order":5,"path":"scripts/__bbox/__bbox.yy",}, {"name":"node_shadow","order":14,"path":"scripts/node_shadow/node_shadow.yy",}, @@ -1074,6 +1079,7 @@ {"name":"s_node_shape_polygon","order":25,"path":"sprites/s_node_shape_polygon/s_node_shape_polygon.yy",}, {"name":"sh_color_picker_hue","order":7,"path":"shaders/sh_color_picker_hue/sh_color_picker_hue.yy",}, {"name":"node_path_eval","order":4,"path":"scripts/node_path_eval/node_path_eval.yy",}, + {"name":"sh_3d_depth","order":7,"path":"shaders/sh_3d_depth/sh_3d_depth.yy",}, {"name":"node_3d_displace","order":18,"path":"scripts/node_3d_displace/node_3d_displace.yy",}, {"name":"node_vector_dot","order":9,"path":"scripts/node_vector_dot/node_vector_dot.yy",}, {"name":"node_path_map_area","order":1,"path":"scripts/node_path_map_area/node_path_map_area.yy",}, @@ -1117,6 +1123,7 @@ {"name":"s_node_ase_file","order":15,"path":"sprites/s_node_ase_file/s_node_ase_file.yy",}, {"name":"draw_line_round","order":4,"path":"scripts/draw_line_round/draw_line_round.yy",}, {"name":"vectorBox","order":18,"path":"scripts/vectorBox/vectorBox.yy",}, + {"name":"sh_3d_extrude_corner","order":9,"path":"shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.yy",}, {"name":"sh_blend_normal_dim","order":10,"path":"shaders/sh_blend_normal_dim/sh_blend_normal_dim.yy",}, {"name":"node_skew","order":11,"path":"scripts/node_skew/node_skew.yy",}, {"name":"s_node_dot_product","order":13,"path":"sprites/s_node_dot_product/s_node_dot_product.yy",}, @@ -1223,6 +1230,7 @@ {"name":"s_node_group_input","order":16,"path":"sprites/s_node_group_input/s_node_group_input.yy",}, {"name":"sample_projects","order":6,"path":"scripts/sample_projects/sample_projects.yy",}, {"name":"draw_fit","order":12,"path":"scripts/draw_fit/draw_fit.yy",}, + {"name":"node_armature_sample","order":5,"path":"scripts/node_armature_sample/node_armature_sample.yy",}, {"name":"s_node_morph_surface","order":56,"path":"sprites/s_node_morph_surface/s_node_morph_surface.yy",}, {"name":"fd_rectangle_get_velocity_dissipation_type","order":20,"path":"scripts/fd_rectangle_get_velocity_dissipation_type/fd_rectangle_get_velocity_dissipation_type.yy",}, {"name":"s_node_3d_transform","order":4,"path":"sprites/s_node_3d_transform/s_node_3d_transform.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 495c8a44e..09548e5bf 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -286,6 +286,7 @@ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_graph.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_group_16.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_group_24.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_hamburger_s.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_hamburger.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_heart.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_icon_accept_24.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, @@ -518,6 +519,7 @@ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_menu_white.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/UI",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_shadow_drop_down_24.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/UI",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_timeline_dopesheet_bg.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/UI",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_tool_side.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/UI",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_toolbar_shadow.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/UI",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_toolbar.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/UI",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_ui_label_bg.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/UI",}, @@ -675,6 +677,7 @@ {"id":{"name":"sh_noise_grid_hex","path":"shaders/sh_noise_grid_hex/sh_noise_grid_hex.yy",},}, {"id":{"name":"node_3d_obj","path":"scripts/node_3d_obj/node_3d_obj.yy",},}, {"id":{"name":"__path","path":"scripts/__path/__path.yy",},}, + {"id":{"name":"sh_brush_outline","path":"shaders/sh_brush_outline/sh_brush_outline.yy",},}, {"id":{"name":"s_node_grid_tri_noise","path":"sprites/s_node_grid_tri_noise/s_node_grid_tri_noise.yy",},}, {"id":{"name":"o_dialog_menubox","path":"objects/o_dialog_menubox/o_dialog_menubox.yy",},}, {"id":{"name":"s_node_blend","path":"sprites/s_node_blend/s_node_blend.yy",},}, @@ -743,6 +746,7 @@ {"id":{"name":"draw_set_blend_mode_ext","path":"scripts/draw_set_blend_mode_ext/draw_set_blend_mode_ext.yy",},}, {"id":{"name":"s_node_json_parse","path":"sprites/s_node_json_parse/s_node_json_parse.yy",},}, {"id":{"name":"s_node_noise_simplex","path":"sprites/s_node_noise_simplex/s_node_noise_simplex.yy",},}, + {"id":{"name":"s_node_armature_sample","path":"sprites/s_node_armature_sample/s_node_armature_sample.yy",},}, {"id":{"name":"o_dialog_notifications","path":"objects/o_dialog_notifications/o_dialog_notifications.yy",},}, {"id":{"name":"s_node_array_find","path":"sprites/s_node_array_find/s_node_array_find.yy",},}, {"id":{"name":"fd_rectangle_set_velocity_time_step","path":"scripts/fd_rectangle_set_velocity_time_step/fd_rectangle_set_velocity_time_step.yy",},}, @@ -915,6 +919,7 @@ {"id":{"name":"s_node_vfx_wind","path":"sprites/s_node_vfx_wind/s_node_vfx_wind.yy",},}, {"id":{"name":"s_node_rigidSim_global","path":"sprites/s_node_rigidSim_global/s_node_rigidSim_global.yy",},}, {"id":{"name":"sh_channel_G_grey","path":"shaders/sh_channel_G_grey/sh_channel_G_grey.yy",},}, + {"id":{"name":"node_3d_depth","path":"scripts/node_3d_depth/node_3d_depth.yy",},}, {"id":{"name":"s_node_vec4","path":"sprites/s_node_vec4/s_node_vec4.yy",},}, {"id":{"name":"node_to_number","path":"scripts/node_to_number/node_to_number.yy",},}, {"id":{"name":"buttonGroup","path":"scripts/buttonGroup/buttonGroup.yy",},}, @@ -1044,6 +1049,7 @@ {"id":{"name":"s_node_particle","path":"sprites/s_node_particle/s_node_particle.yy",},}, {"id":{"name":"sh_flood_fill_thres","path":"shaders/sh_flood_fill_thres/sh_flood_fill_thres.yy",},}, {"id":{"name":"s_node_random","path":"sprites/s_node_random/s_node_random.yy",},}, + {"id":{"name":"sh_3d_extrude_filler","path":"shaders/sh_3d_extrude_filler/sh_3d_extrude_filler.yy",},}, {"id":{"name":"s_window_exit","path":"sprites/s_window_exit/s_window_exit.yy",},}, {"id":{"name":"s_node_color_remove","path":"sprites/s_node_color_remove/s_node_color_remove.yy",},}, {"id":{"name":"sh_average","path":"shaders/sh_average/sh_average.yy",},}, @@ -1387,6 +1393,7 @@ {"id":{"name":"s_node_vfx_spawn","path":"sprites/s_node_vfx_spawn/s_node_vfx_spawn.yy",},}, {"id":{"name":"texture_set_repeat","path":"scripts/texture_set_repeat/texture_set_repeat.yy",},}, {"id":{"name":"fd_rectangle_update_velocity","path":"scripts/fd_rectangle_update_velocity/fd_rectangle_update_velocity.yy",},}, + {"id":{"name":"sh_3d_extrude_filler_depth","path":"shaders/sh_3d_extrude_filler_depth/sh_3d_extrude_filler_depth.yy",},}, {"id":{"name":"sh_draw_mapping","path":"shaders/sh_draw_mapping/sh_draw_mapping.yy",},}, {"id":{"name":"__bbox","path":"scripts/__bbox/__bbox.yy",},}, {"id":{"name":"node_shadow","path":"scripts/node_shadow/node_shadow.yy",},}, @@ -1692,6 +1699,7 @@ {"id":{"name":"s_node_shape_polygon","path":"sprites/s_node_shape_polygon/s_node_shape_polygon.yy",},}, {"id":{"name":"sh_color_picker_hue","path":"shaders/sh_color_picker_hue/sh_color_picker_hue.yy",},}, {"id":{"name":"node_path_eval","path":"scripts/node_path_eval/node_path_eval.yy",},}, + {"id":{"name":"sh_3d_depth","path":"shaders/sh_3d_depth/sh_3d_depth.yy",},}, {"id":{"name":"node_3d_displace","path":"scripts/node_3d_displace/node_3d_displace.yy",},}, {"id":{"name":"node_vector_dot","path":"scripts/node_vector_dot/node_vector_dot.yy",},}, {"id":{"name":"o_dialog_arrayBox","path":"objects/o_dialog_arrayBox/o_dialog_arrayBox.yy",},}, @@ -1743,6 +1751,7 @@ {"id":{"name":"s_node_ase_file","path":"sprites/s_node_ase_file/s_node_ase_file.yy",},}, {"id":{"name":"draw_line_round","path":"scripts/draw_line_round/draw_line_round.yy",},}, {"id":{"name":"vectorBox","path":"scripts/vectorBox/vectorBox.yy",},}, + {"id":{"name":"sh_3d_extrude_corner","path":"shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.yy",},}, {"id":{"name":"sh_blend_normal_dim","path":"shaders/sh_blend_normal_dim/sh_blend_normal_dim.yy",},}, {"id":{"name":"node_skew","path":"scripts/node_skew/node_skew.yy",},}, {"id":{"name":"s_node_dot_product","path":"sprites/s_node_dot_product/s_node_dot_product.yy",},}, @@ -1863,6 +1872,7 @@ {"id":{"name":"sample_projects","path":"scripts/sample_projects/sample_projects.yy",},}, {"id":{"name":"load_function","path":"scripts/load_function/load_function.yy",},}, {"id":{"name":"draw_fit","path":"scripts/draw_fit/draw_fit.yy",},}, + {"id":{"name":"node_armature_sample","path":"scripts/node_armature_sample/node_armature_sample.yy",},}, {"id":{"name":"ds_map","path":"scripts/ds_map/ds_map.yy",},}, {"id":{"name":"s_node_morph_surface","path":"sprites/s_node_morph_surface/s_node_morph_surface.yy",},}, {"id":{"name":"fd_rectangle_get_velocity_dissipation_type","path":"scripts/fd_rectangle_get_velocity_dissipation_type/fd_rectangle_get_velocity_dissipation_type.yy",},}, diff --git a/datafiles/data/themes/default.zip b/datafiles/data/themes/default.zip index 5d46145e5..6ef5df0af 100644 Binary files a/datafiles/data/themes/default.zip and b/datafiles/data/themes/default.zip differ diff --git a/objects/o_dialog_textbox_function_guide/Draw_64.gml b/objects/o_dialog_textbox_function_guide/Draw_64.gml index 68f158bd0..832df705f 100644 --- a/objects/o_dialog_textbox_function_guide/Draw_64.gml +++ b/objects/o_dialog_textbox_function_guide/Draw_64.gml @@ -21,13 +21,20 @@ if(textbox == noone) exit; var cch = ""; var fname = true; var var_ind = 0; + var def_val = false; repeat(amo) { cch = string_char_at(prompt, ind); ind++; if(cch == "(") fname = false; - if(cch == ",") var_ind++; + if(cch == ",") { + def_val = false; + var_ind++; + } + + if(cch == "=") + def_val = true; if(cch == "(" || cch == ")" || cch == "[" || cch == "]" || cch == "{" || cch == "}") draw_set_color(COLORS.lua_highlight_bracklet); @@ -35,8 +42,12 @@ if(textbox == noone) exit; draw_set_color(COLORS._main_text); else if(fname) draw_set_color(COLORS.lua_highlight_function); - else - draw_set_color(var_ind == index? COLORS._main_text : COLORS._main_text_sub); + else { + if(var_ind == index) { + draw_set_color(def_val? COLORS._main_text : COLORS.lua_highlight_number); + } else + draw_set_color(COLORS._main_text_sub); + } draw_text(cx, cy, cch); cx += string_width(cch); diff --git a/objects/o_main/Step_1.gml b/objects/o_main/Step_1.gml index c1fce18e6..79382bc4e 100644 --- a/objects/o_main/Step_1.gml +++ b/objects/o_main/Step_1.gml @@ -1,4 +1,7 @@ /// @description init +global.cache_call = 0; +global.cache_hit = 0; + HOVERING_ELEMENT = _HOVERING_ELEMENT; _HOVERING_ELEMENT = noone; @@ -187,4 +190,6 @@ _HOVERING_ELEMENT = noone; } } MOUSE_WRAP = false; -#endregion \ No newline at end of file +#endregion + +//print($"CACHE called: {global.cache_call} | hit: {global.cache_hit} ({global.cache_hit / global.cache_call}%)"); \ No newline at end of file diff --git a/scripts/__bone/__bone.gml b/scripts/__bone/__bone.gml index 9941e5d65..2bd06bc49 100644 --- a/scripts/__bone/__bone.gml +++ b/scripts/__bone/__bone.gml @@ -77,6 +77,20 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length = return noone; } + static findBoneByName = function(_name) { + //print($"Print {string_length(string_trim(name))} : {string_length(string_trim(_name))}"); + if(string_trim(name) == string_trim(_name)) + return self; + + for( var i = 0; i < array_length(childs); i++ ) { + var b = childs[i].findBoneByName(_name); + if(b != noone) + return b; + } + + return noone; + } + static getPoint = function(progress) { var len = length * progress; @@ -397,6 +411,35 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length = } } + static __getBBOX = function() { + var p0 = getPoint(0); + var p1 = getPoint(1); + + var x0 = min(p0.x, p1.x); + var y0 = min(p0.y, p1.y); + var x1 = max(p0.x, p1.x); + var y1 = max(p0.y, p1.y); + + return [ x0, y0, x1, y1 ]; + } + + static bbox = function() { + var _bbox = __getBBOX(); + //print($"BBOX: {_bbox}") + + for( var i = 0; i < array_length(childs); i++ ) { + var _bbox_ch = childs[i].bbox(); + //print($"BBOX ch: {_bbox_ch}") + + _bbox[0] = min(_bbox[0], _bbox_ch[0]); + _bbox[1] = min(_bbox[1], _bbox_ch[1]); + _bbox[2] = max(_bbox[2], _bbox_ch[2]); + _bbox[3] = max(_bbox[3], _bbox_ch[3]); + } + + return _bbox; + } + static serialize = function() { var bone = {}; diff --git a/scripts/_node_VFX_spawner/_node_VFX_spawner.gml b/scripts/_node_VFX_spawner/_node_VFX_spawner.gml index cdcc1b545..110385de4 100644 --- a/scripts/_node_VFX_spawner/_node_VFX_spawner.gml +++ b/scripts/_node_VFX_spawner/_node_VFX_spawner.gml @@ -112,7 +112,7 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co ]; attributes.part_amount = 512; - array_push(attributeEditors, ["Maximum particles", "part_amount", + array_push(attributeEditors, ["Maximum particles", function() { return attributes.part_amount; }, new textBox(TEXTBOX_INPUT.number, function(val) { attributes.part_amount = val; }) ]); parts = array_create(attributes.part_amount); diff --git a/scripts/color_function/color_function.gml b/scripts/color_function/color_function.gml index db1425f96..0cffd8d75 100644 --- a/scripts/color_function/color_function.gml +++ b/scripts/color_function/color_function.gml @@ -57,7 +57,7 @@ function color_diff(c1, c2, fast = false) { _c2_g = _c2_g / 255 * _c2_a; _c2_b = _c2_b / 255 * _c2_a; - if(fast) return sqr(_c1_r - _c2_r) + sqr(_c1_g - _c2_g) + sqr(_c1_b - _c2_b) + sqr(_c1_a - _c2_a); + if(fast) return abs(_c1_r - _c2_r) + abs(_c1_g - _c2_g) + abs(_c1_b - _c2_b) + abs(_c1_a - _c2_a); return sqrt(sqr(_c1_r - _c2_r) + sqr(_c1_g - _c2_g) + sqr(_c1_b - _c2_b) + sqr(_c1_a - _c2_a)); } diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index a8dbfde47..c0a4df30a 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -59,8 +59,11 @@ globalvar PROJECT_VARIABLES; PROJECT_VARIABLES = ds_map_create(); PROJECT_VARIABLES[? "frame"] = [ function() { return PROJECT.animator.current_frame; }]; + PROJECT_VARIABLES[? "progress"] = [ function() { return PROJECT.animator.current_frame / PROJECT.animator.frames_total; }]; PROJECT_VARIABLES[? "frameTotal"] = [ function() { return PROJECT.animator.frames_total; }]; PROJECT_VARIABLES[? "fps"] = [ function() { return PROJECT.animator.framerate; }]; + PROJECT_VARIABLES[? "time"] = [ function() { return PROJECT.animator.current_frame / PROJECT.animator.framerate; }]; + PROJECT_VARIABLES[? "name"] = [ function() { return filename_name_only(PROJECT.path); }]; #endregion #region main @@ -75,8 +78,8 @@ globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER; VERSION = 1147; - SAVE_VERSION = 1447; - VERSION_STRING = "1.14.6n5"; + SAVE_VERSION = 1448; + VERSION_STRING = "1.14.6n7"; BUILD_NUMBER = 114600; globalvar APPEND_MAP; diff --git a/scripts/histogram_drawer/histogram_drawer.gml b/scripts/histogram_drawer/histogram_drawer.gml index 20e6ebc09..ec95abd4d 100644 --- a/scripts/histogram_drawer/histogram_drawer.gml +++ b/scripts/histogram_drawer/histogram_drawer.gml @@ -1,10 +1,10 @@ function histogramInit() { attributes.preview_resolution = 64; - array_push(attributeEditors, ["Preview resolution", "preview_resolution", + array_push(attributeEditors, ["Preview resolution", function() { return attributes.preview_resolution; }, new textBox(TEXTBOX_INPUT.number, function(val) { attributes.preview_resolution = val; })]); attributes.preview_sample = 32; - array_push(attributeEditors, ["Preview sample", "preview_sample", + array_push(attributeEditors, ["Preview sample", function() { return attributes.preview_sample; }, new textBox(TEXTBOX_INPUT.number, function(val) { attributes.preview_sample = val; })]); for( var i = 0; i < 4; i++ ) { diff --git a/scripts/node_3d_depth/node_3d_depth.gml b/scripts/node_3d_depth/node_3d_depth.gml new file mode 100644 index 000000000..a06d3ce7f --- /dev/null +++ b/scripts/node_3d_depth/node_3d_depth.gml @@ -0,0 +1,68 @@ +function Node_3D_Depth(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { + name = "3D Depth"; + + inputs[| 0] = nodeValue("Base Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); + + inputs[| 1] = nodeValue("Depth", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); + + inputs[| 2] = nodeValue("Rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [0, 0, 0] ) + .setDisplay(VALUE_DISPLAY.vector); + + outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); + + input_display_list = [ + ["Texture", false], 0, 1, + ["Camera", false], 2, + ]; + + attribute_surface_depth(); + attribute_interpolation(); + + static process_data = function(_outSurf, _data, _output_index, _array_index) { + var _tex = _data[0]; + var _dep = _data[1]; + var _rot = _data[2]; + + if(!is_surface(_tex)) return _outSurf; + if(!is_surface(_dep)) return _outSurf; + + var x_rad = degtorad(_rot[0]); + var y_rad = degtorad(_rot[1]); + var z_rad = degtorad(_rot[2]); + + var _cx = cos(y_rad) * cos(z_rad); + var _cy = (sin(x_rad) * sin(y_rad) * cos(z_rad) - cos(x_rad) * sin(z_rad)); + var _cz = (cos(x_rad) * sin(y_rad) * cos(z_rad) + sin(x_rad) * sin(z_rad)); + + var up_x = -sin(x_rad); + var up_y = cos(x_rad); + var up_z = 0; + + var right_x = cos(y_rad) * cos(z_rad); + var right_y = sin(x_rad) * sin(y_rad) * cos(z_rad) - cos(x_rad) * sin(z_rad); + var right_z = cos(x_rad) * sin(y_rad) * cos(z_rad) + sin(x_rad) * sin(z_rad); + + print($"POS: {_cx}, {_cy}, {_cz}"); + print($"UP: {up_x}, {up_y}, {up_z}"); + print($"RIGHT: {right_x}, {right_y}, {right_z}"); + print(""); + + surface_set_shader(_outSurf, sh_3d_depth); + DRAW_CLEAR + + shader_set_surface("texMap", _tex); + shader_set_f("dimension", surface_get_width(_tex), surface_get_height(_tex)); + + shader_set_surface("depthMap", _dep); + shader_set_f("depthDimension", surface_get_width(_dep), surface_get_height(_dep)); + + shader_set_f("cameraPos", _cx, _cy, _cz); + shader_set_f("cameraUp", up_x, up_y, up_z); + shader_set_f("cameraRight", right_x, right_y, right_z); + + draw_sprite_stretched(s_fx_pixel, 0, 0, 0, surface_get_width(_tex), surface_get_height(_tex)); + surface_reset_shader(); + + return _outSurf; + } +} \ No newline at end of file diff --git a/scripts/node_3d_depth/node_3d_depth.yy b/scripts/node_3d_depth/node_3d_depth.yy new file mode 100644 index 000000000..5783daf0a --- /dev/null +++ b/scripts/node_3d_depth/node_3d_depth.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "node_3d_depth", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "generator", + "path": "folders/nodes/data/generator.yy", + }, +} \ No newline at end of file diff --git a/scripts/node_3d_depth/node_checkerboard.yy b/scripts/node_3d_depth/node_checkerboard.yy new file mode 100644 index 000000000..f65eb196c --- /dev/null +++ b/scripts/node_3d_depth/node_checkerboard.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "generator", + "path": "folders/nodes/data/generator.yy", + }, + "resourceVersion": "1.0", + "name": "node_checkerboard", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/node_3d_depth/node_stripe.yy b/scripts/node_3d_depth/node_stripe.yy new file mode 100644 index 000000000..3c179d416 --- /dev/null +++ b/scripts/node_3d_depth/node_stripe.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "generator", + "path": "folders/nodes/data/generator.yy", + }, + "resourceVersion": "1.0", + "name": "node_stripe", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/node_3d_displace/node_3d_displace.gml b/scripts/node_3d_displace/node_3d_displace.gml index 6c80b245f..bfc8d61c3 100644 --- a/scripts/node_3d_displace/node_3d_displace.gml +++ b/scripts/node_3d_displace/node_3d_displace.gml @@ -72,7 +72,10 @@ function Node_3D_Displace(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou attributes.auto_update = true; - array_push(attributeEditors, ["Auto Update", "auto_update", new checkBox(function() { attribute[? "auto_update"] = !attribute[? "auto_update"]; }, false)]); + array_push(attributeEditors, ["Auto Update", function() { return attributes.auto_update; }, + new checkBox(function() { + attribute[? "auto_update"] = !attribute[? "auto_update"]; + }, false)]); vertexObjects = []; _3d_node_init(1, /*Transform*/ 4, 5, 1, 2, 3); diff --git a/scripts/node_3d_extrude/node_3d_extrude.gml b/scripts/node_3d_extrude/node_3d_extrude.gml index 6907578a1..88230bd83 100644 --- a/scripts/node_3d_extrude/node_3d_extrude.gml +++ b/scripts/node_3d_extrude/node_3d_extrude.gml @@ -56,9 +56,11 @@ function Node_3D_Extrude(_x, _y, _group = noone) : Node_Processor(_x, _y, _group inputs[| 18] = nodeValue("Scale view with dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true) + inputs[| 19] = nodeValue("Smooth", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false) + input_display_list = [ ["Output", false], 1, 18, - ["Geometry", false], 0, 8, 14, + ["Geometry", false], 0, 8, 14, 19, ["Object transform", false], 2, 3, 4, ["Camera", false], 16, 17, 5, 7, 15, ["Light", false], 9, 10, 11, 12, 13, @@ -85,6 +87,11 @@ function Node_3D_Extrude(_x, _y, _group = noone) : Node_Processor(_x, _y, _group mesh_generate_index = 0; mesh_generate_amount = 0; + static onValueUpdate = function(index) { + if(index == 19) + generateMesh(); + } + static onValueFromUpdate = function(index) { if(index == 0 || index == 14) generateMesh(); @@ -119,16 +126,38 @@ function Node_3D_Extrude(_x, _y, _group = noone) : Node_Processor(_x, _y, _group static generateMeshIndex = function(index) { var _ins = getSingleValue( 0, index); var _hei = getSingleValue(14, index); - if(!is_surface(_ins)) return noone; + var _smt = getSingleValue(19, index); + if(!is_surface(_ins)) return noone; var ww = surface_get_width(_ins); var hh = surface_get_height(_ins); + var tw = 1 / ww; var th = 1 / hh; var sw = -ww / 2 * tw; var sh = -hh / 2 * th; var useH = is_surface(_hei); + if(_smt) { + var ts = surface_create(ww, hh); + surface_set_shader(ts, sh_3d_extrude_filler); + DRAW_CLEAR + shader_set_f("dimension", ww, hh); + draw_surface(_ins, 0, 0); + surface_reset_shader(); + _ins = ts; + + if(useH) { + var ds = surface_create(ww, hh); + surface_set_shader(ds, sh_3d_extrude_filler_depth); + DRAW_CLEAR + shader_set_f("dimension", ww, hh); + draw_surface(_hei, 0, 0); + surface_reset_shader(); + _hei = ds; + } + } + if(useH) { var hgw = surface_get_width(_hei); var hgh = surface_get_height(_hei); @@ -169,72 +198,200 @@ function Node_3D_Extrude(_x, _y, _group = noone) : Node_Processor(_x, _y, _group for( var i = 0; i < ww; i++ ) for( var j = 0; j < hh; j++ ) { - if(ap[i][j] == 0) continue; + if(!_smt && ap[i][j] == 0) continue; - var i0 = sw + i * tw, i1 = i0 + tw; - var j0 = sh + j * th, j1 = j0 + th; + var i0 = sw + i * tw; + var i1 = i0 + tw; + var j0 = sh + j * th; + var j1 = j0 + th; var tx0 = tw * i, tx1 = tx0 + tw; var ty0 = th * j, ty1 = ty0 + th; var dep = (useH? getHeight(hei, hgtW, hgtH, i, j) : 1) * 0.5; - v.addFace( [i1, j0, -dep], [0, 0, -1], [tx1, ty0], - [i0, j0, -dep], [0, 0, -1], [tx0, ty0], - [i1, j1, -dep], [0, 0, -1], [tx1, ty1], true); + if(_smt) { + var d0, d1, d2, d3; + var d00, d10, d01, d11; + var a, a0, a1, a2, a3; + + // d00 | a0 | d10 + // a1 | a | a2 + // d01 | a3 | d11 + + if(useH) { + d00 = (i > 0 && j > 0)? getHeight(hei, hgtW, hgtH, i - 1, j - 1) * 0.5 : 0; + d10 = (i < ww - 1 && j > 0)? getHeight(hei, hgtW, hgtH, i + 1, j - 1) * 0.5 : 0; + d01 = (i > 0 && j < hh - 1)? getHeight(hei, hgtW, hgtH, i - 1, j + 1) * 0.5 : 0; + d11 = (i < ww - 1 && j < hh - 1)? getHeight(hei, hgtW, hgtH, i + 1, j + 1) * 0.5 : 0; + + d0 = (j > 0)? getHeight(hei, hgtW, hgtH, i, j - 1) * 0.5 : 0; + d1 = (i > 0)? getHeight(hei, hgtW, hgtH, i - 1, j) * 0.5 : 0; + d2 = (i < ww - 1)? getHeight(hei, hgtW, hgtH, i + 1, j) * 0.5 : 0; + d3 = (j < hh - 1)? getHeight(hei, hgtW, hgtH, i, j + 1) * 0.5 : 0; + } else { + d00 = (i > 0 && j > 0)? bool(ap[i - 1][j - 1]) * 0.5 : 0; + d10 = (i < ww - 1 && j > 0)? bool(ap[i + 1][j - 1]) * 0.5 : 0; + d01 = (i > 0 && j < hh - 1)? bool(ap[i - 1][j + 1]) * 0.5 : 0; + d11 = (i < ww - 1 && j < hh - 1)? bool(ap[i + 1][j + 1]) * 0.5 : 0; + + d0 = (j > 0)? bool(ap[i][j - 1]) * 0.5 : 0; + d1 = (i > 0)? bool(ap[i - 1][j]) * 0.5 : 0; + d2 = (i < ww - 1)? bool(ap[i + 1][j]) * 0.5 : 0; + d3 = (j < hh - 1)? bool(ap[i][j + 1]) * 0.5 : 0; + } + + a = ap[i][j]; + a0 = (j > 0)? ap[i][j - 1] : 0; + a1 = (i > 0)? ap[i - 1][j] : 0; + a2 = (i < ww - 1)? ap[i + 1][j] : 0; + a3 = (j < hh - 1)? ap[i][j + 1] : 0; + + if(a1 && a0) d00 = (d1 + d0) / 2; + if(a0 && a2) d10 = (d0 + d2) / 2; + if(a2 && a3) d11 = (d2 + d3) / 2; + if(a3 && a1) d01 = (d3 + d1) / 2; + + if(a) { + v.addFace( [i1, j0, -d10], [0, 0, -1], [tx1, ty0], + [i0, j0, -d00], [0, 0, -1], [tx0, ty0], + [i1, j1, -d11], [0, 0, -1], [tx1, ty1], false); - v.addFace( [i1, j1, -dep], [0, 0, -1], [tx1, ty1], - [i0, j0, -dep], [0, 0, -1], [tx0, ty0], - [i0, j1, -dep], [0, 0, -1], [tx0, ty1], true); + v.addFace( [i1, j1, -d11], [0, 0, -1], [tx1, ty1], + [i0, j0, -d00], [0, 0, -1], [tx0, ty0], + [i0, j1, -d01], [0, 0, -1], [tx0, ty1], false); - v.addFace( [i1, j0, dep], [0, 0, 1], [tx1, ty0], - [i0, j0, dep], [0, 0, 1], [tx0, ty0], - [i1, j1, dep], [0, 0, 1], [tx1, ty1], true); + v.addFace( [i1, j0, d10], [0, 0, 1], [tx1, ty0], + [i0, j0, d00], [0, 0, 1], [tx0, ty0], + [i1, j1, d11], [0, 0, 1], [tx1, ty1], false); - v.addFace( [i1, j1, dep], [0, 0, 1], [tx1, ty1], - [i0, j0, dep], [0, 0, 1], [tx0, ty0], - [i0, j1, dep], [0, 0, 1], [tx0, ty1], true); + v.addFace( [i1, j1, d11], [0, 0, 1], [tx1, ty1], + [i0, j0, d00], [0, 0, 1], [tx0, ty0], + [i0, j1, d01], [0, 0, 1], [tx0, ty1], false); + } else if(!a0 && !a1 && a2 && a3) { + //var _tx0 = tw * (i + 1), _tx1 = _tx0 + tw; + //var _ty0 = th * (j + 0), _ty1 = _ty0 + th; + + d00 *= d0 * d1; + d10 *= d1 * d2; + d01 *= d1 * d3; + + v.addFace( [i1, j0, -d10], [0, 0, -1], [tx1, ty0], + [i0, j1, -d01], [0, 0, -1], [tx0, ty1], + [i1, j1, -d11], [0, 0, -1], [tx1, ty1], false); + + v.addFace( [i1, j0, d10], [0, 0, 1], [tx1, ty0], + [i0, j1, d01], [0, 0, 1], [tx0, ty1], + [i1, j1, d11], [0, 0, 1], [tx1, ty1], false); + } else if(!a0 && a1 && !a2 && a3) { + //var _tx0 = tw * (i - 1), _tx1 = _tx0 + tw; + //var _ty0 = th * (j + 0), _ty1 = _ty0 + th; + + d00 *= d0 * d1; + d10 *= d1 * d2; + d11 *= d2 * d3; + + v.addFace( [i1, j1, -d11], [0, 0, -1], [tx1, ty1], + [i0, j0, -d00], [0, 0, -1], [tx0, ty0], + [i0, j1, -d01], [0, 0, -1], [tx0, ty1], false); + + v.addFace( [i1, j1, d11], [0, 0, 1], [tx1, ty1], + [i0, j0, d00], [0, 0, 1], [tx0, ty0], + [i0, j1, d01], [0, 0, 1], [tx0, ty1], false); + } else if(a0 && a1 && !a2 && !a3) { + //var _tx0 = tw * (i - 1), _tx1 = _tx0 + tw; + //var _ty0 = th * (j + 0), _ty1 = _ty0 + th; + + d10 *= d1 * d2; + d01 *= d1 * d3; + d11 *= d2 * d3; + + v.addFace( [i0, j0, -d00], [0, 0, -1], [tx0, ty0], // d00 | a0 | d10 + [i0, j1, -d01], [0, 0, -1], [tx0, ty1], // a1 | a | a2 + [i1, j0, -d10], [0, 0, -1], [tx1, ty0], false); // d01 | a3 | d11 + + v.addFace( [i0, j0, d00], [0, 0, 1], [tx0, ty0], + [i0, j1, d01], [0, 0, 1], [tx0, ty1], + [i1, j0, d10], [0, 0, 1], [tx1, ty0], false); + } else if(a0 && !a1 && a2 && !a3) { + //var _tx0 = tw * (i + 1), _tx1 = _tx0 + tw; + //var _ty0 = th * (j + 0), _ty1 = _ty0 + th; + + d00 *= d0 * d1; + d01 *= d1 * d3; + d11 *= d2 * d3; + + v.addFace( [i1, j0, -d10], [0, 0, -1], [tx1, ty0], + [i0, j0, -d00], [0, 0, -1], [tx0, ty0], + [i1, j1, -d11], [0, 0, -1], [tx1, ty1], false); + + v.addFace( [i1, j0, d10], [0, 0, 1], [tx1, ty0], + [i0, j0, d00], [0, 0, 1], [tx0, ty0], + [i1, j1, d11], [0, 0, 1], [tx1, ty1], false); + } + } else { + v.addFace( [i1, j0, -dep], [0, 0, -1], [tx1, ty0], + [i0, j0, -dep], [0, 0, -1], [tx0, ty0], + [i1, j1, -dep], [0, 0, -1], [tx1, ty1], false); + + v.addFace( [i1, j1, -dep], [0, 0, -1], [tx1, ty1], + [i0, j0, -dep], [0, 0, -1], [tx0, ty0], + [i0, j1, -dep], [0, 0, -1], [tx0, ty1], false); - if((useH && dep * 2 > getHeight(hei, hgtW, hgtH, i, j - 1)) || (j == 0 || ap[i][j - 1] == 0)) { - v.addFace( [i0, j0, dep], [0, -1, 0], [tx1, ty0], - [i0, j0, -dep], [0, -1, 0], [tx0, ty0], - [i1, j0, dep], [0, -1, 0], [tx1, ty1], true); + v.addFace( [i1, j0, dep], [0, 0, 1], [tx1, ty0], + [i0, j0, dep], [0, 0, 1], [tx0, ty0], + [i1, j1, dep], [0, 0, 1], [tx1, ty1], false); - v.addFace( [i0, j0, -dep], [0, -1, 0], [tx1, ty1], - [i1, j0, -dep], [0, -1, 0], [tx0, ty0], - [i1, j0, dep], [0, -1, 0], [tx0, ty1], true); - } + v.addFace( [i1, j1, dep], [0, 0, 1], [tx1, ty1], + [i0, j0, dep], [0, 0, 1], [tx0, ty0], + [i0, j1, dep], [0, 0, 1], [tx0, ty1], false); + + if((useH && dep * 2 > getHeight(hei, hgtW, hgtH, i, j - 1)) || (j == 0 || ap[i][j - 1] == 0)) { //y side + v.addFace( [i0, j0, dep], [0, -1, 0], [tx1, ty0], + [i0, j0, -dep], [0, -1, 0], [tx0, ty0], + [i1, j0, dep], [0, -1, 0], [tx1, ty1], false); + + v.addFace( [i0, j0, -dep], [0, -1, 0], [tx1, ty1], + [i1, j0, -dep], [0, -1, 0], [tx0, ty0], + [i1, j0, dep], [0, -1, 0], [tx0, ty1], false); + } - if((useH && dep * 2 > getHeight(hei, hgtW, hgtH, i, j + 1)) || (j == hh - 1 || ap[i][j + 1] == 0)) { - v.addFace( [i0, j1, dep], [0, 1, 0], [tx1, ty0], - [i0, j1, -dep], [0, 1, 0], [tx0, ty0], - [i1, j1, dep], [0, 1, 0], [tx1, ty1], true); + if((useH && dep * 2 > getHeight(hei, hgtW, hgtH, i, j + 1)) || (j == hh - 1 || ap[i][j + 1] == 0)) { //y side + v.addFace( [i0, j1, dep], [0, 1, 0], [tx1, ty0], + [i0, j1, -dep], [0, 1, 0], [tx0, ty0], + [i1, j1, dep], [0, 1, 0], [tx1, ty1], false); - v.addFace( [i0, j1, -dep], [0, 1, 0], [tx1, ty1], - [i1, j1, -dep], [0, 1, 0], [tx0, ty0], - [i1, j1, dep], [0, 1, 0], [tx0, ty1], true); - } + v.addFace( [i0, j1, -dep], [0, 1, 0], [tx1, ty1], + [i1, j1, -dep], [0, 1, 0], [tx0, ty0], + [i1, j1, dep], [0, 1, 0], [tx0, ty1], false); + } - if((useH && dep * 2 > getHeight(hei, hgtW, hgtH, i - 1, j)) || (i == 0 || ap[i - 1][j] == 0)) { - v.addFace( [i0, j0, dep], [1, 0, 0], [tx1, ty0], - [i0, j0, -dep], [1, 0, 0], [tx0, ty0], - [i0, j1, dep], [1, 0, 0], [tx1, ty1], true); + if((useH && dep * 2 > getHeight(hei, hgtW, hgtH, i - 1, j)) || (i == 0 || ap[i - 1][j] == 0)) { //x side + v.addFace( [i0, j0, dep], [1, 0, 0], [tx1, ty0], + [i0, j0, -dep], [1, 0, 0], [tx0, ty0], + [i0, j1, dep], [1, 0, 0], [tx1, ty1], false); - v.addFace( [i0, j0, -dep], [1, 0, 0], [tx1, ty1], - [i0, j1, -dep], [1, 0, 0], [tx0, ty0], - [i0, j1, dep], [1, 0, 0], [tx0, ty1], true); - } + v.addFace( [i0, j0, -dep], [1, 0, 0], [tx1, ty1], + [i0, j1, -dep], [1, 0, 0], [tx0, ty0], + [i0, j1, dep], [1, 0, 0], [tx0, ty1], false); + } - if((useH && dep * 2 > getHeight(hei, hgtW, hgtH, i + 1, j)) || (i == ww - 1 || ap[i + 1][j] == 0)) { - v.addFace( [i1, j0, dep], [-1, 0, 0], [tx1, ty0], - [i1, j0, -dep], [-1, 0, 0], [tx0, ty0], - [i1, j1, dep], [-1, 0, 0], [tx1, ty1], true); + if((useH && dep * 2 > getHeight(hei, hgtW, hgtH, i + 1, j)) || (i == ww - 1 || ap[i + 1][j] == 0)) { //x side + v.addFace( [i1, j0, dep], [-1, 0, 0], [tx1, ty0], + [i1, j0, -dep], [-1, 0, 0], [tx0, ty0], + [i1, j1, dep], [-1, 0, 0], [tx1, ty1], false); - v.addFace( [i1, j0, -dep], [-1, 0, 0], [tx1, ty1], - [i1, j1, -dep], [-1, 0, 0], [tx0, ty0], - [i1, j1, dep], [-1, 0, 0], [tx0, ty1], true); + v.addFace( [i1, j0, -dep], [-1, 0, 0], [tx1, ty1], + [i1, j1, -dep], [-1, 0, 0], [tx0, ty0], + [i1, j1, dep], [-1, 0, 0], [tx0, ty1], false); + } } } + if(_smt) { + surface_free(_ins); + if(useH) surface_free(_hei); + } + v.createBuffer(); return v; } @@ -259,13 +416,14 @@ function Node_3D_Extrude(_x, _y, _group = noone) : Node_Processor(_x, _y, _group } static submit_vertex = function(index = 0) { - var _ins = getSingleValue(0, index); + var _ins = array_safe_get(textures, index); if(!is_surface(_ins)) return; if(index >= array_length(vertexObjects)) return; - var _lpos = getSingleValue(2, index); - var _lrot = getSingleValue(3, index); - var _lsca = getSingleValue(4, index); + var _lpos = getSingleValue( 2, index); + var _lrot = getSingleValue( 3, index); + var _lsca = getSingleValue( 4, index); + var _smt = getSingleValue(19, index); if(is_struct(vertexObjects[index])) { _3d_local_transform(_lpos, _lrot, _lsca); @@ -274,6 +432,8 @@ function Node_3D_Extrude(_x, _y, _group = noone) : Node_Processor(_x, _y, _group } } + textures = []; + static process_data = function(_outSurf, _data, _output_index, _array_index) { if(mesh_generating) return; if(_output_index == 3) return vertexObjects; @@ -298,6 +458,7 @@ function Node_3D_Extrude(_x, _y, _group = noone) : Node_Processor(_x, _y, _group var _proj = _data[16]; var _fov = _data[17]; var _dimS = _data[18]; + var _smt = _data[19]; inputs[| 17].setVisible(_proj); @@ -317,6 +478,19 @@ function Node_3D_Extrude(_x, _y, _group = noone) : Node_Processor(_x, _y, _group var _light = new __3d_light(_ldir, _lhgt, _lint, _lclr, _aclr); var _cam = new __3d_camera(_proj, _fov); + if(_smt) { + var ww = surface_get_width(_ins); + var hh = surface_get_height(_ins); + + var ts = surface_create(ww, hh); + surface_set_shader(ts, sh_3d_extrude_corner); + shader_set_f("dimension", ww, hh); + draw_surface(_ins, 0, 0); + surface_reset_shader(); + textures[_array_index] = ts; + } else + textures[_array_index] = _ins; + _outSurf = _3d_pre_setup(_outSurf, _dim, _transform, _light, _cam, pass); submit_vertex(_array_index); _3d_post_setup(); diff --git a/scripts/node_armature/node_armature.gml b/scripts/node_armature/node_armature.gml index a582fb980..f33ebb0a3 100644 --- a/scripts/node_armature/node_armature.gml +++ b/scripts/node_armature/node_armature.gml @@ -29,47 +29,72 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo var hovering = noone; var _bst = ds_stack_create(); ds_stack_push(_bst, [ _b, _x, _w ]); - + + var bone_remove = noone; + while(!ds_stack_empty(_bst)) { var _st = ds_stack_pop(_bst); var bone = _st[0]; var __x = _st[1]; var __w = _st[2]; - - if(!bone.is_main) { - if(bone.parent_anchor) - draw_sprite_ui(THEME.bone, 1, __x + 12, ty + 14,,,, COLORS._main_icon); - else if(bone.IKlength) - draw_sprite_ui(THEME.bone, 2, __x + 12, ty + 14,,,, COLORS._main_icon); - else { - if(_hover && point_in_circle(_m[0], _m[1], __x + 12, ty + 12, 12)) { - draw_sprite_ui(THEME.bone, 0, __x + 12, ty + 14,,,, COLORS._main_icon_light); - if(mouse_press(mb_left, _focus)) - bone_dragging = bone; - } else - draw_sprite_ui(THEME.bone, 0, __x + 12, ty + 14,,,, COLORS._main_icon); - } - - if(point_in_rectangle(_m[0], _m[1], __x + 24, ty + 3, __x + __w, ty + _hh - 3)) - anchor_selecting = [ bone, 2 ]; - - bone.tb_name.setFocusHover(_focus, _hover); - bone.tb_name.draw(__x + 24, ty + 3, __w - 24 - 32, _hh - 6, bone.name, _m); - - ty += _hh; - - draw_set_color(COLORS.node_composite_separator); - draw_line(_x + 16, ty, _x + _w - 16, ty); - } - + for( var i = 0; i < array_length(bone.childs); i++ ) ds_stack_push(_bst, [ bone.childs[i], __x + 16, __w - 16 ]); + + if(bone.is_main) continue; + + if(bone.parent_anchor) + draw_sprite_ui(THEME.bone, 1, __x + 12, ty + 14,,,, COLORS._main_icon); + else if(bone.IKlength) + draw_sprite_ui(THEME.bone, 2, __x + 12, ty + 14,,,, COLORS._main_icon); + else { + if(_hover && point_in_circle(_m[0], _m[1], __x + 12, ty + 12, 12)) { + draw_sprite_ui(THEME.bone, 0, __x + 12, ty + 14,,,, COLORS._main_icon_light); + if(mouse_press(mb_left, _focus)) + bone_dragging = bone; + } else + draw_sprite_ui(THEME.bone, 0, __x + 12, ty + 14,,,, COLORS._main_icon); + } + + if(point_in_rectangle(_m[0], _m[1], __x + 24, ty + 3, __x + __w, ty + _hh - 3)) + anchor_selecting = [ bone, 2 ]; + + var bx = __x + __w - 24; + var by = ty + _hh / 2; + + if(point_in_circle(_m[0], _m[1], bx, by, 16)) { + draw_sprite_ui_uniform(THEME.icon_delete, 3, bx, by, 1, COLORS._main_value_negative); + + if(mouse_press(mb_left, _focus)) + bone_remove = bone; + } else + draw_sprite_ui_uniform(THEME.icon_delete, 3, bx, by, 1, COLORS._main_icon); + + bone.tb_name.setFocusHover(_focus, _hover); + bone.tb_name.draw(__x + 24, ty + 3, __w - 24 - 40, _hh - 6, bone.name, _m); + + ty += _hh; + + draw_set_color(COLORS.node_composite_separator); + draw_line(_x + 16, ty, _x + _w - 16, ty); } ds_stack_destroy(_bst); if(bone_dragging && mouse_release(mb_left)) bone_dragging = noone; + + if(bone_remove != noone) { + var _par = bone_remove.parent; + array_remove(_par.childs, bone_remove); + + for( var i = 0; i < array_length(bone_remove.childs); i++ ) { + var _ch = bone_remove.childs[i]; + _par.addChild(_ch); + + _ch.parent_anchor = bone_remove.parent_anchor; + } + } return bh; }) @@ -101,11 +126,11 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo attributes.display_bone = 0; array_push(attributeEditors, "Display"); - array_push(attributeEditors, ["Display name", "display_name", + array_push(attributeEditors, ["Display name", function() { return attributes.display_name; }, new checkBox(function() { attributes.display_name = !attributes.display_name; })]); - array_push(attributeEditors, ["Display bone", "display_bone", + array_push(attributeEditors, ["Display bone", function() { return attributes.display_bone; }, new scrollBox(["Octahedral", "Stick"], function(ind) { attributes.display_bone = ind; })]); diff --git a/scripts/node_armature_bind/node_armature_bind.gml b/scripts/node_armature_bind/node_armature_bind.gml index 361aa0450..133936aa6 100644 --- a/scripts/node_armature_bind/node_armature_bind.gml +++ b/scripts/node_armature_bind/node_armature_bind.gml @@ -11,6 +11,12 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr inputs[| 2] = nodeValue("Bind data", self, JUNCTION_CONNECT.input, VALUE_TYPE.struct, noone) .setVisible(true, true) .setArrayDepth(1); + + inputs[| 3] = nodeValue("Bone transform", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ]) + .setDisplay(VALUE_DISPLAY.vector); + + inputs[| 4] = nodeValue("Bone scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) + .setDisplay(VALUE_DISPLAY.slider, [ 0.1, 2, 0.01 ]); outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); @@ -32,12 +38,14 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr attributes.display_name = true; attributes.display_bone = 0; + anchor_selecting = noone; + array_push(attributeEditors, "Display"); - array_push(attributeEditors, ["Display name", "display_name", + array_push(attributeEditors, ["Display name", function() { return attributes.display_name; }, new checkBox(function() { attributes.display_name = !attributes.display_name; })]); - array_push(attributeEditors, ["Display bone", "display_bone", + array_push(attributeEditors, ["Display bone", function() { return attributes.display_bone; }, new scrollBox(["Octahedral", "Stick"], function(ind) { attributes.display_bone = ind; })]); @@ -69,7 +77,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr } #region draw bones - var _b = inputs[| 1].getValue(); + var _b = bone; if(_b == noone) return 0; var amo = _b.childCount(); var _hh = ui(28); @@ -81,7 +89,9 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr ty += ui(32); + var _ty = ty; draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, ty, _w, bh - ui(32), COLORS.node_composite_bg_blend, 1); + draw_set_color(COLORS.node_composite_separator); draw_line(_x + 16, ty + ui(8), _x + _w - 16, ty + ui(8)); @@ -91,66 +101,72 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var _bst = ds_stack_create(); ds_stack_push(_bst, [ _b, _x, _w ]); + anchor_selecting = noone; + while(!ds_stack_empty(_bst)) { - var _st = ds_stack_pop(_bst); - var bone = _st[0]; - var __x = _st[1]; - var __w = _st[2]; + var _st = ds_stack_pop(_bst); + var _bone = _st[0]; + var __x = _st[1]; + var __w = _st[2]; - if(!bone.is_main) { - if(bone.parent_anchor) - draw_sprite_ui(THEME.bone, 1, __x + 12, ty + 14,,,, COLORS._main_icon); - else if(bone.IKlength) - draw_sprite_ui(THEME.bone, 2, __x + 12, ty + 14,,,, COLORS._main_icon); - else - draw_sprite_ui(THEME.bone, 0, __x + 12, ty + 14,,,, COLORS._main_icon); - - draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text); - draw_text(__x + 24, ty + 12, bone.name); + for( var i = 0; i < array_length(_bone.childs); i++ ) + ds_stack_push(_bst, [ _bone.childs[i], __x + 16, __w - 16 ]); - if(ds_map_exists(surfMap, bone.ID)) { - var _sdata = surfMap[? bone.ID]; + if(_bone.is_main) continue; + + if(_bone.parent_anchor) + draw_sprite_ui(THEME.bone, 1, __x + 12, ty + 14,,,, COLORS._main_icon); + else if(_bone.IKlength) + draw_sprite_ui(THEME.bone, 2, __x + 12, ty + 14,,,, COLORS._main_icon); + else + draw_sprite_ui(THEME.bone, 0, __x + 12, ty + 14,,,, COLORS._main_icon); - var _sx = __x + 24 + string_width(bone.name) + 8; - var _sy = ty + 4; + draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text); + draw_text(__x + 24, ty + 12, _bone.name); + + if(ds_map_exists(surfMap, _bone.ID)) { + var _sdata = surfMap[? _bone.ID]; - for( var i = 0; i < array_length(_sdata); i++ ) { - var _sid = _sdata[i][0]; - var _surf = _sdata[i][1]; - var _sw = surface_get_width(_surf); - var _sh = surface_get_height(_surf); - var _ss = (_hh - 8) / _sh; + var _sx = __x + 24 + string_width(_bone.name) + 8; + var _sy = ty + 4; + + for( var i = 0; i < array_length(_sdata); i++ ) { + var _sid = _sdata[i][0]; + var _surf = _sdata[i][1]; + var _sw = surface_get_width(_surf); + var _sh = surface_get_height(_surf); + var _ss = (_hh - 8) / _sh; - draw_surface_ext_safe(_surf, _sx, _sy, _ss, _ss, 0, c_white, 1); + draw_surface_ext_safe(_surf, _sx, _sy, _ss, _ss, 0, c_white, 1); - if(_hover && point_in_rectangle(_m[0], _m[1], _sx, _sy, _sx + _sw * _ss, _sy + _sh * _ss)) { - if(mouse_press(mb_left, _focus)) { - layer_dragging = _sid; - inputs[| input_fix_len + _sid * data_length].extra_data[0] = ""; - } + if(_hover && point_in_rectangle(_m[0], _m[1], _sx, _sy, _sx + _sw * _ss, _sy + _sh * _ss)) { + if(mouse_press(mb_left, _focus)) { + layer_dragging = _sid; + inputs[| input_fix_len + _sid * data_length].extra_data[0] = ""; + } - draw_set_color(COLORS._main_accent); - } else - draw_set_color(COLORS.node_composite_bg); - draw_rectangle(_sx, _sy, _sx + _sw * _ss, _sy + _sh * _ss, true); + draw_set_color(COLORS._main_accent); + } else + draw_set_color(COLORS.node_composite_bg); + draw_rectangle(_sx, _sy, _sx + _sw * _ss, _sy + _sh * _ss, true); - _sy += _sh * _ss + 4; - } + _sy += _sh * _ss + 4; } - - if(layer_dragging != noone && point_in_rectangle(_m[0], _m[1], _x, ty, _x + _w, ty + _hh - 1)) { - draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, ty, _w, _hh, COLORS._main_accent, 1); - hovering = bone; - } - - ty += _hh; - - draw_set_color(COLORS.node_composite_separator); - draw_line(_x + 16, ty, _x + _w - 16, ty); } + + if(point_in_rectangle(_m[0], _m[1], _x, ty, _x + _w, ty + _hh - 1)) { + if(layer_dragging != noone) { + draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, ty, _w, _hh, COLORS._main_accent, 1); + hovering = _bone; + } + + anchor_selecting = [_bone, 2]; + } + + ty += _hh; - for( var i = 0; i < array_length(bone.childs); i++ ) - ds_stack_push(_bst, [ bone.childs[i], __x + 16, __w - 16 ]); + draw_set_color(COLORS.node_composite_separator); + draw_line(_x + 16, ty, _x + _w - 16, ty); } ds_stack_destroy(_bst); @@ -162,6 +178,9 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr layer_dragging = noone; triggerRender(); } + + if(layer_dragging != noone && !hovering) + draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, _ty, _w, bh - ui(32), COLORS._main_accent, 1); #endregion var amo = (ds_list_size(inputs) - input_fix_len) / data_length - 1; @@ -270,16 +289,23 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr draw_line_width(_x + 16, _cy - 2, _x + _w - 16, _cy - 2, 2); } } - + + var binded = inputs[| i].extra_data[0] != ""; + if(layer_dragging == noone || layer_dragging == index) { var _bx = _x + 24; if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 16)) { - draw_sprite_ui_uniform(THEME.hamburger, 3, _bx, _cy + lh / 2, 1, c_white); + draw_sprite_ui_uniform(THEME.hamburger_s, 3, _bx, _cy + lh / 2, 1, c_white); if(mouse_press(mb_left, _focus)) layer_dragging = index; - } else - draw_sprite_ui_uniform(THEME.hamburger, 3, _bx, _cy + lh / 2, 1, COLORS._main_icon); + } else { + if(!binded) { + var cc = merge_color(COLORS._main_icon, COLORS._main_accent, 0.5 + 0.5 * (sin(current_time / 100) * 0.5 + 0.5)); + draw_sprite_ui_uniform(THEME.hamburger_s, 3, _bx, _cy + lh / 2, 1, cc); + } else + draw_sprite_ui_uniform(THEME.hamburger_s, 3, _bx, _cy + lh / 2, 1, COLORS._main_icon); + } } } #endregion @@ -322,7 +348,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr input_display_list = [ 1, 2, ["Output", true], 0, - ["Armature", false], layer_renderer, + ["Armature", false], 3, 4, layer_renderer, ["Surfaces", true], ]; input_display_list_len = array_length(input_display_list); @@ -387,6 +413,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr atlas_data = []; bind_data = []; + bone = noone; surface_selecting = noone; static getInputAmount = function() { @@ -426,15 +453,16 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var _b = inputs[| 1].getValue(); if(_b == noone) return; + bone = _b.clone(); var _bst = ds_stack_create(); - ds_stack_push(_bst, _b); + ds_stack_push(_bst, bone); while(!ds_stack_empty(_bst)) { - var bone = ds_stack_pop(_bst); + var _bone = ds_stack_pop(_bst); - for( var i = 0; i < array_length(bone.childs); i++ ) { - var child_bone = bone.childs[i]; + for( var i = 0; i < array_length(_bone.childs); i++ ) { + var child_bone = _bone.childs[i]; boneMap[? child_bone.ID] = child_bone; ds_stack_push(_bst, child_bone); } @@ -446,17 +474,19 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region var dim = inputs[| 0].getValue(); - var _b = inputs[| 1].getValue(); var _bind = inputs[| 2].getValue(); - if(_b == noone) return; + var _dpos = inputs[| 3].getValue(); + var _dsca = inputs[| 4].getValue(); - if(_bind != noone) { - _b.draw(attributes, false, _x, _y, _s, _mx, _my); + if(bone == noone) return; + + bone.draw(attributes, false, _x + _dpos[0] * _s, _y + _dpos[1] * _s, _s * _dsca, _mx, _my, anchor_selecting); + inputs[| 3].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); + //inputs[| 4].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); + + if(_bind != noone) return; - } - - _b.draw(attributes, false, _x, _y, _s, _mx, _my); var ww = dim[0]; var hh = dim[1]; @@ -554,8 +584,8 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var _sw = _ww * _sca[0]; var _sh = _hh * _sca[1]; - var _cx = _anc.x + _mov[0]; - var _cy = _anc.y + _mov[1]; + var _cx = (_anc.x * _dsca) + _mov[0] + _dpos[0]; + var _cy = (_anc.y * _dsca) + _mov[1] + _dpos[1]; var _d0 = point_rotate(_cx - _sw / 2, _cy - _sh / 2, _cx, _cy, _rot); var _d1 = point_rotate(_cx - _sw / 2, _cy + _sh / 2, _cx, _cy, _rot); @@ -701,9 +731,15 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var _dim = _data[0]; var _bone = _data[1]; var _bind = _data[2]; + + var _dpos = _data[3]; + var _dsca = _data[4]; var cDep = attrDepth(); - if(_bone == noone) return _outSurf; + if(bone == noone && _bone != noone) setBone(); + if(bone == noone) return _outSurf; + + ////////////////////////////////////////// if(ds_map_size(boneMap) == 0) setBone(); @@ -737,18 +773,18 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var _s = use_data? _bind[i].surface.get() : _data[datInd]; if(!is_surface(_s)) continue; - var _bone = use_data? _bind[i].bone : inputs[| datInd].extra_data[0]; + var _b = use_data? _bind[i].bone : inputs[| datInd].extra_data[0]; - if(!ds_map_exists(boneMap, _bone)) { + if(!ds_map_exists(boneMap, _b)) { //print($"Bone not exist {_bone} from map {ds_map_size(boneMap)}") continue; } - _bone = boneMap[? _bone]; + _b = boneMap[? _b]; var _tran = use_data? _bind[i].transform : _data[datInd + 1]; - var _rot = _bone.angle + _tran[TRANSFORM.rot]; - var _anc = _bone.getPoint(0.5); - var _mov = point_rotate(_tran[TRANSFORM.pos_x], _tran[TRANSFORM.pos_y], 0, 0, _bone.angle); + var _rot = _b.angle + _tran[TRANSFORM.rot]; + var _anc = _b.getPoint(0.5); + var _mov = point_rotate(_tran[TRANSFORM.pos_x], _tran[TRANSFORM.pos_y], 0, 0, _b.angle); var _sca = [ _tran[TRANSFORM.sca_x], _tran[TRANSFORM.sca_y] ]; var _ww = surface_get_width(_s); @@ -758,8 +794,8 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var _cen = point_rotate(-_sw / 2, -_sh / 2, 0, 0, _rot); var _pos = [ - _anc.x + _cen[0] + _mov[0], - _anc.y + _cen[1] + _mov[1] + (_anc.x * _dsca) + _cen[0] + _mov[0] + _dpos[0], + (_anc.y * _dsca) + _cen[1] + _mov[1] + _dpos[1] ]; shader_set_interpolation(_s); @@ -767,7 +803,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr array_push(atlas_data, new SurfaceAtlas(_s, _pos, _rot, _sca)); array_push(bind_data, { surface: new Surface(_s), - bone: _bone.ID, + bone: _b.ID, transform: _tran }); draw_surface_ext_safe(_s, _pos[0], _pos[1], _sca[0], _sca[1], _rot); @@ -781,7 +817,14 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr static postDeserialize = function() { var _inputs = load_map.inputs; - for(var i = input_fix_len; i < array_length(_inputs); i += data_length) + var load_fix_len = input_fix_len; + if(PROJECT.version < SAVE_VERSION) { + array_insert(load_map.inputs, 3, noone); + array_insert(load_map.inputs, 4, noone); + load_fix_len = 3; + } + + for(var i = load_fix_len; i < array_length(_inputs); i += data_length) createNewSurface(); } diff --git a/scripts/node_armature_pose/node_armature_pose.gml b/scripts/node_armature_pose/node_armature_pose.gml index 8781b7297..97f530296 100644 --- a/scripts/node_armature_pose/node_armature_pose.gml +++ b/scripts/node_armature_pose/node_armature_pose.gml @@ -23,11 +23,11 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const attributes.display_bone = 0; array_push(attributeEditors, "Display"); - array_push(attributeEditors, ["Display name", "display_name", + array_push(attributeEditors, ["Display name", function() { return attributes.display_name; }, new checkBox(function() { attributes.display_name = !attributes.display_name; })]); - array_push(attributeEditors, ["Display bone", "display_bone", + array_push(attributeEditors, ["Display bone", function() { return attributes.display_bone; }, new scrollBox(["Octahedral", "Stick"], function(ind) { attributes.display_bone = ind; })]); diff --git a/scripts/node_armature_sample/node_armature_sample.gml b/scripts/node_armature_sample/node_armature_sample.gml new file mode 100644 index 000000000..c7df8d721 --- /dev/null +++ b/scripts/node_armature_sample/node_armature_sample.gml @@ -0,0 +1,66 @@ +function Node_Armature_Sample(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { + name = "Armature Sample"; + previewable = false; + w = 96; + h = 72; + min_h = h; + + inputs[| 0] = nodeValue("Armature", self, JUNCTION_CONNECT.input, VALUE_TYPE.armature, noone) + .setVisible(true, true) + .rejectArray(); + + inputs[| 1] = nodeValue("Bone name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, ""); + + inputs[| 2] = nodeValue("Sample point", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) + .setDisplay(VALUE_DISPLAY.slider, [ 0, 1, 0.01 ]); + + outputs[| 0] = nodeValue("Position", self, JUNCTION_CONNECT.output, VALUE_TYPE.integer, [ 0, 0 ]) + .setDisplay(VALUE_DISPLAY.vector); + + attributes.display_name = true; + attributes.display_bone = 0; + + array_push(attributeEditors, "Display"); + array_push(attributeEditors, ["Display name", function() { return attributes.display_name; }, + new checkBox(function() { + attributes.display_name = !attributes.display_name; + })]); + array_push(attributeEditors, ["Display bone", function() { return attributes.display_bone; }, + new scrollBox(["Octahedral", "Stick"], function(ind) { + attributes.display_bone = ind; + })]); + + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { + var _b = inputs[| 0].getValue(); + + if(_b == noone) return; + _b.draw(attributes, false, _x, _y, _s, _mx, _my); + } + + function update() { + var _bone = inputs[| 0].getValue(); + var _name = inputs[| 1].getValue(); + var _prog = inputs[| 2].getValue(); + + if(_bone == noone) return; + + _name = string_trim(_name); + //print($"|{_name}|{string_length(_name)}"); + //for( var i = 1; i <= string_length(_name); i++ ) + // print($" {i}: |{string_char_at(_name, i)}|"); + + var _b = _bone.findBoneByName(_name); + if(_b == noone) { + outputs[| 0].setValue([0, 0]); + return; + } + + var _p = _b.getPoint(_prog); + outputs[| 0].setValue([_p.x, _p.y]); + } + + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { + var bbox = drawGetBbox(xx, yy, _s); + draw_sprite_fit(s_node_armature_sample, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); + } +} \ No newline at end of file diff --git a/scripts/node_armature_sample/node_armature_sample.yy b/scripts/node_armature_sample/node_armature_sample.yy new file mode 100644 index 000000000..f27c2a01e --- /dev/null +++ b/scripts/node_armature_sample/node_armature_sample.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "node_armature_sample", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "armature", + "path": "folders/nodes/data/compose/armature.yy", + }, +} \ No newline at end of file diff --git a/scripts/node_armature_to_path/node_armature_to_path.gml b/scripts/node_armature_to_path/node_armature_to_path.gml index f0514bac5..2f59eaff3 100644 --- a/scripts/node_armature_to_path/node_armature_to_path.gml +++ b/scripts/node_armature_to_path/node_armature_to_path.gml @@ -2,6 +2,8 @@ function Node_Armature_Path(_x, _y, _group = noone) : Node(_x, _y, _group) const name = "Armature Path"; previewable = false; w = 96; + h = 72; + min_h = h; inputs[| 0] = nodeValue("Armature", self, JUNCTION_CONNECT.input, VALUE_TYPE.armature, noone) .setVisible(true, true) @@ -18,11 +20,11 @@ function Node_Armature_Path(_x, _y, _group = noone) : Node(_x, _y, _group) const attributes.display_bone = 0; array_push(attributeEditors, "Display"); - array_push(attributeEditors, ["Display name", "display_name", + array_push(attributeEditors, ["Display name", function() { return attributes.display_name; }, new checkBox(function() { attributes.display_name = !attributes.display_name; })]); - array_push(attributeEditors, ["Display bone", "display_bone", + array_push(attributeEditors, ["Display bone", function() { return attributes.display_bone; }, new scrollBox(["Octahedral", "Stick"], function(ind) { attributes.display_bone = ind; })]); diff --git a/scripts/node_canvas/node_canvas.gml b/scripts/node_canvas/node_canvas.gml index 67c6aa906..2be89786b 100644 --- a/scripts/node_canvas/node_canvas.gml +++ b/scripts/node_canvas/node_canvas.gml @@ -3,24 +3,25 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor color = COLORS.node_blend_canvas; preview_channel = 1; - inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, def_surf_size2 ) + inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, def_surf_size2 ) .setDisplay(VALUE_DISPLAY.vector); - inputs[| 1] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black ); - inputs[| 2] = nodeValue("Brush size", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1 ) + inputs[| 1] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black ); + inputs[| 2] = nodeValue("Brush size", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1 ) .setDisplay(VALUE_DISPLAY.slider, [1, 32, 1]); - inputs[| 3] = nodeValue("Fill threshold", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.) + inputs[| 3] = nodeValue("Fill threshold", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.) .setDisplay(VALUE_DISPLAY.slider, [0, 1, 0.01]); - inputs[| 4] = nodeValue("Fill type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) + inputs[| 4] = nodeValue("Fill type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) .setDisplay(VALUE_DISPLAY.enum_scroll, ["4 connect", "8 connect", "Entire canvas"]); - inputs[| 5] = nodeValue("Draw preview overlay", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true); + inputs[| 5] = nodeValue("Draw preview overlay", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true); - inputs[| 6] = nodeValue("Brush", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, -1); + inputs[| 6] = nodeValue("Brush", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, -1) + .setVisible(true, false); - inputs[| 7] = nodeValue("Surface amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1); + inputs[| 7] = nodeValue("Surface amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1); inputs[| 8] = nodeValue("Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, -1); @@ -33,23 +34,26 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor .setDisplay(VALUE_DISPLAY.slider, [0, 1, 0.01]); outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); - outputs[| 1] = nodeValue("Preview", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); input_display_list = [ ["Output", false], 0, ["Brush", false], 6, 2, 1, 11, ["Fill", false], 3, 4, - ["Display", false], 5, 8, 9, 10, + ["Display", false], 8, 10, 9, ]; attribute_surface_depth(); - canvas_surface = surface_create(1, 1); - drawing_surface = surface_create(1, 1); - surface_buffer = buffer_create(1 * 1 * 4, buffer_fixed, 2); + canvas_surface = surface_create_empty(1, 1); + drawing_surface = surface_create_empty(1, 1); + canvas_buffer = buffer_create(1 * 1 * 4, buffer_fixed, 2); surface_w = 1; surface_h = 1; + prev_surface = surface_create_empty(1, 1); + preview_draw_surface = surface_create_empty(1, 1); + _preview_draw_surface = surface_create_empty(1, 1); + tool_channel_edit = new checkBoxGroup(THEME.tools_canvas_channel, function(ind, val) { tool_attribute.channel[ind] = val; }); tool_attribute.channel = [ true, true, true, true ]; tool_settings = [ @@ -66,18 +70,6 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor draw_stack = ds_list_create(); - function surface_store_buffer() { - buffer_delete(surface_buffer); - - surface_w = surface_get_width(canvas_surface); - surface_h = surface_get_height(canvas_surface); - surface_buffer = buffer_create(surface_w * surface_h * 4, buffer_fixed, 4); - buffer_get_surface(surface_buffer, canvas_surface, 0); - - triggerRender(); - apply_surface(); - } - function apply_draw_surface() { var _alp = inputs[| 11].getValue(); @@ -86,65 +78,41 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor gpu_set_blendmode(bm_subtract); draw_surface_ext_safe(drawing_surface, 0, 0, 1, 1, 0, c_white, _alp); - surface_set_target(drawing_surface); - DRAW_CLEAR - surface_reset_target(); + surface_clear(drawing_surface); BLEND_NORMAL; surface_store_buffer(); } - function apply_surface() { - var _dim = inputs[| 0].getValue(); - var _bg = inputs[| 8].getValue(); - var _bga = inputs[| 9].getValue(); - var _bgr = inputs[| 10].getValue(); - var cDep = attrDepth(); + function surface_store_buffer() { + buffer_delete(canvas_buffer); + + surface_w = surface_get_width(canvas_surface); + surface_h = surface_get_height(canvas_surface); + canvas_buffer = buffer_create(surface_w * surface_h * 4, buffer_fixed, 4); + buffer_get_surface(canvas_buffer, canvas_surface, 0); + + triggerRender(); + apply_surface(); + } + + function apply_surface() { + var _dim = inputs[| 0].getValue(); + var cDep = attrDepth(); - var _outSurf = outputs[| 0].getValue(); - _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], cDep); - if(!is_surface(canvas_surface)) - canvas_surface = surface_create_from_buffer(_dim[0], _dim[1], surface_buffer); + canvas_surface = surface_create_from_buffer(_dim[0], _dim[1], canvas_buffer); else if(surface_get_width(canvas_surface) != _dim[0] || surface_get_height(canvas_surface) != _dim[1]) { - buffer_delete(surface_buffer); - surface_buffer = buffer_create(_dim[0] * _dim[1] * 4, buffer_fixed, 4); + buffer_delete(canvas_buffer); + canvas_buffer = buffer_create(_dim[0] * _dim[1] * 4, buffer_fixed, 4); canvas_surface = surface_size_to(canvas_surface, _dim[0], _dim[1]); } drawing_surface = surface_verify(drawing_surface, _dim[0], _dim[1], cDep); - - surface_set_target(_outSurf); - DRAW_CLEAR - BLEND_ALPHA - if(_bgr && is_surface(_bg)) - draw_surface_stretched_ext(_bg, 0, 0, _dim[0], _dim[1], c_white, _bga); - draw_surface_safe(canvas_surface, 0, 0); - BLEND_NORMAL - surface_reset_target(); - - outputs[| 0].setValue(_outSurf); - - ///// - - var _surf_prev = outputs[| 1].getValue(); - _surf_prev = surface_verify(_surf_prev, _dim[0], _dim[1], cDep); - outputs[| 1].setValue(_surf_prev); - - surface_set_target(_surf_prev); - DRAW_CLEAR - BLEND_ALPHA; - - if(is_surface(_bg)) - draw_surface_stretched_ext(_bg, 0, 0, _dim[0], _dim[1], c_white, _bga); - draw_surface_safe(canvas_surface, 0, 0); - - BLEND_NORMAL; - - surface_reset_target(); + surface_clear(drawing_surface); } - function draw_point_size(_x, _y, _siz, _brush) { + function draw_point_size(_x, _y, _siz, _brush) { #region if(!is_surface(_brush)) { if(_siz <= 1) draw_point(_x, _y); @@ -167,27 +135,29 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor draw_surface_ext_safe(_brush, _x - floor(_sw / 2), _y - floor(_sh / 2), 1, 1, 0, draw_get_color(), draw_get_alpha()); } - } + } #endregion - function draw_line_size(_x0, _y0, _x1, _y1, _siz, _brush) { + function draw_line_size(_x0, _y0, _x1, _y1, _siz, _brush) { #region if(_siz == 1 && _brush == -1) draw_line(_x0, _y0, _x1, _y1); else { - var diss = floor(point_distance(_x0, _y0, _x1, _y1)); + var diss = point_distance(_x0, _y0, _x1, _y1); var dirr = point_direction(_x0, _y0, _x1, _y1); var st_x = lengthdir_x(1, dirr); var st_y = lengthdir_y(1, dirr); - for( var i = 0; i <= diss; i++ ) { - var _x = _x0 + st_x * i; - var _y = _y0 + st_y * i; + for( var i = 0; i <= diss; i += 1 ) { + var _px = _x0 + st_x * i; + var _py = _y0 + st_y * i; - draw_point_size(_x, _y, _siz, _brush); + draw_point_size(_px, _py, _siz, _brush); } + + draw_point_size(_x1, _y1, _siz, _brush); } - } + } #endregion - function draw_rect_size(_x0, _y0, _x1, _y1, _siz, _fill, _brush) { + function draw_rect_size(_x0, _y0, _x1, _y1, _siz, _fill, _brush) { #region if(_x0 == _x1 && _y0 == _y1) { draw_point_size(_x0, _y0, _siz, _brush); return; @@ -218,9 +188,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor draw_line_size(_max_x, _may_y, _max_x, _min_y, _siz, _brush); draw_line_size(_max_x, _may_y, _min_x, _may_y, _siz, _brush); } - } + } #endregion - function draw_ellp_size(_x0, _y0, _x1, _y1, _siz, _fill, _brush) { + function draw_ellp_size(_x0, _y0, _x1, _y1, _siz, _fill, _brush) { #region if(_x0 == _x1 && _y0 == _y1) { draw_point_size(_x0, _y0, _siz, _brush); return; @@ -261,27 +231,27 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor oy = ny; } } - } + } #endregion - function get_color_buffer(_x, _y) { + function get_color_buffer(_x, _y) { #region var pos = (surface_w * _y + _x) * 4; - if(pos > buffer_get_size(surface_buffer)) { - print("Error buffer overflow " + string(pos) + "/" + string(buffer_get_size(surface_buffer))); + if(pos > buffer_get_size(canvas_buffer)) { + print("Error buffer overflow " + string(pos) + "/" + string(buffer_get_size(canvas_buffer))); return 0; } - buffer_seek(surface_buffer, buffer_seek_start, pos); - var c = buffer_read(surface_buffer, buffer_u32); + buffer_seek(canvas_buffer, buffer_seek_start, pos); + var c = buffer_read(canvas_buffer, buffer_u32); return c; - } + } #endregion - function ff_fillable(colorBase, colorFill, _x, _y, _thres) { + function ff_fillable(colorBase, colorFill, _x, _y, _thres) { #region var d = color_diff(colorBase, get_color_buffer(_x, _y), true); return d <= _thres && d != colorFill; - } + } #endregion - function flood_fill_scanline(_x, _y, _surf, _thres, _corner = false) { + function flood_fill_scanline(_x, _y, _surf, _thres, _corner = false) { #region var _alp = inputs[| 11].getValue(); var colorFill = draw_get_color() + (255 << 24); @@ -320,8 +290,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor draw_point(x1, y1); draw_set_alpha(1); - buffer_seek(surface_buffer, buffer_seek_start, (surface_w * y1 + x1) * 4); - buffer_write(surface_buffer, buffer_u32, colorFill); + buffer_seek(canvas_buffer, buffer_seek_start, (surface_w * y1 + x1) * 4); + buffer_write(canvas_buffer, buffer_u32, colorFill); //print("> Filling " + string(x1) + ", " + string(y1) + ": " + string(get_color_buffer(x1, y1))); @@ -369,9 +339,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor } } } - } + } #endregion - function canvas_fill(_x, _y, _surf, _thres) { + function canvas_fill(_x, _y, _surf, _thres) { #region var _alp = inputs[| 11].getValue(); var w = surface_get_width(_surf); @@ -394,7 +364,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor } } draw_set_alpha(1); - } + } #endregion mouse_cur_x = 0; mouse_cur_y = 0; @@ -405,6 +375,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor mouse_holding = false; + //static getPreviewValue = function() { return key_mod_press(ALT)? outputs[| 0] : noone; } + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { mouse_cur_x = round((_mx - _x) / _s - 0.5); mouse_cur_y = round((_my - _y) / _s - 0.5); @@ -418,7 +390,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor var _brush = inputs[| 6].getValue(); if(!surface_exists(canvas_surface)) - apply_surface(); + surface_store_buffer(); var _surf_w = surface_get_width(canvas_surface); var _surf_h = surface_get_height(canvas_surface); @@ -441,18 +413,18 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor if(mouse_press(mb_left, active)) { drawing_surface = surface_verify(drawing_surface, _dim[0], _dim[1], attrDepth()); - BLEND_ALPHA; - surface_set_target(drawing_surface); - DRAW_CLEAR + + surface_set_shader(drawing_surface, noone); draw_point_size(mouse_cur_x, mouse_cur_y, _siz, _brush); - surface_reset_target(); + surface_reset_shader(); mouse_holding = true; if(key_mod_press(SHIFT)) { - BLEND_ALPHA; - surface_set_target(drawing_surface); + surface_set_shader(drawing_surface, noone, true, BLEND.alpha); + //print($"===== DRAW LINE {mouse_pre_draw_x}, {mouse_pre_draw_y}, {mouse_cur_x}, {mouse_cur_y} ====="); draw_line_size(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, _siz, _brush); - surface_reset_target(); + //print($"===== DRAW LINE END ====="); + surface_reset_shader(); mouse_holding = false; apply_draw_surface(); @@ -464,11 +436,10 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor if(mouse_holding && mouse_click(mb_left, active)) { if(mouse_pre_draw_x != mouse_cur_x || mouse_pre_draw_y != mouse_cur_y) { - BLEND_ALPHA; - surface_set_target(drawing_surface); + surface_set_shader(drawing_surface, noone, false, BLEND.alpha); draw_point_size(mouse_cur_x, mouse_cur_y, _siz, _brush); draw_line_size(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, _siz, _brush); - surface_reset_target(); + surface_reset_shader(); } mouse_pre_draw_x = mouse_cur_x; @@ -484,7 +455,6 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor mouse_pre_x = mouse_cur_x; mouse_pre_y = mouse_cur_y; - apply_surface(); } else if(isUsingTool(2) || isUsingTool(3)) { if(mouse_holding && key_mod_press(SHIFT)) { @@ -503,25 +473,22 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor mouse_holding = true; } - if(mouse_holding && mouse_release(mb_left)) { - BLEND_ALPHA; - surface_set_target(drawing_surface); - DRAW_CLEAR + if(mouse_holding) { + drawing_surface = surface_verify(drawing_surface, _dim[0], _dim[1], attrDepth()); + + surface_set_shader(drawing_surface, noone); if(isUsingTool(2)) draw_rect_size(mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, _siz, isUsingTool(2, 1), _brush); else if(isUsingTool(3)) draw_ellp_size(mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, _siz, isUsingTool(3, 1), _brush); - surface_reset_target(); - BLEND_NORMAL; + surface_reset_shader(); - apply_draw_surface(); - mouse_holding = false; + if(mouse_release(mb_left)) { + apply_draw_surface(); + mouse_holding = false; + } } - apply_surface(); - - } - - if(isUsingTool(4) || (DRAGGING && DRAGGING.type == "Color")) { + } else if(isUsingTool(4) || (DRAGGING && DRAGGING.type == "Color")) { if(point_in_rectangle(mouse_cur_x, mouse_cur_y, 0, 0, _surf_w - 1, _surf_h - 1)) { var fill = DRAGGING? mouse_release(mb_left) : mouse_press(mb_left); @@ -547,84 +514,103 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor gpu_set_colorwriteenable(true, true, true, true); surface_reset_target(); + if(key_mod_press(ALT)) return; + #region preview var _bg = inputs[| 8].getValue(); var _bga = inputs[| 9].getValue(); + var _bgr = inputs[| 10].getValue(); var _alp = inputs[| 11].getValue(); - - var _surf_prev = outputs[| 1].getValue(); - _surf_prev = surface_verify(_surf_prev, _dim[0], _dim[1], attrDepth()); - outputs[| 1].setValue(_surf_prev); - surface_set_target(_surf_prev); - DRAW_CLEAR - BLEND_ALPHA; + var __s = surface_get_target(); - if(is_surface(_bg)) draw_surface_stretched_ext(_bg, 0, 0, _dim[0], _dim[1], c_white, _bga); - draw_surface_safe(canvas_surface, 0, 0); + prev_surface = surface_verify(prev_surface, _dim[0], _dim[1]); + preview_draw_surface = surface_verify(preview_draw_surface, _dim[0], _dim[1]); + _preview_draw_surface = surface_verify(_preview_draw_surface, surface_get_width(__s), surface_get_height(__s)); - BLEND_ALPHA; - if(isUsingTool(1)) - gpu_set_blendmode(bm_subtract); - draw_surface_ext_safe(drawing_surface, 0, 0, 1, 1, 0, c_white, _alp); - BLEND_NORMAL; - - draw_set_color(_col); - if(isUsingTool(0) || isUsingTool(1)) { - if(key_mod_press(SHIFT)) - draw_line_size(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, _siz, _brush); - else - draw_point_size(mouse_cur_x, mouse_cur_y, _siz, _brush); + surface_set_shader(preview_draw_surface, noone,, BLEND.alpha); + draw_surface_safe(drawing_surface, 0, 0); - if(isUsingTool(1)) gpu_set_blendmode(bm_normal); - } else if (mouse_holding) { - if(isUsingTool(2)) - draw_rect_size(mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, _siz, isUsingTool(2, 1), _brush); - else if(isUsingTool(3)) - draw_ellp_size(mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, _siz, isUsingTool(3, 1), _brush); - } - - BLEND_NORMAL; - surface_reset_target(); - - if (isUsingTool(2) || isUsingTool(3)) { - if(mouse_holding) { - var _pr_x = _x + mouse_pre_x * _s; - var _pr_y = _y + mouse_pre_y * _s; - var _cr_x = _x + mouse_cur_x * _s; - var _cr_y = _y + mouse_cur_y * _s; - - //draw_set_color(c_red); - //draw_rectangle(_pr_x, _pr_y, _cr_x, _cr_y, 1); + draw_set_color(_col); + if(isUsingTool(0) || isUsingTool(1)) { + if(isUsingTool(1)) draw_set_color(c_white); + + if(key_mod_press(SHIFT)) draw_line_size(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, _siz, _brush); + else draw_point_size(mouse_cur_x, mouse_cur_y, _siz, _brush); + } else if (mouse_holding) { + if(isUsingTool(2)) draw_rect_size(mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, _siz, isUsingTool(2, 1), _brush); + else if(isUsingTool(3)) draw_ellp_size(mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, _siz, isUsingTool(3, 1), _brush); } + surface_reset_shader(); + + surface_set_shader(prev_surface, noone,, BLEND.alpha); + draw_surface_safe(canvas_surface, 0, 0); + + gpu_set_colorwriteenable(tool_attribute.channel[0], tool_attribute.channel[1], tool_attribute.channel[2], tool_attribute.channel[3]); + draw_surface_ext_safe(preview_draw_surface, 0, 0, 1, 1, 0, isUsingTool(1)? c_red : c_white, isUsingTool(1)? 0.2 : _alp); + gpu_set_colorwriteenable(true, true, true, true); + surface_reset_shader(); + + if(_bgr && is_surface(_bg)) + draw_surface_ext(_bg, _x, _y, _s, _s, 0, c_white, _bga); + + draw_surface_ext(prev_surface, _x, _y, _s, _s, 0, c_white, 1); + //if(isUsingTool(1)) { + // gpu_set_blendmode(bm_subtract); + // draw_surface_ext(preview_draw_surface, _x, _y, _s, _s, 0, c_white, 1); + // gpu_set_blendmode(bm_normal); + //} + + if(!isNotUsingTool()) { + surface_set_target(_preview_draw_surface); + DRAW_CLEAR + draw_surface_ext(preview_draw_surface, _x, _y, _s, _s, 0, c_white, 1); + surface_reset_target(); + + shader_set(sh_brush_outline); + shader_set_f("dimension", surface_get_width(_preview_draw_surface), surface_get_height(_preview_draw_surface)); + draw_surface_ext(_preview_draw_surface, 0, 0, 1, 1, 0, c_white, 1); + shader_reset(); } - if(!isNotUsingTool() && point_in_rectangle(mouse_cur_x, mouse_cur_y, 0, 0, _surf_w - 1, _surf_h - 1)) { - var _pr_x = _x + mouse_cur_x * _s; - var _pr_y = _y + mouse_cur_y * _s; - - draw_set_color(c_white); - draw_rectangle(_pr_x, _pr_y, _pr_x + _s - 1, _pr_y + _s - 1, 1); - } + surface_clear(prev_surface); #endregion - } - - static step = function() { - var _outSurf = outputs[| 0].getValue(); - if(!is_surface(_outSurf)) { - _outSurf = surface_create_from_buffer(surface_w, surface_h, surface_buffer); - outputs[| 0].setValue(_outSurf); - } + var _x0 = _x; + var _y0 = _y; + var _x1 = _x0 + _dim[0] * _s; + var _y1 = _y0 + _dim[1] * _s; + + draw_set_color(COLORS.panel_preview_surface_outline); + draw_rectangle(_x0, _y0, _x1 - 1, _y1 - 1, true); + + previewing = 1; } static update = function(frame = PROJECT.animator.current_frame) { + var _dim = inputs[| 0].getValue(); + var _bg = inputs[| 8].getValue(); + var _bga = inputs[| 9].getValue(); + var _bgr = inputs[| 10].getValue(); + + var cDep = attrDepth(); apply_surface(); + + var _outSurf = outputs[| 0].getValue(); + _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], cDep); + + surface_set_shader(_outSurf, noone,, BLEND.alpha); + if(_bgr && is_surface(_bg)) + draw_surface_stretched_ext(_bg, 0, 0, _dim[0], _dim[1], c_white, _bga); + draw_surface_safe(canvas_surface, 0, 0); + surface_reset_shader(); + + outputs[| 0].setValue(_outSurf); } static doSerialize = function(_map) { surface_store_buffer(); - var comp = buffer_compress(surface_buffer, 0, buffer_get_size(surface_buffer)); + var comp = buffer_compress(canvas_buffer, 0, buffer_get_size(canvas_buffer)); var enc = buffer_base64_encode(comp, 0, buffer_get_size(comp)); _map.surface = enc; @@ -633,12 +619,12 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor static doApplyDeserialize = function() { if(!struct_has(load_map, "surface")) return; var buff = buffer_base64_decode(load_map.surface); - surface_buffer = buffer_decompress(buff); + canvas_buffer = buffer_decompress(buff); var _dim = inputs[| 0].getValue(); var _outSurf = outputs[| 0].getValue(); _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth()); - canvas_surface = surface_create_from_buffer(_dim[0], _dim[1], surface_buffer); + canvas_surface = surface_create_from_buffer(_dim[0], _dim[1], canvas_buffer); apply_surface(); } diff --git a/scripts/node_collection/node_collection.gml b/scripts/node_collection/node_collection.gml index ed162702c..44849c491 100644 --- a/scripts/node_collection/node_collection.gml +++ b/scripts/node_collection/node_collection.gml @@ -78,7 +78,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc attributes.w = 128; attributes.h = 128; - array_push(attributeEditors, ["Edit separator", "separator", + array_push(attributeEditors, ["Edit separator", function() { return attributes.separator; }, button(function() { var dia = dialogCall(o_dialog_group_input_order); dia.node = self; diff --git a/scripts/node_composite/node_composite.gml b/scripts/node_composite/node_composite.gml index 8b037b16d..8daf63650 100644 --- a/scripts/node_composite/node_composite.gml +++ b/scripts/node_composite/node_composite.gml @@ -145,12 +145,12 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) if(layer_dragging == noone || layer_dragging == ind) { var _bx = _x + 24; if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 16)) { - draw_sprite_ui_uniform(THEME.hamburger, 3, _bx, _cy + lh / 2, 1, c_white); + draw_sprite_ui_uniform(THEME.hamburger_s, 3, _bx, _cy + lh / 2, 1, c_white); if(mouse_press(mb_left, _focus)) layer_dragging = ind; } else - draw_sprite_ui_uniform(THEME.hamburger, 3, _bx, _cy + lh / 2, 1, COLORS._main_icon); + draw_sprite_ui_uniform(THEME.hamburger_s, 3, _bx, _cy + lh / 2, 1, COLORS._main_icon); } } diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index f2c53e06e..246de46e0 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -1430,7 +1430,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x var amo = min(ds_list_size(inputs), array_length(_inputs)); for(var i = 0; i < amo; i++) { - if(inputs[| i] == noone) continue; + if(inputs[| i] == noone || _inputs[i] == noone) continue; inputs[| i].applyDeserialize(_inputs[i], load_scale, preset); } diff --git a/scripts/node_flood_fill/node_flood_fill.gml b/scripts/node_flood_fill/node_flood_fill.gml index f488d21f7..0be2881fb 100644 --- a/scripts/node_flood_fill/node_flood_fill.gml +++ b/scripts/node_flood_fill/node_flood_fill.gml @@ -35,7 +35,7 @@ function Node_Flood_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _group attributes.fill_iteration = -1; array_push(attributeEditors, "Algorithm"); - array_push(attributeEditors, ["Fill iteration", "fill_iteration", + array_push(attributeEditors, ["Fill iteration", function() { return attributes.fill_iteration; }, new textBox(TEXTBOX_INPUT.number, function(val) { attributes.fill_iteration = val; triggerRender(); diff --git a/scripts/node_image_gif/node_image_gif.gml b/scripts/node_image_gif/node_image_gif.gml index 0aa90f19c..07992d962 100644 --- a/scripts/node_image_gif/node_image_gif.gml +++ b/scripts/node_image_gif/node_image_gif.gml @@ -100,7 +100,7 @@ function Node_Image_gif(_x, _y, _group = noone) : Node(_x, _y, _group) construct static step = function() { if(loading == 2 && spr_builder != noone && spr_builder.building()) { spr = spr_builder._spr; - doUpdate(); + triggerRender(); loading = 0; delete spr_builder; diff --git a/scripts/node_keyframe/node_keyframe.gml b/scripts/node_keyframe/node_keyframe.gml index d614f5edb..11b58af5f 100644 --- a/scripts/node_keyframe/node_keyframe.gml +++ b/scripts/node_keyframe/node_keyframe.gml @@ -10,6 +10,7 @@ function valueKey(_time, _value, _anim = noone, _in = 0, _ot = 0) constructor { value = _value; anim = _anim; + ease_y_lock = true; ease_in = is_array(_in)? _in : [_in, 1]; ease_out = is_array(_ot)? _ot : [_ot, 0]; @@ -398,6 +399,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { _value_list[3] = values[| i].ease_out; _value_list[4] = values[| i].ease_in_type; _value_list[5] = values[| i].ease_out_type; + _value_list[6] = values[| i].ease_y_lock; array_push(_data, _value_list); } @@ -441,6 +443,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { var ease_out = array_safe_get(_keyframe, 3); var ease_in_type = array_safe_get(_keyframe, 4); var ease_out_type = array_safe_get(_keyframe, 5); + var ease_y_lock = array_safe_get(_keyframe, 6, true); var _val = value; @@ -464,6 +467,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { var vk = new valueKey(_time, _val, self, ease_in, ease_out); vk.ease_in_type = ease_in_type; vk.ease_out_type = ease_out_type; + vk.ease_y_lock = ease_y_lock; ds_list_add(values, vk); } } diff --git a/scripts/node_processor/node_processor.gml b/scripts/node_processor/node_processor.gml index 1150bcc82..7657e056e 100644 --- a/scripts/node_processor/node_processor.gml +++ b/scripts/node_processor/node_processor.gml @@ -19,7 +19,7 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct icon = THEME.node_processor; array_push(attributeEditors, "Array processor"); - array_push(attributeEditors, [ "Array process type", "array_process", + array_push(attributeEditors, [ "Array process type", function() { return attributes.array_process; }, new scrollBox([ "Loop", "Hold", "Expand", "Expand inverse" ], function(val) { attributes.array_process = val; diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index 171c4d3e8..1cb94a5e3 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -341,6 +341,7 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { addNodeObject(threeD, "Normal Light", s_node_normal_light, "Node_Normal_Light", [1, Node_Normal_Light],, "Light up the image using normal mapping."); addNodeObject(threeD, "Bevel", s_node_bevel, "Node_Bevel", [1, Node_Bevel], ["shade", "auto shade"], "Apply 2D bevel on the image."); addNodeObject(threeD, "Sprite Stack", s_node_stack, "Node_Sprite_Stack", [1, Node_Sprite_Stack],, "Create sprite stack either from repeating a single image or stacking different images using array."); + ///**/ addNodeObject(threeD, "Depth 3D", s_node_stack, "Node_3D_Depth", [1, Node_3D_Depth],, "Create 3D looking image from depth map.").setVersion(1447); ds_list_add(threeD, "3D generates"); addNodeObject(threeD, "3D Object", s_node_3d_obj, "Node_3D_Obj", [0, Node_create_3D_Obj],, "Load .obj file from your computer as a 3D object."); @@ -419,6 +420,7 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { addNodeObject(compose, "Armature Pose", s_node_armature_pose, "Node_Armature_Pose", [1, Node_Armature_Pose], ["rigging", "bone"]).setVersion(1146); addNodeObject(compose, "Armature Bind", s_node_armature_bind, "Node_Armature_Bind", [1, Node_Armature_Bind], ["rigging", "bone"]).setVersion(1146); addNodeObject(compose, "Armature Path", s_node_armature_path, "Node_Armature_Path", [1, Node_Armature_Path], ["rigging", "bone"]).setVersion(1146); + addNodeObject(compose, "Armature Sample", s_node_armature_sample, "Node_Armature_Sample", [1, Node_Armature_Sample], ["rigging", "bone"]).setVersion(1147); if(!DEMO) { ds_list_add(compose, "Export"); @@ -653,8 +655,8 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { global.VALUE_SUGGESTION[? VALUE_TYPE.d3vertex] = [ ]; global.VALUE_SUGGESTION[? VALUE_TYPE.gradient] = [ "Node_Gradient", "Node_Gradient_Extract" ]; - global.VALUE_SUGGESTION[? VALUE_TYPE.armature] = [ "Node_Armature_Pose", "Node_Armature_Bind" ]; - global.VALUE_SUGGESTION[? VALUE_TYPE.buffer] = [ ]; + global.VALUE_SUGGESTION[? VALUE_TYPE.armature] = [ "Node_Armature_Pose", "Node_Armature_Bind", "Node_Armature_Path", "Node_Armature_Sample" ]; + global.VALUE_SUGGESTION[? VALUE_TYPE.buffer] = [ "Node_Surface_From_Buffer" ]; global.VALUE_SUGGESTION[? VALUE_TYPE.action] = [ ]; #endregion @@ -816,7 +818,7 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { attributes.color_depth = array_find(depth_array, "8 bit RGBA"); if(label) array_push(attributeEditors, "Surface"); - array_push(attributeEditors, ["Color depth", "color_depth", + array_push(attributeEditors, ["Color depth", function() { return attributes.color_depth; }, new scrollBox(depth_array, function(val) { attributes.color_depth = val; triggerRender(); @@ -827,7 +829,7 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { attributes.interpolation = 0; if(label) array_push(attributeEditors, "Surface"); - array_push(attributeEditors, ["Texture interpolation", "interpolation", + array_push(attributeEditors, ["Texture interpolation", function() { return attributes.interpolation; }, new scrollBox(global.SURFACE_INTERPOLATION, function(val) { attributes.interpolation = val; triggerRender(); @@ -838,7 +840,7 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { attributes.oversample = 0; if(label) array_push(attributeEditors, "Surface"); - array_push(attributeEditors, ["Oversample", "oversample", + array_push(attributeEditors, ["Oversample", function() { return attributes.oversample; }, new scrollBox(global.SURFACE_OVERSAMPLE, function(val) { attributes.oversample = val; triggerRender(); @@ -848,7 +850,7 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { function attribute_auto_execute(label = false) { attributes.auto_exe = false; if(label) array_push(attributeEditors, "Node"); - array_push(attributeEditors, ["Auto execute", "auto_exe", + array_push(attributeEditors, ["Auto execute", function() { return attributes.auto_exe; }, new checkBox(function() { attributes.auto_exe = !attributes.auto_exe; })]); diff --git a/scripts/node_seperate_shapes/node_seperate_shapes.gml b/scripts/node_seperate_shapes/node_seperate_shapes.gml index 80f2d9d5b..d19bd39b9 100644 --- a/scripts/node_seperate_shapes/node_seperate_shapes.gml +++ b/scripts/node_seperate_shapes/node_seperate_shapes.gml @@ -36,7 +36,7 @@ function Node_Seperate_Shape(_x, _y, _group = noone) : Node(_x, _y, _group) cons surface_h = 1; attributes.max_shape = 32; - array_push(attributeEditors, ["Maximum shapes", "max_shape", + array_push(attributeEditors, ["Maximum shapes", function() { return attributes.max_shape; }, new textBox(TEXTBOX_INPUT.number, function(val) { attributes.max_shape = val; triggerRender(); diff --git a/scripts/node_surface_replace/node_surface_replace.gml b/scripts/node_surface_replace/node_surface_replace.gml index 7591e9099..4d2f2c9c6 100644 --- a/scripts/node_surface_replace/node_surface_replace.gml +++ b/scripts/node_surface_replace/node_surface_replace.gml @@ -38,8 +38,12 @@ function Node_Surface_Replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _ static matchTemplate = function(_index, _surf, _base, _target, _cthr, _pthr, _fst) { surface_set_shader(_surf, _fst? sh_surface_replace_fast_find : sh_surface_replace_find, false); shader_set_f("dimension", surface_get_width(_base), surface_get_height(_base)); + shader_set_surface("target", _target); - shader_set_f("target_dim", surface_get_width(_target), surface_get_height(_target)); + shader_set_f("targetDimension", surface_get_width(_target), surface_get_height(_target)); + + //print($"{surface_get_width(_base)}, {surface_get_height(_base)} | {surface_get_width(_target)}, {surface_get_height(_target)}"); + shader_set_f("colorThreshold", _cthr); shader_set_f("pixelThreshold", _pthr); shader_set_f("index", _index); diff --git a/scripts/node_tool/node_tool.gml b/scripts/node_tool/node_tool.gml index 866d5fd4b..bc8dc7971 100644 --- a/scripts/node_tool/node_tool.gml +++ b/scripts/node_tool/node_tool.gml @@ -26,22 +26,17 @@ function NodeTool(name, spr) constructor { return self; } - static toggle = function() { + static toggle = function(index = 0) { if(subtools == 0) { PANEL_PREVIEW.tool_current = PANEL_PREVIEW.tool_current == self? noone : self; } else { - if(PANEL_PREVIEW.tool_current != self) { - PANEL_PREVIEW.tool_current = self; - selecting = 0; - return; - } - - selecting++; - if(selecting == subtools) { - selecting = 0; + if(PANEL_PREVIEW.tool_current == self && index == selecting) { PANEL_PREVIEW.tool_current = noone; - } else + selecting = 0; + } else { PANEL_PREVIEW.tool_current = self; + selecting = index; + } } if(PANEL_PREVIEW.tool_current == self) diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 350795be7..862e4eea0 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1023,13 +1023,17 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(type == VALUE_TYPE.trigger) useCache = false; + global.cache_call++; if(useCache) { var cache_hit = cache_value[0]; cache_hit &= cache_value[1] == _time; cache_hit &= cache_value[2] != undefined; cache_hit &= connect_type == JUNCTION_CONNECT.input; cache_hit &= unit.reference == VALUE_UNIT.constant; - if(cache_hit) return cache_value[2]; + if(cache_hit) { + global.cache_hit++; + return cache_value[2]; + } } var val = _getValue(_time, applyUnit, arrIndex); @@ -1117,9 +1121,22 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru val = value_from.getValueRecursive(_time); if(expUse && is_struct(expTree) && expTree.validate()) { + //print($"========== EXPRESSION CALLED =========="); + //print(debug_get_callstack(8)); + printIf(global.FLAG.expression_debug, "==================== EVAL BEGIN ===================="); - var params = { value: val[0] }; - val[0] = expTree.eval(variable_clone(params)); + if(global.EVALUATE_HEAD != noone && global.EVALUATE_HEAD == self) { + //noti_warning($"Expression evaluation error : recursive call detected."); + } else { + global.EVALUATE_HEAD = self; + var params = { + name: name, + node_name: node.display_name, + value: val[0] + }; + val[0] = expTree.eval(variable_clone(params)); + global.EVALUATE_HEAD = noone; + } } return val; diff --git a/scripts/node_wav_file_read/node_wav_file_read.gml b/scripts/node_wav_file_read/node_wav_file_read.gml index 120b3b6da..c3cf5ed54 100644 --- a/scripts/node_wav_file_read/node_wav_file_read.gml +++ b/scripts/node_wav_file_read/node_wav_file_read.gml @@ -79,12 +79,12 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const array_push(attributeEditors, "Audio Preview"); - array_push(attributeEditors, ["Gain", "preview_gain", + array_push(attributeEditors, ["Gain", function() { return attributes.preview_gain; }, new textBox(TEXTBOX_INPUT.number, function(val) { attributes.preview_gain = val; })]); - array_push(attributeEditors, ["Shift", "preview_shift", + array_push(attributeEditors, ["Shift", function() { return attributes.preview_shift; }, new textBox(TEXTBOX_INPUT.number, function(val) { attributes.preview_shift = val; })]); diff --git a/scripts/node_wrap_mesh/node_wrap_mesh.gml b/scripts/node_wrap_mesh/node_wrap_mesh.gml index d942ac1cf..cedec564c 100644 --- a/scripts/node_wrap_mesh/node_wrap_mesh.gml +++ b/scripts/node_wrap_mesh/node_wrap_mesh.gml @@ -58,7 +58,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) array_push(attributeEditors, "Warp"); attributes.iteration = 4; - array_push(attributeEditors, ["Iteration", "iteration", + array_push(attributeEditors, ["Iteration", function() { return attributes.iteration; }, new textBox(TEXTBOX_INPUT.number, function(val) { attributes.iteration = val; triggerRender(); diff --git a/scripts/panel_animation/panel_animation.gml b/scripts/panel_animation/panel_animation.gml index ce966d04e..16f9d32b7 100644 --- a/scripts/panel_animation/panel_animation.gml +++ b/scripts/panel_animation/panel_animation.gml @@ -239,6 +239,11 @@ function Panel_Animation() : PanelContent() constructor { } keyframe_menu = [ + menuItem(__txtx("panel_animation_lock_y", "Lock/Unlock Y easing"), function() { + for( var i = 0; i < array_length(keyframe_selecting); i++ ) { + var k = keyframe_selecting[i]; + k.ease_y_lock = !k.ease_y_lock; + } }), menuItemGroup(__txtx("panel_animation_ease_in", "Ease in"), [ [ [THEME.timeline_ease, 0], function() { for( var i = 0; i < array_length(keyframe_selecting); i++ ) { @@ -823,13 +828,13 @@ function Panel_Animation() : PanelContent() constructor { if(pHOVER && point_in_circle(msx, msy, _tx, prop_dope_y, ui(6))) { key_hover = key; - draw_sprite_ui_uniform(THEME.timeline_keyframe, 2, _tx, prop_dope_y, 1, COLORS.panel_animation_keyframe_selected); + draw_sprite_ui_uniform(THEME.timeline_keyframe, key.ease_y_lock? 2 : 5, _tx, prop_dope_y, 1, COLORS.panel_animation_keyframe_selected); if(mouse_press(mb_left, pFOCUS)) { keyframe_dragging = animator.values[| k]; keyframe_drag_type = KEYFRAME_DRAG_TYPE.ease_in; } } else - draw_sprite_ui_uniform(THEME.timeline_keyframe, 2, _tx, prop_dope_y, 1, COLORS.panel_animation_keyframe_unselected); + draw_sprite_ui_uniform(THEME.timeline_keyframe, key.ease_y_lock? 2 : 5, _tx, prop_dope_y, 1, COLORS.panel_animation_keyframe_unselected); } if(key.ease_out_type == CURVE_TYPE.bezier) { @@ -839,13 +844,13 @@ function Panel_Animation() : PanelContent() constructor { if(pHOVER && point_in_circle(msx, msy, _tx, prop_dope_y, ui(6))) { key_hover = key; - draw_sprite_ui_uniform(THEME.timeline_keyframe, 3, _tx, prop_dope_y, 1, COLORS.panel_animation_keyframe_selected); + draw_sprite_ui_uniform(THEME.timeline_keyframe, key.ease_y_lock? 3 : 5, _tx, prop_dope_y, 1, COLORS.panel_animation_keyframe_selected); if(mouse_press(mb_left, pFOCUS)) { keyframe_dragging = animator.values[| k]; keyframe_drag_type = KEYFRAME_DRAG_TYPE.ease_out; } } else - draw_sprite_ui_uniform(THEME.timeline_keyframe, 3, _tx, prop_dope_y, 1, COLORS.panel_animation_keyframe_unselected); + draw_sprite_ui_uniform(THEME.timeline_keyframe, key.ease_y_lock? 3 : 5, _tx, prop_dope_y, 1, COLORS.panel_animation_keyframe_unselected); } } @@ -1370,7 +1375,7 @@ function Panel_Animation() : PanelContent() constructor { dx = clamp(dx, 0, 1); if(dx > 0.2) keyframe_dragout = true; - var dy = (my - keyframe_drag_my) / 32; + var dy = -(my - keyframe_drag_my) / 32; var _in = keyframe_dragging.ease_in; var _ot = keyframe_dragging.ease_out; @@ -1380,7 +1385,10 @@ function Panel_Animation() : PanelContent() constructor { for( var i = 0; i < array_length(keyframe_selecting); i++ ) { var k = keyframe_selecting[i]; k.ease_in_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.none; + k.ease_in[0] = dx; + if(!k.ease_y_lock) + k.ease_in[1] = dy; } break; @@ -1388,7 +1396,10 @@ function Panel_Animation() : PanelContent() constructor { for( var i = 0; i < array_length(keyframe_selecting); i++ ) { var k = keyframe_selecting[i]; k.ease_out_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.none; + k.ease_out[0] = dx; + if(!k.ease_y_lock) + k.ease_out[1] = dy; } break; case KEYFRAME_DRAG_TYPE.ease_both : @@ -1398,7 +1409,12 @@ function Panel_Animation() : PanelContent() constructor { k.ease_out_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.none; k.ease_in[0] = dx; + if(!k.ease_y_lock) + k.ease_in[1] = dy; + k.ease_out[0] = dx; + if(!k.ease_y_lock) + k.ease_out[1] = dy; } break; } diff --git a/scripts/panel_inspector/panel_inspector.gml b/scripts/panel_inspector/panel_inspector.gml index 351d025e5..95dee9156 100644 --- a/scripts/panel_inspector/panel_inspector.gml +++ b/scripts/panel_inspector/panel_inspector.gml @@ -328,8 +328,7 @@ function Panel_Inspector() : PanelContent() constructor { continue; } - var val = inspecting.attributes[$ edt[1]]; - if(is_undefined(val)) continue; + var val = edt[1](); edt[2].setFocusHover(pFOCUS, pHOVER); if(instanceof(edt[2]) == "buttonClass") { @@ -470,7 +469,7 @@ function Panel_Inspector() : PanelContent() constructor { if(jun.connect_type == JUNCTION_CONNECT.input && jun.type == VALUE_TYPE.color && jun.display_type == VALUE_DISPLAY._default) { pickers[color_picker_index] = jun; if(color_picker_index == picker_index) { - if(ALT == KEYBOARD_STATUS.down) + if(ALT == KEYBOARD_STATUS.down && WIDGET_CURRENT == noone) jun.editWidget.onColorPick(); color_picker_selecting = jun; } diff --git a/scripts/panel_preview/panel_preview.gml b/scripts/panel_preview/panel_preview.gml index 915c29297..cef7a2dca 100644 --- a/scripts/panel_preview/panel_preview.gml +++ b/scripts/panel_preview/panel_preview.gml @@ -287,9 +287,9 @@ function Panel_Preview() : PanelContent() constructor { return; } - var ss = min((w - 32) / bbox.w, (h - 32 - toolbar_height * 2) / bbox.h); + var ss = min((w - 32 - tool_side_drawing * 40) / bbox.w, (h - 32 - toolbar_height * 2) / bbox.h); canvas_s = ss; - canvas_x = w / 2 - bbox.w * canvas_s / 2 - bbox.x0 * canvas_s; + canvas_x = w / 2 - bbox.w * canvas_s / 2 - bbox.x0 * canvas_s + (tool_side_drawing * 40 / 2); canvas_y = h / 2 - bbox.h * canvas_s / 2 - bbox.y0 * canvas_s; } @@ -652,26 +652,27 @@ function Panel_Preview() : PanelContent() constructor { } } + tool_hovering = false; + tool_side_drawing = false; + function drawNodeTools(active, _node) { var _mx = mx; var _my = my; var isHover = pHOVER && mouse_on_preview; - - if(_node.tools != -1) { - var xx = ui(8); - var yy = ui(40); - - for(var i = 0; i < array_length(_node.tools); i++) { - var b = buttonInstant(THEME.button, xx, yy, ui(40), ui(40), [_mx, _my], pFOCUS, isHover); - if(b > 0) active = false; - yy += ui(48); - } - } + var tool_width = ui(40); + var tool_size = ui(32); var cx = canvas_x + _node.preview_x * canvas_s; var cy = canvas_y + _node.preview_y * canvas_s; var _snx = 0, _sny = 0; + tool_side_drawing = _node.tools != -1; + + if(_node.tools != -1 && point_in_rectangle(_mx, _my, 0, 0, tool_width, h)) { + isHover = false; + mouse_on_preview = false; + } + if(key_mod_press(CTRL)) { _snx = grid_show? grid_width : 1; _sny = grid_show? grid_height : 1; @@ -680,39 +681,91 @@ function Panel_Preview() : PanelContent() constructor { _sny = grid_height; } - var overlayHover = active && isHover && point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height); - if(_node.tools != -1) - overlayHover &= mx > ui(48); - - _node.drawOverlay(overlayHover && !key_mod_press(CTRL), cx, cy, canvas_s, _mx, _my, _snx, _sny, { w: w, h: h }); + var overlayHover = tool_hovering == noone; + overlayHover &= active && isHover; + overlayHover &= point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height); + overlayHover &= !key_mod_press(CTRL); + + _node.drawOverlay(overlayHover, cx, cy, canvas_s, _mx, _my, _snx, _sny, { w: w, h: h }); + + draw_sprite_stretched(THEME.tool_side, 1, 0, 0, tool_width, h); + + var _tool = tool_hovering; + tool_hovering = noone; if(_node.tools != -1) { - var xx = ui(8); - var yy = ui(40); + var xx = ui(1) + tool_width / 2; + var yy = ui(34) + tool_size / 2; + var pd = 2; for(var i = 0; i < array_length(_node.tools); i++) { - var b = buttonInstant(THEME.button, xx, yy, ui(40), ui(40), [_mx, _my], pFOCUS, isHover); var tool = _node.tools[i]; + var _x0 = xx - tool_size / 2; + var _y0 = yy - tool_size / 2; + var _x1 = xx + tool_size / 2; + var _y1 = yy + tool_size / 2; - if(b == 1) { - TOOLTIP = tool.name; - mouse_on_preview = false; - } if(b == 2) - tool.toggle(); + if(point_in_rectangle(_mx, _my, _x0, _y0 + 1, _x1, _y1 - 1)) { + tool_hovering = tool; + } - if(pFOCUS && WIDGET_CURRENT == noone && keyboard_check_pressed(ord(string(i + 1)))) - tool.toggle(); + if(tool.subtools > 0 && _tool == tool) { + var s_ww = tool_size * tool.subtools; + var s_hh = tool_size; + draw_sprite_stretched(THEME.menu_bg, 0, _x0 - pd, _y0 - pd, s_ww + pd * 2, s_hh + pd * 2); + + var stool = tool.spr; + + for( var j = 0; j < array_length(stool); j++ ) { + var _sxx = xx + j * tool_size; + var _syy = yy; + + var _sx0 = _sxx - tool_size / 2; + var _sy0 = _syy - tool_size / 2; + var _sx1 = _sxx + tool_size / 2; + var _sy1 = _syy + tool_size / 2; - if(tool_current == tool) { - draw_sprite_stretched(THEME.button, 2, xx, yy, ui(40), ui(40)); - draw_sprite_stretched_ext(THEME.button, 3, xx, yy, ui(40), ui(40), COLORS._main_accent, 1); + if(point_in_rectangle(_mx, _my, _sx0, _sy0 + 1, _sx1, _sy1 - 1)) { + draw_sprite_stretched(THEME.button_hide, 1, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2); + + if(mouse_press(mb_left, pFOCUS)) + tool.toggle(j); + } + + if(tool_current == tool && tool.selecting == j) { + draw_sprite_stretched_ext(THEME.button_hide, 2, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS.panel_preview_grid, 1); + draw_sprite_stretched_ext(THEME.button_hide, 3, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS._main_accent, 1); + } + + draw_sprite_colored(stool[j], 0, _sxx, _syy); + } + + if(point_in_rectangle(_mx, _my, _x0, _y0 + 1, _x0 + s_ww, _y1 - 1)) { + tool_hovering = tool; + TOOLTIP = tool.name; + } + } else { + if(tool_hovering == tool) { + draw_sprite_stretched(THEME.button_hide, 1, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2); + TOOLTIP = tool.name; + + if(mouse_press(mb_left, pFOCUS)) + tool.toggle(); + } + + if(pFOCUS && WIDGET_CURRENT == noone && keyboard_check_pressed(ord(string(i + 1)))) + tool.toggle(); + + if(tool_current == tool) { + draw_sprite_stretched_ext(THEME.button_hide, 2, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS.panel_preview_grid, 1); + draw_sprite_stretched_ext(THEME.button_hide, 3, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS._main_accent, 1); + } + + if(tool.subtools > 0) draw_sprite_colored(tool.spr[tool.selecting], 0, xx, yy); + else draw_sprite_colored(tool.spr, 0, xx, yy); } - if(tool.subtools > 0) - draw_sprite_colored(tool.spr[tool.selecting], 0, xx + ui(20), yy + ui(20)); - else - draw_sprite_colored(tool.spr, 0, xx + ui(20), yy + ui(20)); - yy += ui(48); + yy += tool_size; } } else tool_current = noone; diff --git a/scripts/render_data/render_data.gml b/scripts/render_data/render_data.gml index b907dcc0c..442d13de8 100644 --- a/scripts/render_data/render_data.gml +++ b/scripts/render_data/render_data.gml @@ -271,6 +271,6 @@ function RenderListAction(list, context = PANEL_GRAPH.getCurrentContext()) { printIf(global.FLAG.render, "=== RENDER COMPLETE IN {" + string(current_time - t) + "ms} ===\n"); } catch(e) { - noti_waning(exception_print(e)); + noti_warning(exception_print(e)); } } \ No newline at end of file diff --git a/scripts/shader_functions/shader_functions.gml b/scripts/shader_functions/shader_functions.gml index 85b6a5456..17bc9c6d9 100644 --- a/scripts/shader_functions/shader_functions.gml +++ b/scripts/shader_functions/shader_functions.gml @@ -57,6 +57,20 @@ function shader_set_surface(sampler, surface) { texture_set_stage(t, surface_get_texture(surface)); } +function shader_set_surface_dimension(uniform, surface) { + var shader = shader_current(); + if(!is_surface(surface)) return; + + var texture = surface_get_texture(surface); + var tw = texture_get_texel_width(texture); + var th = texture_get_texel_height(texture); + + tw = 2048; + th = 2048; + + shader_set_uniform_f(shader_get_uniform(shader, uniform), tw, th); +} + #region prebuild enum BLEND { normal, @@ -91,7 +105,12 @@ function shader_set_surface(sampler, surface) { case BLEND.alphamulp: BLEND_ALPHA_MULP; break; } - shader_set(shader); + if(shader == noone) + __shader_set = false; + else { + __shader_set = true; + shader_set(shader); + } } function surface_reset_shader() { @@ -100,6 +119,8 @@ function shader_set_surface(sampler, surface) { gpu_set_tex_filter(false); BLEND_NORMAL; surface_reset_target(); - shader_reset(); + + if(__shader_set) + shader_reset(); } #endregion \ No newline at end of file diff --git a/scripts/string_eval/string_eval.gml b/scripts/string_eval/string_eval.gml index 4070fff82..8cb45b670 100644 --- a/scripts/string_eval/string_eval.gml +++ b/scripts/string_eval/string_eval.gml @@ -1,4 +1,6 @@ #region data + global.EVALUATE_HEAD = noone; + global.EQUATION_PRES = ds_map_create(); global.EQUATION_PRES[? "+"] = 1; global.EQUATION_PRES[? "-"] = 1; @@ -30,6 +32,7 @@ global.FUNCTIONS[? "sin"] = [ ["radian"], function(val) { return sin(val[0]); } ]; global.FUNCTIONS[? "cos"] = [ ["radian"], function(val) { return cos(val[0]); } ]; global.FUNCTIONS[? "tan"] = [ ["radian"], function(val) { return tan(val[0]); } ]; + global.FUNCTIONS[? "abs"] = [ ["number"], function(val) { return abs(val[0]); } ]; global.FUNCTIONS[? "round"] = [ ["number"], function(val) { return round(val[0]); } ]; global.FUNCTIONS[? "ceil"] = [ ["number"], function(val) { return ceil(val[0]); } ]; @@ -37,12 +40,20 @@ global.FUNCTIONS[? "lerp"] = [ ["number_0", "number_1", "amount"], function(val) { return lerp(array_safe_get(val, 0), array_safe_get(val, 1), array_safe_get(val, 2)); } ]; - global.FUNCTIONS[? "wiggle"] = [ ["time", "frequency", "octave", "seed"], function(val) { - return wiggle(0, 1, array_safe_get(val, 1), - array_safe_get(val, 0), - array_safe_get(val, 3, 0), - array_safe_get(val, 2, 1)); - } ]; + global.FUNCTIONS[? "wiggle"] = [ ["time", "frequency", "octave = 1", "seed = 0"], function(val) { + return wiggle(0, 1, array_safe_get(val, 1), + array_safe_get(val, 0), + array_safe_get(val, 3, 0), + array_safe_get(val, 2, 1)); + } ]; + global.FUNCTIONS[? "random"] = [ ["min = 0", "max = 1"], function(val) { + return random_range(array_safe_get(val, 0, 0), + array_safe_get(val, 1, 1)); + } ]; + global.FUNCTIONS[? "irandom"] = [ ["min = 0", "max = 1"], function(val) { + return irandom_range(array_safe_get(val, 0, 0), + array_safe_get(val, 1, 1)); + } ]; #endregion function functionStringClean(fx) { @@ -263,7 +274,7 @@ function functionStringClean(fx) { if(!ds_map_exists(PROJECT.nodeNameMap, strs[0])) return false; - array_push_unique(dependency, strs[0]) + array_push_unique(dependency, strs[0]); return true; } diff --git a/scripts/surface_functions/surface_functions.gml b/scripts/surface_functions/surface_functions.gml index 897987eaa..03e544e6c 100644 --- a/scripts/surface_functions/surface_functions.gml +++ b/scripts/surface_functions/surface_functions.gml @@ -141,6 +141,12 @@ function surface_get_pixel_ext(surface, _x, _y) { } //create +function surface_create_empty(w, h) { + var s = surface_create(w, h); + surface_clear(s); + return s; +} + function surface_create_size(surface, format = surface_rgba8unorm) { var s = surface_create_valid(surface_get_width(surface), surface_get_height(surface), format); surface_set_target(s); @@ -249,6 +255,13 @@ function surface_size_to(surface, width, height, format = noone) { return surface; } +function surface_clear(surface) { + if(!is_surface(surface)) return; + surface_set_target(surface); + DRAW_CLEAR + surface_reset_target(); +} + function surface_copy_from(dst, src, format = noone) { surface_set_target(dst); DRAW_CLEAR diff --git a/shaders/sh_3d_depth/sh_3d_depth.fsh b/shaders/sh_3d_depth/sh_3d_depth.fsh new file mode 100644 index 000000000..adabba87c --- /dev/null +++ b/shaders/sh_3d_depth/sh_3d_depth.fsh @@ -0,0 +1,79 @@ +// +// Simple passthrough fragment shader +// +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform sampler2D texMap; +uniform vec2 dimension; + +uniform sampler2D depthMap; +uniform vec2 depthDimension; + +uniform float depth; + +uniform vec3 cameraPos; +uniform vec3 cameraUp; +uniform vec3 cameraRight; + +bool rayHitCube(vec3 rayStart, vec3 rayDirection, vec3 cubeCenter, vec3 cubeSpan) { + // Calculate the minimum and maximum bounds of the cube + vec3 cubeMin = cubeCenter - cubeSpan * 0.5; + vec3 cubeMax = cubeCenter + cubeSpan * 0.5; + + // Calculate the inverse direction of the ray + vec3 invRayDir = 1.0 / rayDirection; + + // Calculate the intersection distances with the cube's bounding planes + vec3 tMin = (cubeMin - rayStart) * invRayDir; + vec3 tMax = (cubeMax - rayStart) * invRayDir; + + // Find the largest entry among the intersection distances + vec3 tNear = min(tMin, tMax); + vec3 tFar = max(tMin, tMax); + + // Find the largest entry among the intersection distances + float t0 = max(max(tNear.x, tNear.y), tNear.z); + float t1 = min(min(tFar.x, tFar.y), tFar.z); + + // Check if there is a valid intersection + return t0 <= t1; +} + +void main() { + vec3 cameraPixelPosition = cameraPos + (v_vTexcoord.x - 0.5) * cameraRight + (v_vTexcoord.y - 0.5) * cameraUp; + vec3 cameraForward = -cameraPos; + + float minDist = 99999.; + vec2 hitPos = vec2(0.); + vec3 cubeSpan = vec3(.5 / dimension.x, .5 / dimension.y, .5 / dimension.x); + + for(float i = 0.; i < dimension.x; i++) + for(float j = 0.; j < dimension.y; j++) { + vec4 _dsample = texture2D( gm_BaseTexture, vec2(i, j) / dimension ); + float _d = depth * (_dsample.x + _dsample.y + _dsample.z) / 3.; + + vec3 cubePos = vec3(i, j, _d); + + float dist = distance(cameraPixelPosition, cubePos); + if(dist <= minDist) + if(rayHitCube(cameraPixelPosition, cameraForward, cubePos, cubeSpan)) { + minDist = dist; + hitPos = vec2(i, j) / dimension; + } + + cubePos = vec3(i, j, -_d); + + dist = distance(cameraPixelPosition, cubePos); + if(dist <= minDist) + if(rayHitCube(cameraPixelPosition, cameraForward, cubePos, cubeSpan)) { + minDist = dist; + hitPos = vec2(i, j) / dimension; + } + } + + if(minDist == 99999.) + gl_FragColor = vec4(0.); + else + gl_FragColor = texture2D( gm_BaseTexture, hitPos ); +} diff --git a/shaders/sh_3d_depth/sh_3d_depth.vsh b/shaders/sh_3d_depth/sh_3d_depth.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_3d_depth/sh_3d_depth.vsh @@ -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; +} diff --git a/shaders/sh_3d_depth/sh_3d_depth.yy b/shaders/sh_3d_depth/sh_3d_depth.yy new file mode 100644 index 000000000..6b2bc9fe7 --- /dev/null +++ b/shaders/sh_3d_depth/sh_3d_depth.yy @@ -0,0 +1,10 @@ +{ + "resourceType": "GMShader", + "resourceVersion": "1.0", + "name": "sh_3d_depth", + "parent": { + "name": "3d", + "path": "folders/shader/3d.yy", + }, + "type": 1, +} \ No newline at end of file diff --git a/shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.fsh b/shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.fsh new file mode 100644 index 000000000..e49a29bf8 --- /dev/null +++ b/shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.fsh @@ -0,0 +1,29 @@ +// +// Simple passthrough fragment shader +// +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec2 dimension; + +void main() { + vec2 texel = 1. / dimension; + + vec4 c = texture2D( gm_BaseTexture, v_vTexcoord ); + vec4 c0 = texture2D( gm_BaseTexture, v_vTexcoord + vec2(texel.x, 0.) ); + vec4 c1 = texture2D( gm_BaseTexture, v_vTexcoord - vec2(texel.x, 0.) ); + vec4 c2 = texture2D( gm_BaseTexture, v_vTexcoord + vec2(0., texel.y) ); + vec4 c3 = texture2D( gm_BaseTexture, v_vTexcoord - vec2(0., texel.y) ); + + int _c = c .a > 0.? 1 : 0; + int _c0 = c0.a > 0.? 1 : 0; + int _c1 = c1.a > 0.? 1 : 0; + int _c2 = c2.a > 0.? 1 : 0; + int _c3 = c3.a > 0.? 1 : 0; + + if(_c == 0 && _c0 + _c1 + _c2 + _c3 >= 2) { + gl_FragColor = ((c0 * c0.a) + (c1 * c1.a) + (c2 * c2.a) + (c3 * c3.a)) / (c0.a + c1.a + c2.a + c3.a); + gl_FragColor.a = 1.; + } else + gl_FragColor = c; +} diff --git a/shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.vsh b/shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.vsh @@ -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; +} diff --git a/shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.yy b/shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.yy new file mode 100644 index 000000000..4ec3d5af6 --- /dev/null +++ b/shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.yy @@ -0,0 +1,10 @@ +{ + "resourceType": "GMShader", + "resourceVersion": "1.0", + "name": "sh_3d_extrude_corner", + "parent": { + "name": "3d", + "path": "folders/shader/3d.yy", + }, + "type": 1, +} \ No newline at end of file diff --git a/shaders/sh_3d_extrude_filler/sh_3d_extrude_filler.fsh b/shaders/sh_3d_extrude_filler/sh_3d_extrude_filler.fsh new file mode 100644 index 000000000..92c9605a0 --- /dev/null +++ b/shaders/sh_3d_extrude_filler/sh_3d_extrude_filler.fsh @@ -0,0 +1,29 @@ +// +// Simple passthrough fragment shader +// +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec2 dimension; + +void main() { + vec2 texel = 1. / dimension; + + vec4 c = texture2D( gm_BaseTexture, v_vTexcoord ); + vec4 c0 = texture2D( gm_BaseTexture, v_vTexcoord + vec2(texel.x, 0.) ); + vec4 c1 = texture2D( gm_BaseTexture, v_vTexcoord - vec2(texel.x, 0.) ); + vec4 c2 = texture2D( gm_BaseTexture, v_vTexcoord + vec2(0., texel.y) ); + vec4 c3 = texture2D( gm_BaseTexture, v_vTexcoord - vec2(0., texel.y) ); + + int _c = c .a > 0.? 1 : 0; + int _c0 = c0.a > 0.? 1 : 0; + int _c1 = c1.a > 0.? 1 : 0; + int _c2 = c2.a > 0.? 1 : 0; + int _c3 = c3.a > 0.? 1 : 0; + + if(_c == 0 && _c0 + _c1 + _c2 + _c3 >= 3) { + gl_FragColor = ((c0 * c0.a) + (c1 * c1.a) + (c2 * c2.a) + (c3 * c3.a)) / (c0.a + c1.a + c2.a + c3.a); + gl_FragColor.a = 1.; + } else + gl_FragColor = c; +} diff --git a/shaders/sh_3d_extrude_filler/sh_3d_extrude_filler.vsh b/shaders/sh_3d_extrude_filler/sh_3d_extrude_filler.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_3d_extrude_filler/sh_3d_extrude_filler.vsh @@ -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; +} diff --git a/shaders/sh_3d_extrude_filler/sh_3d_extrude_filler.yy b/shaders/sh_3d_extrude_filler/sh_3d_extrude_filler.yy new file mode 100644 index 000000000..22b0434c7 --- /dev/null +++ b/shaders/sh_3d_extrude_filler/sh_3d_extrude_filler.yy @@ -0,0 +1,10 @@ +{ + "resourceType": "GMShader", + "resourceVersion": "1.0", + "name": "sh_3d_extrude_filler", + "parent": { + "name": "3d", + "path": "folders/shader/3d.yy", + }, + "type": 1, +} \ No newline at end of file diff --git a/shaders/sh_3d_extrude_filler_depth/sh_3d_extrude_filler_depth.fsh b/shaders/sh_3d_extrude_filler_depth/sh_3d_extrude_filler_depth.fsh new file mode 100644 index 000000000..261e932bf --- /dev/null +++ b/shaders/sh_3d_extrude_filler_depth/sh_3d_extrude_filler_depth.fsh @@ -0,0 +1,28 @@ +// +// Simple passthrough fragment shader +// +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec2 dimension; + +void main() { + vec2 texel = 1. / dimension; + + vec4 c = texture2D( gm_BaseTexture, v_vTexcoord ); + vec4 c0 = texture2D( gm_BaseTexture, v_vTexcoord + vec2(texel.x, 0.) ); + vec4 c1 = texture2D( gm_BaseTexture, v_vTexcoord - vec2(texel.x, 0.) ); + vec4 c2 = texture2D( gm_BaseTexture, v_vTexcoord + vec2(0., texel.y) ); + vec4 c3 = texture2D( gm_BaseTexture, v_vTexcoord - vec2(0., texel.y) ); + + int _c = (c .r) > 0.? 1 : 0; + int _c0 = (c0.r) > 0.? 1 : 0; + int _c1 = (c1.r) > 0.? 1 : 0; + int _c2 = (c2.r) > 0.? 1 : 0; + int _c3 = (c3.r) > 0.? 1 : 0; + + if(_c == 0 && _c0 + _c1 + _c2 + _c3 >= 3) { + gl_FragColor = max(c0, max(c1, max(c2, c3))); + } else + gl_FragColor = c; +} diff --git a/shaders/sh_3d_extrude_filler_depth/sh_3d_extrude_filler_depth.vsh b/shaders/sh_3d_extrude_filler_depth/sh_3d_extrude_filler_depth.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_3d_extrude_filler_depth/sh_3d_extrude_filler_depth.vsh @@ -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; +} diff --git a/shaders/sh_3d_extrude_filler_depth/sh_3d_extrude_filler_depth.yy b/shaders/sh_3d_extrude_filler_depth/sh_3d_extrude_filler_depth.yy new file mode 100644 index 000000000..2c44b049d --- /dev/null +++ b/shaders/sh_3d_extrude_filler_depth/sh_3d_extrude_filler_depth.yy @@ -0,0 +1,10 @@ +{ + "resourceType": "GMShader", + "resourceVersion": "1.0", + "name": "sh_3d_extrude_filler_depth", + "parent": { + "name": "3d", + "path": "folders/shader/3d.yy", + }, + "type": 1, +} \ No newline at end of file diff --git a/shaders/sh_brush_outline/sh_brush_outline.fsh b/shaders/sh_brush_outline/sh_brush_outline.fsh new file mode 100644 index 000000000..a4e4768b6 --- /dev/null +++ b/shaders/sh_brush_outline/sh_brush_outline.fsh @@ -0,0 +1,22 @@ +// +// Simple passthrough fragment shader +// +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec2 dimension; + +void main() { + gl_FragColor = vec4(0.); + + vec2 tx = 1. / dimension; + + float p = texture2D( gm_BaseTexture, v_vTexcoord ).a > 0.? 1. : 0.; + float p1 = texture2D( gm_BaseTexture, v_vTexcoord - vec2(0., tx.y) ).a > 0.? 1. : 0.; + float p3 = texture2D( gm_BaseTexture, v_vTexcoord - vec2(tx.x, 0.) ).a > 0.? 1. : 0.; + float p5 = texture2D( gm_BaseTexture, v_vTexcoord + vec2(tx.x, 0.) ).a > 0.? 1. : 0.; + float p7 = texture2D( gm_BaseTexture, v_vTexcoord + vec2(0., tx.y) ).a > 0.? 1. : 0.; + + if(p == 0. && (p1 != p7 || p3 != p5)) + gl_FragColor = v_vColour; +} diff --git a/shaders/sh_brush_outline/sh_brush_outline.vsh b/shaders/sh_brush_outline/sh_brush_outline.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_brush_outline/sh_brush_outline.vsh @@ -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; +} diff --git a/shaders/sh_brush_outline/sh_brush_outline.yy b/shaders/sh_brush_outline/sh_brush_outline.yy new file mode 100644 index 000000000..816689258 --- /dev/null +++ b/shaders/sh_brush_outline/sh_brush_outline.yy @@ -0,0 +1,10 @@ +{ + "resourceType": "GMShader", + "resourceVersion": "1.0", + "name": "sh_brush_outline", + "parent": { + "name": "draw", + "path": "folders/shader/draw.yy", + }, + "type": 1, +} \ No newline at end of file diff --git a/shaders/sh_surface_replace_fast_find/sh_surface_replace_fast_find.fsh b/shaders/sh_surface_replace_fast_find/sh_surface_replace_fast_find.fsh index da0ef2b91..11046e5a9 100644 --- a/shaders/sh_surface_replace_fast_find/sh_surface_replace_fast_find.fsh +++ b/shaders/sh_surface_replace_fast_find/sh_surface_replace_fast_find.fsh @@ -5,8 +5,10 @@ varying vec2 v_vTexcoord; varying vec4 v_vColour; uniform vec2 dimension; + uniform sampler2D target; -uniform vec2 target_dim; +uniform vec2 targetDimension; + uniform float colorThreshold; uniform float pixelThreshold; uniform float index; @@ -19,42 +21,33 @@ float random (in vec2 st) { return fract(sin(dot(st.xy + seed, vec2(12.9898, 78. float round(float val) { return fract(val) > 0.5? ceil(val) : floor(val); } void main() { - vec4 base = texture2D( gm_BaseTexture, v_vTexcoord ); - if(base.a == 0.) { - gl_FragColor = vec4(0.); - return; - } - - vec2 px = v_vTexcoord * dimension; - float pixels_count = target_dim.x * target_dim.y; - float target_pixels = pixels_count * (1. - pixelThreshold); - float content_px = 0.; - float match = 0.; - vec2 baseTx = 1. / dimension; - vec2 targTx = 1. / target_dim; - gl_FragColor = vec4(0.); - for( float i = 0.; i < target_dim.x; i++ ) - for( float j = 0.; j < target_dim.y; j++ ) { - vec4 targ = texture2D( target, vec2(i, j) * targTx ); + vec4 base = texture2D( gm_BaseTexture, v_vTexcoord ); + if(base.a == 0.) + return; + + vec2 px = v_vTexcoord * dimension; + float target_pixels = targetDimension.x * targetDimension.y * (1. - pixelThreshold); + float match = 0.; + vec2 baseTx = 1. / dimension; + vec2 targTx = 1. / targetDimension; + + for( float i = 0.; i < targetDimension.x; i++ ) + for( float j = 0.; j < targetDimension.y; j++ ) { + vec4 targ = texture2D( target, vec2(0.5 + i, 0.5 + j) * targTx ); if(targ.a == 0.) continue; vec2 bpx = px + vec2(i, j); vec4 base = texture2D( gm_BaseTexture, bpx * baseTx ); - content_px++; if(distance(base, targ) <= 2. * colorThreshold) { match++; if(match >= target_pixels) { - gl_FragColor = vec4(1., index, 0., 1.); + float ind = mode == 0? index : round(random(v_vTexcoord) * (size - 1.)) / size; + gl_FragColor = vec4(1., ind, 0., 1.); return; } } } - - if(match / content_px >= (1. - pixelThreshold)) { - float ind = mode == 0? index : round(random(v_vTexcoord) * (size - 1.)) / size; - gl_FragColor = vec4(1., ind, 0., 1.); - } } diff --git a/shaders/sh_surface_replace_fast_replace/sh_surface_replace_fast_replace.fsh b/shaders/sh_surface_replace_fast_replace/sh_surface_replace_fast_replace.fsh index 0fc665cf2..b0ccfe491 100644 --- a/shaders/sh_surface_replace_fast_replace/sh_surface_replace_fast_replace.fsh +++ b/shaders/sh_surface_replace_fast_replace/sh_surface_replace_fast_replace.fsh @@ -13,13 +13,18 @@ uniform float index; void main() { gl_FragColor = vec4(0.); - vec2 px = v_vTexcoord * dimension - replace_dim; + vec2 px = v_vTexcoord * dimension - (replace_dim - 1.); + for( float i = 0.; i < replace_dim.x; i++ ) for( float j = 0.; j < replace_dim.y; j++ ) { - vec2 uv = px + vec2(i, j) + 1.; + vec2 uv = px + vec2(i, j); + if(uv.x < 0. || uv.y < 0.) continue; + vec4 wg = texture2D( findRes, uv / dimension ); + if(wg.r == 1. && abs(wg.g - index) < 0.01) { - gl_FragColor = texture2D( replace, (replace_dim - vec2(i, j) - 1.) / replace_dim ); + gl_FragColor = texture2D( replace, (replace_dim - vec2(i, j) - 1. + .5) / replace_dim ); + //gl_FragColor = vec4((replace_dim - vec2(i, j)) / replace_dim, 0., 1.); return; } } diff --git a/shaders/sh_surface_replace_find/sh_surface_replace_find.fsh b/shaders/sh_surface_replace_find/sh_surface_replace_find.fsh index 098a6ef47..f9495b608 100644 --- a/shaders/sh_surface_replace_find/sh_surface_replace_find.fsh +++ b/shaders/sh_surface_replace_find/sh_surface_replace_find.fsh @@ -5,8 +5,10 @@ varying vec2 v_vTexcoord; varying vec4 v_vColour; uniform vec2 dimension; + uniform sampler2D target; -uniform vec2 target_dim; +uniform vec2 targetDimension; + uniform float colorThreshold; uniform float pixelThreshold; uniform float index; @@ -19,34 +21,32 @@ float random (in vec2 st) { return fract(sin(dot(st.xy + seed, vec2(12.9898, 78. float round(float val) { return fract(val) > 0.5? ceil(val) : floor(val); } vec2 baseTx = 1. / dimension; -vec2 targTx = 1. / target_dim; +vec2 targTx = 1. / targetDimension; float matchTemplate(vec2 pos) { float _match = 0.; - float content_px = 0.; - for( float i = 0.; i < target_dim.x; i++ ) - for( float j = 0.; j < target_dim.y; j++ ) { - vec4 targ = texture2D( target, vec2(i, j) * targTx ); + for( float i = 0.; i < targetDimension.x; i++ ) + for( float j = 0.; j < targetDimension.y; j++ ) { + vec4 targ = texture2D( target, vec2(0.5 + i, 0.5 + j) * targTx ); if(targ.a == 0.) continue; vec2 bpx = pos + vec2(i, j); vec4 base = texture2D( gm_BaseTexture, bpx * baseTx ); - content_px++; if(distance(base, targ) <= 2. * colorThreshold) _match++; } - return _match / content_px; + return _match / (targetDimension.x * targetDimension.y); } void main() { + gl_FragColor = vec4(0.); + vec4 base = texture2D( gm_BaseTexture, v_vTexcoord ); - if(base.a == 0.) { - gl_FragColor = vec4(vec3(0.), 0.); + if(base.a == 0.) return; - } vec2 px = v_vTexcoord * dimension; @@ -54,20 +54,23 @@ void main() { vec2 matchPos = vec2(0., 0.); vec2 matchUv = vec2(0., 0.); - for( float i = 0.; i < target_dim.x; i++ ) - for( float j = 0.; j < target_dim.y; j++ ) { + for( float i = 0.; i < targetDimension.x; i++ ) + for( float j = 0.; j < targetDimension.y; j++ ) { vec2 uv = px - vec2(i, j); if(uv.x < 0. || uv.y < 0.) continue; - if(uv.x + target_dim.x > dimension.x || uv.y + target_dim.y > dimension.y) continue; + if(uv.x - .5 + targetDimension.x > dimension.x || uv.y - .5 + targetDimension.y > dimension.y) continue; + gl_FragColor = vec4(1.); float matchTemp = matchTemplate(uv); if(matchTemp > match) { match = matchTemp; - matchPos = vec2(i, j) / (target_dim - 1.); - matchUv = uv / dimension; + matchPos = (vec2(i, j) + 0.5) * targTx; + matchUv = uv * baseTx; } } - float ind = mode == 0? index : round(random(matchUv) * (size - 1.)) / size; - gl_FragColor = match > (1. - pixelThreshold - 1. / (target_dim.x * target_dim.y))? vec4(matchPos, ind, 1.) : vec4(0.); + if(match >= 1. - pixelThreshold) { + float ind = mode == 0? index : round(random(matchUv) * (size - 1.)) / size; + gl_FragColor = vec4(matchPos, ind, 1.); + } } diff --git a/sprites/s_node_armature_sample/c95f3cd1-1a44-47df-9da7-312ec9aebed3.png b/sprites/s_node_armature_sample/c95f3cd1-1a44-47df-9da7-312ec9aebed3.png new file mode 100644 index 000000000..a19ca88b7 Binary files /dev/null and b/sprites/s_node_armature_sample/c95f3cd1-1a44-47df-9da7-312ec9aebed3.png differ diff --git a/sprites/s_node_armature_sample/layers/c95f3cd1-1a44-47df-9da7-312ec9aebed3/abca6436-e8a8-491d-89ad-6123cbafe587.png b/sprites/s_node_armature_sample/layers/c95f3cd1-1a44-47df-9da7-312ec9aebed3/abca6436-e8a8-491d-89ad-6123cbafe587.png new file mode 100644 index 000000000..a19ca88b7 Binary files /dev/null and b/sprites/s_node_armature_sample/layers/c95f3cd1-1a44-47df-9da7-312ec9aebed3/abca6436-e8a8-491d-89ad-6123cbafe587.png differ diff --git a/sprites/s_node_armature_sample/s_node_armature_sample.yy b/sprites/s_node_armature_sample/s_node_armature_sample.yy new file mode 100644 index 000000000..bc7be2eb8 --- /dev/null +++ b/sprites/s_node_armature_sample/s_node_armature_sample.yy @@ -0,0 +1,74 @@ +{ + "resourceType": "GMSprite", + "resourceVersion": "1.0", + "name": "s_node_armature_sample", + "bbox_bottom": 53, + "bbox_left": 3, + "bbox_right": 60, + "bbox_top": 10, + "bboxMode": 0, + "collisionKind": 1, + "collisionTolerance": 0, + "DynamicTexturePage": false, + "edgeFiltering": false, + "For3D": false, + "frames": [ + {"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"c95f3cd1-1a44-47df-9da7-312ec9aebed3",}, + ], + "gridX": 0, + "gridY": 0, + "height": 64, + "HTile": false, + "layers": [ + {"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"abca6436-e8a8-491d-89ad-6123cbafe587","blendMode":0,"displayName":"default","isLocked":false,"opacity":100.0,"visible":true,}, + ], + "nineSlice": null, + "origin": 4, + "parent": { + "name": "transform", + "path": "folders/nodes/icons/transform.yy", + }, + "preMultiplyAlpha": false, + "sequence": { + "resourceType": "GMSequence", + "resourceVersion": "1.4", + "name": "s_node_armature_sample", + "autoRecord": true, + "backdropHeight": 768, + "backdropImageOpacity": 0.5, + "backdropImagePath": "", + "backdropWidth": 1366, + "backdropXOffset": 0.0, + "backdropYOffset": 0.0, + "events": {"resourceType":"KeyframeStore","resourceVersion":"1.0","Keyframes":[],}, + "eventStubScript": null, + "eventToFunction": {}, + "length": 1.0, + "lockOrigin": false, + "moments": {"resourceType":"KeyframeStore","resourceVersion":"1.0","Keyframes":[],}, + "playback": 1, + "playbackSpeed": 30.0, + "playbackSpeedType": 0, + "showBackdrop": true, + "showBackdropImage": false, + "timeUnits": 1, + "tracks": [ + {"resourceType":"GMSpriteFramesTrack","resourceVersion":"1.0","name":"frames","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"resourceType":"KeyframeStore","resourceVersion":"1.0","Keyframes":[ + {"resourceType":"Keyframe","resourceVersion":"1.0","Channels":{"0":{"resourceType":"SpriteFrameKeyframe","resourceVersion":"1.0","Id":{"name":"c95f3cd1-1a44-47df-9da7-312ec9aebed3","path":"sprites/s_node_armature_sample/s_node_armature_sample.yy",},},},"Disabled":false,"id":"e523200f-47ea-4df4-b800-b6fb0058c12c","IsCreationKey":false,"Key":0.0,"Length":1.0,"Stretch":false,}, + ],},"modifiers":[],"spriteId":null,"trackColour":0,"tracks":[],"traits":0,}, + ], + "visibleRange": null, + "volume": 1.0, + "xorigin": 32, + "yorigin": 32, + }, + "swatchColours": null, + "swfPrecision": 2.525, + "textureGroupId": { + "name": "Default", + "path": "texturegroups/Default", + }, + "type": 0, + "VTile": false, + "width": 64, +} \ No newline at end of file