Append connection fix, particle effector render chain.

This commit is contained in:
MakhamDev 2022-01-16 11:17:35 +07:00
parent 71b248fdfe
commit f27fb8aeee
44 changed files with 552 additions and 244 deletions

View file

@ -151,6 +151,7 @@
{"id":{"name":"s_node_transform_single","path":"sprites/s_node_transform_single/s_node_transform_single.yy",},"order":89,},
{"id":{"name":"s_button_hide_fill","path":"sprites/s_button_hide_fill/s_button_hide_fill.yy",},"order":15,},
{"id":{"name":"sh_blur_radial","path":"shaders/sh_blur_radial/sh_blur_radial.yy",},"order":18,},
{"id":{"name":"sh_grid","path":"shaders/sh_grid/sh_grid.yy",},"order":35,},
{"id":{"name":"s_button_hide","path":"sprites/s_button_hide/s_button_hide.yy",},"order":10,},
{"id":{"name":"sh_twirl","path":"shaders/sh_twirl/sh_twirl.yy",},"order":19,},
{"id":{"name":"s_checkbox","path":"sprites/s_checkbox/s_checkbox.yy",},"order":11,},
@ -430,6 +431,7 @@
{"id":{"name":"string_cut","path":"scripts/string_cut/string_cut.yy",},"order":4,},
{"id":{"name":"node_3d_prim_cylinder","path":"scripts/node_3d_prim_cylinder/node_3d_prim_cylinder.yy",},"order":7,},
{"id":{"name":"s_node_dithering","path":"sprites/s_node_dithering/s_node_dithering.yy",},"order":73,},
{"id":{"name":"node_grid","path":"scripts/node_grid/node_grid.yy",},"order":20,},
{"id":{"name":"s_texture_default","path":"sprites/s_texture_default/s_texture_default.yy",},"order":1,},
{"id":{"name":"node_dilate","path":"scripts/node_dilate/node_dilate.yy",},"order":34,},
{"id":{"name":"s_node_image_sheet","path":"sprites/s_node_image_sheet/s_node_image_sheet.yy",},"order":100,},

View file

@ -147,6 +147,7 @@ event_inherited();
#region search
search_string = "";
keyboard_lastchar = "";
keyboard_string = "";
keyboard_lastkey = -1;
tb_search = new textBox(TEXTBOX_INPUT.text, function(str) { search_string = string(str); });

View file

@ -2,6 +2,7 @@
event_inherited();
#region
align = fa_center;
draggable = false;
destroy_on_click_out = true;

View file

@ -16,7 +16,10 @@
}
}
draw_set_text(f_p0, fa_center, fa_center, c_white);
draw_text(dialog_x + dialog_w / 2, _ly + hght / 2, scrollbox.data_list[i]);
draw_set_text(f_p0, align, fa_center, c_white);
if(align == fa_center)
draw_text(dialog_x + dialog_w / 2, _ly + hght / 2, scrollbox.data_list[i]);
else if(align == fa_left)
draw_text(dialog_x + 8, _ly + hght / 2, scrollbox.data_list[i]);
}
#endregion

View file

@ -14,14 +14,14 @@
file_text_close(f);
#endregion
display_reset(4, 1);
display_reset(0, 1);
#region window
depth = 0;
win_wp = WIN_W;
win_hp = WIN_H;
win_wp = WIN_W;
win_hp = WIN_H;
room_width = WIN_W;
room_width = WIN_W;
room_height = WIN_H;
draw_set_circle_precision(64);

View file

@ -2,21 +2,22 @@
#region tooltip
if(TOOLTIP != "") {
draw_set_text(f_p0, fa_left, fa_top, c_white);
var tw = string_width(TOOLTIP);
var th = string_height(TOOLTIP);
var _w = string_width(TOOLTIP);
var mx = mouse_mx + 16;
var my = mouse_my + 16;
if(mouse_mx + tw > WIN_W - 32) {
mx = mouse_mx - 16 - tw;
}
var tw = clamp(_w, 400, WIN_W - mx - 32);
var th = string_height_ext(TOOLTIP, -1, tw);
tw = string_width_ext(TOOLTIP, -1, tw);
if(mouse_my + th > WIN_H - 32) {
if(mouse_mx + tw > WIN_W - 32)
mx = mouse_mx - 16 - tw;
if(mouse_my + th > WIN_H - 32)
my = mouse_my - 16 - th;
}
draw_sprite_stretched(s_textbox, 0, mx - 8, my - 8, tw + 16, th + 16);
draw_text(mx, my, TOOLTIP);
draw_text_ext(mx, my, TOOLTIP, -1, tw);
}
TOOLTIP = "";
#endregion

View file

@ -30,7 +30,7 @@ function log_newline() {
}
exception_unhandled_handler(function(ex) {
var tt = "\n-------------------------- OH BOY --------------------------\n\n";
var tt = "\n-------------------------- OH NO --------------------------\n\n";
tt += ex.longMessage;
tt += "\n---------------------------- :( ----------------------------\n";
log_crash(tt);

View file

@ -23,7 +23,7 @@ function Node_Blur_Directional(_x, _y) : Node_Processor(_x, _y) constructor {
var _surf = outputs[| 0].getValue();
if(is_array(_surf)) {
if(array_length(_surf) == 0) return;
_surf = _surf[preview_frame];
_surf = _surf[preview_index];
}
var ww = surface_get_width(_surf);

View file

@ -7,7 +7,6 @@ function Node_create_Canvas(_x, _y) {
function Node_Canvas(_x, _y) : Node(_x, _y) constructor {
name = "Canvas";
color = c_ui_orange;
force_preview_channel = 1;
inputs[| 0] = nodeValue(0, "Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, def_surf_size2, VALUE_TAG.dimension_2d )
.setDisplay(VALUE_DISPLAY.vector);

View file

@ -11,7 +11,7 @@ function Node_RGB_Channel(_x, _y) : Node_Processor(_x, _y) constructor {
outputs[| 0] = nodeValue(0, "Surface red", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, surface_create(1, 1));
outputs[| 1] = nodeValue(1, "Surface green", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, surface_create(1, 1));
outputs[| 2] = nodeValue(2, "Surface ble", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, surface_create(1, 1));
outputs[| 2] = nodeValue(2, "Surface blue", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, surface_create(1, 1));
function process_data(_outSurf, _data, output_index) {
surface_set_target(_outSurf);

View file

@ -6,7 +6,6 @@ function Node(_x, _y) constructor {
icon = noone;
bg_spr = s_node_bg;
bg_sel_spr = s_node_active;
force_preview_channel = -1;
if(!LOADING && !APPENDING) {
recordAction(ACTION_TYPE.node_added, self);
@ -40,7 +39,7 @@ function Node(_x, _y) constructor {
previewable = true;
preview_speed = 0;
preview_index = 0;
preview_frame = 0;
preview_channel = 0;
preview_x = 0;
preview_y = 0;
@ -167,6 +166,7 @@ function Node(_x, _y) constructor {
if(_s * w > 48) {
draw_sprite_stretched_ext(s_node_name, 0, xx, yy, w * _s, 20, color, 0.75);
draw_set_text(f_p1, fa_left, fa_center, c_white);
if(!auto_update) icon = s_refresh_16;
if(icon) {
draw_sprite_ext(icon, 0, xx + 12, yy + 10, 1, 1, 0, c_white, 1);
@ -296,8 +296,7 @@ function Node(_x, _y) constructor {
}
if(floor(preview_index) > array_length(surf) - 1) preview_index = 0;
preview_frame = clamp(floor(preview_index), 0, array_length(surf) - 1);
surf = surf[preview_frame];
surf = surf[preview_index];
}
if(is_surface(surf)) {
@ -311,8 +310,10 @@ function Node(_x, _y) constructor {
//draw_set_color(c_ui_blue_grey);
//draw_rectangle(px, py, px + pw * ps - 1, py + ph * ps - 1, true);
draw_set_text(_s >= 1? f_p1 : f_p2, fa_center, fa_top, c_ui_blue_grey);
draw_text(xx + w * _s / 2, yy + h * _s + 4 * _s, string(pw) + " x " + string(ph) + "px");
if(_s * w > 48) {
draw_set_text(_s >= 1? f_p1 : f_p2, fa_center, fa_top, c_ui_blue_grey);
draw_text(xx + w * _s / 2, yy + h * _s + 4 * _s, string(pw) + " x " + string(ph) + "px");
}
}
}

View file

@ -0,0 +1,57 @@
function Node_create_Grid(_x, _y) {
var node = new Node_Grid(_x, _y);
ds_list_add(PANEL_GRAPH.nodes_list, node);
return node;
}
function Node_Grid(_x, _y) : Node(_x, _y) constructor {
name = "Grid";
shader = sh_grid;
uniform_pos = shader_get_uniform(shader, "position");
uniform_sca = shader_get_uniform(shader, "scale");
uniform_wid = shader_get_uniform(shader, "width");
inputs[| 0] = nodeValue(0, "Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, def_surf_size2, VALUE_TAG.dimension_2d )
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 1] = nodeValue(1, "Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ])
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 2] = nodeValue(2, "Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 4, 4 ])
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 3] = nodeValue(3, "Gap", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.02)
.setDisplay(VALUE_DISPLAY.slider, [0, 0.5, 0.01]);
input_display_list = [
["Effect settings", false], 0, 1, 2, 3
];
outputs[| 0] = nodeValue(0, "Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, surface_create(1, 1));
function update() {
var _dim = inputs[| 0].getValue();
var _pos = inputs[| 1].getValue();
var _sca = inputs[| 2].getValue();
var _wid = inputs[| 3].getValue();
var _outSurf = outputs[| 0].getValue();
if(!is_surface(_outSurf)) {
_outSurf = surface_create(surface_valid(_dim[0]), surface_valid(_dim[1]));
outputs[| 0].setValue(_outSurf);
} else
surface_size_to(_outSurf, surface_valid(_dim[0]), surface_valid(_dim[1]));
surface_set_target(_outSurf);
shader_set(shader);
shader_set_uniform_f_array(uniform_pos, _pos);
shader_set_uniform_f_array(uniform_sca, _sca);
shader_set_uniform_f(uniform_wid, _wid);
draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
shader_reset();
surface_reset_target();
}
update();
}

View file

@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "generator",
"path": "folders/nodes/data/generator.yy",
},
"resourceVersion": "1.0",
"name": "node_grid",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -15,8 +15,8 @@ function Node_Group_Input(_x, _y, _group) : Node(_x, _y) constructor {
self.group = _group;
w = 96;
min_h = 0;
h = 32 + 24;
min_h = h;
inputs[| 0] = nodeValue(0, "Display type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Default", "Range", "Enum Scroll", "Enum Button", "Rotation", "Rotation range",

View file

@ -14,7 +14,8 @@ function Node_Group_Output(_x, _y, _group) : Node(_x, _y) constructor {
self.group = _group;
w = 96;
min_h = 0;
h = 32 + 24;
min_h = h;
inputs[| 0] = nodeValue(0, "Value", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, -1);

View file

@ -131,7 +131,7 @@ function Node_Image_Sheet(_x, _y) : Node(_x, _y) constructor {
if(_out == 0)
ii = safe_mod(ANIMATOR.current_frame * _spd, _amo);
else
ii = preview_frame;
ii = preview_index;
var _spr_pos = getSpritePosition(ii);
var _orig_x = _x - (_spr_pos[0] - _pad[2]) * _s;

View file

@ -143,44 +143,6 @@ function Node_Line(_x, _y) : Node(_x, _y) constructor {
_oy = _ny;
_ow = _nw;
}
//for(var i = 0; i <= _seg; i++) {
// var p = _pat.getPointRatio(_rats + i * ww);
// _nx = p[0];
// _ny = p[1];
// if(i > 0 && i < _seg) {
// _d = point_direction(_ox, _oy, _nx, _ny);
// _nx += lengthdir_x(random(_wig) * choose(-1, 1), _d + 90);
// _ny += lengthdir_y(random(_wig) * choose(-1, 1), _d + 90);
// }
// _nw = random_range(_wid[0], _wid[1]);
// if(i == _seg) {
// _na = point_direction(_ox, _oy, _nx, _ny) + 90;
// } else {
// var np = _pat.getPointRatio(_rats + (i + 1) * ww);
// var _nna = point_direction(_nx, _ny, np[0], np[1]) + 90;
// if(i == 0)
// _na = _nna;
// else {
// var _da = point_direction(_ox, _oy, _nx, _ny) + 90;
// _na = _da + angle_difference(_nna, _da) / 2;
// }
// }
// if(i) {
// draw_set_color(c_white);
// draw_line_width2_angle(_ox, _oy, _nx, _ny, _ow, _nw, _oa, _na);
// }
// _oa = _na;
// _ox = _nx;
// _oy = _ny;
// _ow = _nw;
//}
} else {
var x0, y0, x1, y1;
var _0 = point_rectangle_overlap(_dim[0], _dim[1], (_ang + 180) % 360);

View file

@ -10,32 +10,66 @@ function Node_Cellular(_x, _y) : Node(_x, _y) constructor {
inputs[| 0] = nodeValue(0, "Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, def_surf_size2, VALUE_TAG.dimension_2d )
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 1] = nodeValue(1, "Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ])
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 1] = nodeValue(1, "Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ def_surf_size / 2, def_surf_size / 2])
.setDisplay(VALUE_DISPLAY.vector)
.setVisible(false);
inputs[| 2] = nodeValue(2, "Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4);
inputs[| 2] = nodeValue(2, "Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4)
.setVisible(false);
inputs[| 3] = nodeValue(3, "Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0);
inputs[| 3] = nodeValue(3, "Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setVisible(false);
inputs[| 4] = nodeValue(4, "Type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Point", "Edge", "Cell", "Rounded" ]);
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Point", "Edge", "Cell" ])
.setVisible(false);
//inputs[| 5] = nodeValue(5, "Width", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.2);
//inputs[| 5].setDisplay(VALUE_DISPLAY.slider, [0., 1., 0.01]);
inputs[| 5] = nodeValue(5, "Contrast", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setVisible(false);
inputs[| 6] = nodeValue(6, "Pattern", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_button, [ "Uniform", "Radial" ])
.setVisible(false);
inputs[| 7] = nodeValue(7, "Middle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.5)
.setDisplay(VALUE_DISPLAY.slider, [0., 1., 0.01])
.setVisible(false);
inputs[| 8] = nodeValue(8, "Radial scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 2)
.setDisplay(VALUE_DISPLAY.slider, [1., 10., 0.01])
.setVisible(false, false);
inputs[| 9] = nodeValue(9, "Radial shatter", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider, [-10., 10., 0.01])
.setVisible(false, false);
input_display_list = [
["Output", false], 0,
["Noise", false], 4, 3, 1, 2
["Output", false], 0,
["Noise", false], 4, 6, 3, 1, 2,
["Radial", false], 8, 9,
["Rendering", false], 5, 7
];
outputs[| 0] = nodeValue(0, "Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, surface_create(1, 1));
static drawOverlay = function(_active, _x, _y, _s, _mx, _my) {
inputs[| 1].drawOverlay(_active, _x, _y, _s, _mx, _my);
}
function update() {
var _dim = inputs[| 0].getValue();
var _pos = inputs[| 1].getValue();
var _sca = inputs[| 2].getValue();
var _tim = inputs[| 3].getValue();
var _type = inputs[| 4].getValue();
var _con = inputs[| 5].getValue();
var _pat = inputs[| 6].getValue();
var _mid = inputs[| 7].getValue();
inputs[| 8].show_in_inspector = _pat == 1;
inputs[| 9].show_in_inspector = _pat == 1;
var _rad = inputs[| 8].getValue();
var _sht = inputs[| 9].getValue();
var _outSurf = outputs[| 0].getValue();
if(!is_surface(_outSurf)) {
@ -50,19 +84,30 @@ function Node_Cellular(_x, _y) : Node(_x, _y) constructor {
shader = sh_cell_noise_edge;
} else if(_type == 2) {
shader = sh_cell_noise_random;
} else if(_type == 2) {
shader = sh_cell_noise_round;
}
uniform_dim = shader_get_uniform(shader, "dimension");
uniform_pos = shader_get_uniform(shader, "position");
uniform_sca = shader_get_uniform(shader, "scale");
uniform_tim = shader_get_uniform(shader, "time");
uniform_con = shader_get_uniform(shader, "contrast");
uniform_pat = shader_get_uniform(shader, "pattern");
uniform_mid = shader_get_uniform(shader, "middle");
uniform_rad = shader_get_uniform(shader, "radiusScale");
uniform_sht = shader_get_uniform(shader, "radiusShatter");
surface_set_target(_outSurf);
shader_set(shader);
shader_set_uniform_f_array(uniform_dim, _dim);
shader_set_uniform_f(uniform_tim, _tim);
shader_set_uniform_f_array(uniform_pos, _pos);
shader_set_uniform_f(uniform_sca, _sca);
shader_set_uniform_f(uniform_con, _con);
shader_set_uniform_f(uniform_mid, _mid);
shader_set_uniform_f(uniform_rad, _rad);
shader_set_uniform_f(uniform_sht, _sht);
shader_set_uniform_i(uniform_pat, _pat);
draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
shader_reset();
surface_reset_target();

View file

@ -156,8 +156,8 @@ function __part() constructor {
if(boundary_data == -1)
return [x, y];
var ww = boundary_data[2] + boundary_data[0] * scx;
var hh = boundary_data[3] + boundary_data[1] * scy;
var ww = (boundary_data[2] - boundary_data[0]) * scx;
var hh = (boundary_data[3] - boundary_data[1]) * scy;
var cx = x + boundary_data[0] + ww / 2;
var cy = y + boundary_data[1] + hh / 2;
@ -422,7 +422,7 @@ function Node_Particle(_x, _y) : Node(_x, _y) constructor {
var jun = outputs[| 1];
for(var j = 0; j < ds_list_size(jun.value_to); j++) {
if(jun.value_to[| j].value_from == jun) {
jun.value_to[| j].node.updateParticle();
jun.value_to[| j].node.update();
}
}

View file

@ -6,6 +6,7 @@ function Node_create_Particle_Effector(_x, _y) {
enum FORCE_TYPE {
Wind,
Accelerate,
Attract,
Repel,
Vortex,
@ -14,9 +15,13 @@ enum FORCE_TYPE {
}
function Node_Particle_Effector(_x, _y) : Node(_x, _y) constructor {
name = "Particle Effector";
name = "Effector";
previewable = false;
w = 96;
h = 32 + 24;
min_h = h;
inputs[| 0] = nodeValue(0, "Particle data", self, JUNCTION_CONNECT.input, VALUE_TYPE.object, -1 );
inputs[| 1] = nodeValue(1, "Output dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, def_surf_size2, VALUE_TAG.dimension_2d )
.setDisplay(VALUE_DISPLAY.vector)
@ -34,7 +39,7 @@ function Node_Particle_Effector(_x, _y) : Node(_x, _y) constructor {
.setVisible(false);
inputs[| 5] = nodeValue(5, "Effect type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 )
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Wind", "Attract", "Repel", "Vortex", "Turbulence", "Destroy" ] )
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Wind", "Accelerate", "Attract", "Repel", "Vortex", "Turbulence", "Destroy" ] )
.setVisible(false);
inputs[| 6] = nodeValue(6, "Effect Vector", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ -1, 0 ] )
@ -74,6 +79,10 @@ function Node_Particle_Effector(_x, _y) : Node(_x, _y) constructor {
node_input_visible(inputs[| 6], true);
node_input_visible(inputs[| 10], false);
break;
case FORCE_TYPE.Accelerate :
node_input_visible(inputs[| 6], true);
node_input_visible(inputs[| 10], false);
break;
case FORCE_TYPE.Turbulence :
node_input_visible(inputs[| 6], true);
node_input_visible(inputs[| 10], true);
@ -139,6 +148,12 @@ function Node_Particle_Effector(_x, _y) : Node(_x, _y) constructor {
part.x = part.x + _vect[0] * _sten * str;
part.y = part.y + _vect[1] * _sten * str;
part.rot += _rot * str;
break;
case FORCE_TYPE.Accelerate :
part.sx = part.sx + _vect[0] * _sten * str;
part.sy = part.sy + _vect[1] * _sten * str;
part.rot += _rot * str;
break;
case FORCE_TYPE.Attract :
@ -190,11 +205,11 @@ function Node_Particle_Effector(_x, _y) : Node(_x, _y) constructor {
}
}
function updateParticle() {
function update() {
var jun = outputs[| 0];
for(var j = 0; j < ds_list_size(jun.value_to); j++) {
if(jun.value_to[| j].value_from == jun) {
jun.value_to[| j].node.updateParticle();
jun.value_to[| j].node.update();
}
}

View file

@ -163,11 +163,12 @@ function NodeObject(_name, _spr, _create, tags = []) constructor {
addNodeObject(generator, "Checker", s_node_checker, "Node_Checker", Node_create_Checker);
addNodeObject(generator, "Shape", s_node_shape, "Node_Shape", Node_create_Shape);
addNodeObject(generator, "Particle", s_node_particle, "Node_Particle", Node_create_Particle);
addNodeObject(generator, "Particle Effector", s_node_particle_effector, "Node_Particle_Effector", Node_create_Particle_Effector);
addNodeObject(generator, "Particle Effector", s_node_particle_effector, "Node_Particle_Effector", Node_create_Particle_Effector, ["affector"]);
addNodeObject(generator, "Scatter", s_node_scatter, "Node_Scatter", Node_create_Scatter);
addNodeObject(generator, "Perlin noise", s_node_noise_perlin, "Node_Perlin", Node_create_Perlin);
addNodeObject(generator, "Cellular noise", s_node_noise_cell, "Node_Cellular", Node_create_Cellular);
addNodeObject(generator, "Grid noise", s_node_grid_noise, "Node_Grid_Noise", Node_create_Grid_Noise);
addNodeObject(generator, "Grid", s_node_grid_noise, "Node_Grid", Node_create_Grid);
addNodeObject(generator, "Anisotropic noise", s_node_noise_aniso, "Node_Noise_Aniso", Node_create_Noise_Aniso);
addNodeObject(generator, "Seperate shape", s_node_sepearte_shape, "Node_Seperate_Shape", Node_create_Seperate_Shape);
addNodeObject(generator, "Text", s_node_text, "Node_Text", Node_create_Text);
@ -176,8 +177,8 @@ function NodeObject(_name, _spr, _create, tags = []) constructor {
var render = ds_list_create();
addNodeCatagory("Render", render);
addNodeObject(render, "Render sprite sheet", s_node_sprite_sheet, "Node_Render_Sprite_Sheet", Node_create_Render_Sprite_Sheet);
addNodeObject(render, "Export", s_node_export, "Node_Export", Node_create_Export);
addNodeObject(render, "Preview timeline", s_node_timeline_preview,"Node_Timeline_Preview",Node_create_Timeline_Preview);
addNodeObject(render, "Export", s_node_export, "Node_Export", Node_create_Export);
addNodeObject(render, "Preview timeline", s_node_timeline_preview,"Node_Timeline_Preview", Node_create_Timeline_Preview);
var group = ds_list_create();
addNodeCatagory("Group", group);

View file

@ -43,6 +43,8 @@ function Node_Seperate_Shape(_x, _y) : Node(_x, _y) constructor {
var _inSurf = inputs[| 0].getValue();
var _out_type = inputs[| 1].getValue();
if(!is_surface(_inSurf)) return;
var ww = surface_get_width(_inSurf);
var hh = surface_get_height(_inSurf);
@ -111,6 +113,8 @@ function Node_Seperate_Shape(_x, _y) : Node(_x, _y) constructor {
outputs[| 2] = nodeValue(2, "Boundary data", self, JUNCTION_CONNECT.output, VALUE_TYPE.integer, []);
_prev_type = _out_type;
} else {
outputs[| 0].setValue(_val);
}
}

View file

@ -32,7 +32,7 @@ function Node_Shadow(_x, _y) : Node_Processor(_x, _y) constructor {
var _surf = outputs[| 0].getValue();
if(is_array(_surf)) {
if(array_length(_surf) == 0) return;
_surf = _surf[preview_frame];
_surf = _surf[preview_index];
}
var ww = surface_get_width(_surf) * _s;

View file

@ -30,8 +30,6 @@ function Node_Surface_data(_x, _y) : Node(_x, _y) constructor {
}
outputs[| 0].setValue(_dim);
outputs[| 1].show_in_inspector = true;
outputs[| 1].setValue(len);
return;
}
@ -39,7 +37,6 @@ function Node_Surface_data(_x, _y) : Node(_x, _y) constructor {
if(!_insurf || !surface_exists(_insurf)) return;
outputs[| 0].setValue([ surface_get_width(_insurf), surface_get_height(_insurf) ]);
outputs[| 1].show_in_inspector = false;
}
update();
}

View file

@ -77,7 +77,7 @@ function Node_Transform(_x, _y) : Node_Processor(_x, _y) constructor {
if(is_array(_surf)) {
if(array_length(_surf) == 0) return;
_surf = _surf[preview_frame];
_surf = _surf[preview_index];
}
var ww, hh;
@ -259,13 +259,13 @@ function Node_Transform(_x, _y) : Node_Processor(_x, _y) constructor {
var _surf = inputs[| 0].getValue();
if(is_array(_surf)) {
if(array_length(_surf) == 0) return;
_surf = _surf[preview_frame];
_surf = _surf[preview_index];
}
var _surf_out = outputs[| 0].getValue();
if(is_array(_surf_out)) {
if(array_length(_surf_out) == 0) return;
_surf_out = _surf_out[preview_frame];
_surf_out = _surf_out[preview_index];
}
var pos = current_data[2];

View file

@ -59,7 +59,7 @@ function Node_Transform_Single(_x, _y) : Node_Processor(_x, _y) constructor {
var _surf = outputs[| 0].getValue();
if(is_array(_surf)) {
if(array_length(_surf) == 0) return;
_surf = _surf[preview_frame];
_surf = _surf[preview_index];
}
var pos_x = current_data[1];

View file

@ -430,7 +430,7 @@ function NodeValue(_index, _name, _node, _connect, _type, _value, _tag = VALUE_T
var val = getValue();
if(isArray()) {
if(array_length(val) == 0) return 0;
return val[safe_mod(node.preview_frame, array_length(val))];
return val[safe_mod(node.preview_index, array_length(val))];
}
return val;
}
@ -485,57 +485,48 @@ function NodeValue(_index, _name, _node, _connect, _type, _value, _tag = VALUE_T
static setFrom = function(_valueFrom, _update = true, checkRecur = true) {
if(_valueFrom == -1 || _valueFrom == undefined) {
show_debug_message("LOAD : Value from error " + string(_valueFrom))
return;
return false;
}
if(_valueFrom == noone) {
removeFrom();
return;
return false;
}
if(_valueFrom == self) {
show_debug_message("setFrom : Connect to self");
return;
return false;
}
if(value_bit(type) & value_bit(_valueFrom.type) == 0 && !value_type_directional(_valueFrom, self)) {
//show_debug_message(tag);
//show_debug_message(tag & VALUE_TAG.dimension_2d);
//show_debug_message(_valueFrom.type);
//show_debug_message(VALUE_TYPE.surface);
//if((tag & VALUE_TAG.dimension_2d) && _valueFrom.type == VALUE_TYPE.surface) {
// var conversion_node = nodeBuild("Surface data", node.x - 128, node.y);
// conversion_node.inputs[| 0].setFrom(_valueFrom);
// setFrom(conversion_node.outputs[| 0]);
// return;
//} else {
show_debug_message("setFrom : Type mismatch");
return;
return false;
}
if(connect_type == _valueFrom.connect_type) {
show_debug_message("setFrom : Connect type mismatch");
return;
return false;
}
if(checkRecur && _valueFrom.searchNodeBackward(node)) {
show_debug_message("setFrom : Recursive");
return;
return false;
}
if(!accept_array && _valueFrom.isArray()) {
show_debug_message("setFrom : Array mismatch");
return;
return false;
}
recordAction(ACTION_TYPE.junction_connect, self, value_from);
value_from = _valueFrom;
ds_list_add(_valueFrom.value_to, self);
show_debug_message("connected " + name + " to " + _valueFrom.name)
//show_debug_message("connected " + name + " to " + _valueFrom.name)
if(_update) node.updateValueFrom(index);
if(_update && node.auto_update) _valueFrom.node.updateForward();
return true;
}
static removeFrom = function() {
@ -977,16 +968,20 @@ function NodeValue(_index, _name, _node, _connect, _type, _value, _tag = VALUE_T
var _nd = NODE_MAP[? con_node + APPEND_ID];
var _ol = ds_list_size(_nd.outputs);
if(con_index < _ol) {
setFrom(_nd.outputs[| con_index], false);
return true;
if(setFrom(_nd.outputs[| con_index], false))
return true;
else {
log_warning("LOAD", "[Connect] Connection conflict " + string(node.name) + " to " + string(_nd.name) + " : Connection failed.");
return true;
}
} else {
log_warning("LOAD", "Connection conflict " + string(con_index) + " to " + string(_ol));
log_warning("LOAD", "[Connect] Connection conflict " + string(node.name) + " to " + string(_nd.name) + " : Node not exist.");
return false;
}
}
var txt = "Node connect error : Node ID " + string(con_node + APPEND_ID) + " not found.";
log_warning("LOAD", txt);
log_warning("LOAD", "[Connect] " + txt);
PANEL_MENU.addNotiExtra(txt);
return true;
}

View file

@ -34,7 +34,7 @@ function Node_Warp(_x, _y) : Node_Processor(_x, _y) constructor {
var _surf = outputs[| 0].getValue();
if(is_array(_surf)) {
if(array_length(_surf) == 0) return;
_surf = _surf[preview_frame];
_surf = _surf[preview_index];
}
var ww = surface_get_width(_surf);

View file

@ -37,6 +37,8 @@ function Panel_Preview(_panel) : PanelContent(_panel) constructor {
tool_index = -1;
tool_sub_index = 0;
right_menu_y = 8;
tb_framerate = new textBox(TEXTBOX_INPUT.number, function(val) { preview_rate = real(val); })
addHotkey("Preview", "Focus content", "F", MOD_KEY.none, function() { fullView(); });
@ -101,35 +103,48 @@ function Panel_Preview(_panel) : PanelContent(_panel) constructor {
}
}
sbChannel = new scrollBox([], function(index) { PANEL_GRAPH.node_previewing.preview_channel = index; });
sbChannel.align = fa_left;
function drawNodeChannel(_node) {
if(ds_list_size(_node.outputs) < 2) return;
var chName = [];
var ww = 40;
draw_set_text(f_p0, fa_center, fa_center, c_white);
for( var i = 0; i < ds_list_size(_node.outputs); i++ ) {
array_push(chName, _node.outputs[| i].name);
ww = max(ww, string_width(_node.outputs[| i].name) + 40);
}
sbChannel.data_list = chName;
sbChannel.hover = HOVER == panel;
sbChannel.active = FOCUS == panel;
sbChannel.draw(w - 8 - ww, right_menu_y, ww, 34, _node.outputs[| _node.preview_channel].name, [mx, my], panel.x, panel.y);
right_menu_y += 40;
}
function drawNodePreview(_node) {
var index = 0;
preview_surface = 0;
preview_sequence = 0;
var _channel = _node.force_preview_channel == -1? preview_channel : _node.force_preview_channel;
if(_node.preview_channel >= ds_list_size(_node.outputs)) return;
for(var i = 0; i < ds_list_size(_node.outputs); i++) {
var val = _node.outputs[| i];
if(val.type == VALUE_TYPE.surface) {
if(index == _channel) {
var value = val.getValue();
var _prev_val = _node.outputs[| _node.preview_channel];
if(_prev_val.type != VALUE_TYPE.surface) return;
if(is_array(value)) {
preview_sequence = value;
} else {
preview_surface = value;
canvas_w = surface_get_width(preview_surface);
canvas_h = surface_get_height(preview_surface);
}
var value = _prev_val.getValue();
break;
}
index++;
}
if(is_array(value)) {
preview_sequence = value;
} else {
preview_surface = value;
canvas_w = surface_get_width(preview_surface);
canvas_h = surface_get_height(preview_surface);
}
if(preview_sequence != 0) {
if(array_length(preview_sequence) == 0) return;
preview_surface = preview_sequence[safe_mod(_node.preview_frame, array_length(preview_sequence))];
preview_surface = preview_sequence[safe_mod(_node.preview_index, array_length(preview_sequence))];
canvas_w = surface_get_width(preview_surface);
canvas_h = surface_get_height(preview_surface);
@ -157,9 +172,12 @@ function Panel_Preview(_panel) : PanelContent(_panel) constructor {
function drawPreviewOverlay(_node) {
draw_set_text(f_p0, fa_right, fa_top, c_ui_blue_ltgrey);
draw_text(w - 8, 38, "frame " + string(ANIMATOR.current_frame) + "/" + string(ANIMATOR.frames_total));
draw_text(w - 8, 58, string(canvas_w) + "x" + string(canvas_h) + "px");
draw_text(w - 8, 78, "x" + string(canvas_s));
draw_text(w - 8, right_menu_y, "frame " + string(ANIMATOR.current_frame) + "/" + string(ANIMATOR.frames_total));
right_menu_y += 20;
draw_text(w - 8, right_menu_y, string(canvas_w) + "x" + string(canvas_h) + "px");
right_menu_y += 20;
draw_text(w - 8, right_menu_y, "x" + string(canvas_s));
right_menu_y += 20;
var prev_size = 48;
preview_x = lerp_float(preview_x, preview_x_to, 5);
@ -202,7 +220,7 @@ function Panel_Preview(_panel) : PanelContent(_panel) constructor {
draw_surface_ext_safe(prev, xx, yy, ss, ss, 0, c_white, 0.5);
}
if(i == _node.preview_frame) {
if(i == _node.preview_index) {
draw_set_color(c_ui_orange);
draw_rectangle(xx, yy, xx + prev_w * ss, yy + prev_h * ss, true);
}
@ -307,6 +325,8 @@ function Panel_Preview(_panel) : PanelContent(_panel) constructor {
}
function drawContent() {
right_menu_y = 8;
draw_clear(c_ui_blue_black);
if(canvas_bg == -1) {
if(canvas_s >= 1) draw_sprite_tiled_ext(s_transparent, 0, canvas_x, canvas_y, canvas_s, canvas_s, c_white, 0.5);
@ -318,6 +338,14 @@ function Panel_Preview(_panel) : PanelContent(_panel) constructor {
if(PANEL_GRAPH.node_previewing) {
PANEL_GRAPH.node_previewing.previewing = true;
drawNodePreview(PANEL_GRAPH.node_previewing);
drawNodeChannel(PANEL_GRAPH.node_previewing);
}
draw_set_text(f_p0, fa_right, fa_top, c_ui_blue_ltgrey);
draw_text(w - 8, right_menu_y, "fps " + string(fps));
right_menu_y += 20;
if(PANEL_GRAPH.node_previewing) {
drawPreviewOverlay(PANEL_GRAPH.node_previewing);
}
@ -329,9 +357,6 @@ function Panel_Preview(_panel) : PanelContent(_panel) constructor {
last_focus = PANEL_GRAPH.node_focus;
tool_index = -1;
}
draw_set_text(f_p0, fa_right, fa_top, c_ui_blue_ltgrey);
draw_text(w - 8, 08, "fps " + string(fps));
}
function saveCurrentFrame() {

View file

@ -14,6 +14,7 @@ function renderAll() {
var render_q = ds_queue_create();
var rendering = noone;
// get leaf node
var key = ds_map_find_first(NODE_MAP);
repeat(ds_map_size(NODE_MAP)) {
var _node = NODE_MAP[? key];
@ -21,10 +22,10 @@ function renderAll() {
var _startNode = true;
for(var j = 0; j < ds_list_size(_node.inputs); j++) {
var _in = _node.inputs[| j];
_node.rendered = false;
if(_in.value_from != noone) { //init
if(_in.value_from != noone)
_startNode = false;
}
}
if(_startNode)
ds_queue_enqueue(render_q, _node);
@ -32,19 +33,19 @@ function renderAll() {
key = ds_map_find_next(NODE_MAP, key);
}
// render forward
while(!ds_queue_empty(render_q)) {
rendering = ds_queue_dequeue(render_q);
var _ready = true;
for(var j = 0; j < ds_list_size(rendering.inputs); j++) {
var _in = rendering.inputs[| j];
if(_in.value_from && !_in.value_from.node.rendered) {
if(_in.value_from && !_in.value_from.node.rendered)
_ready = false;
}
}
if(_ready) {
if(!rendering.rendered && (LOADING || rendering.auto_update))
if(!rendering.rendered && (LOADING || APPENDING || rendering.auto_update))
rendering.update();
} else {
ds_queue_enqueue(render_q, rendering);

View file

@ -193,10 +193,19 @@ function LOAD_PATH(path, readonly = false) {
renderAll();
if(!ds_queue_empty(CONNECTION_CONFLICT)) {
while(!ds_queue_empty(CONNECTION_CONFLICT)) {
ds_queue_dequeue(CONNECTION_CONFLICT).connect();
var pass = 0;
while(++pass < 4 && !ds_queue_empty(CONNECTION_CONFLICT)) {
var size = ds_queue_size(CONNECTION_CONFLICT);
log_message("LOAD", "[Connect] " + string(size) + " Connection conflict(s) detected ( pass: " + string(pass) + " )");
repeat(size) {
ds_queue_dequeue(CONNECTION_CONFLICT).connect();
}
renderAll();
}
renderAll();
if(!ds_queue_empty(CONNECTION_CONFLICT))
PANEL_MENU.addNotiExtra("Some connection(s) is unsolved. This may caused by render node not being update properly, or image path is broken.");
}
LOADING = false;
@ -263,6 +272,22 @@ function APPEND(_path) {
renderAll();
if(!ds_queue_empty(CONNECTION_CONFLICT)) {
var pass = 0;
while(++pass < 2 && !ds_queue_empty(CONNECTION_CONFLICT)) {
var size = ds_queue_size(CONNECTION_CONFLICT);
log_message("LOAD", "[Connect] " + string(size) + " Connection conflict(s) detected ( pass: " + string(pass) + " )");
repeat(size) {
ds_queue_dequeue(CONNECTION_CONFLICT).connect();
}
renderAll();
}
if(!ds_queue_empty(CONNECTION_CONFLICT))
PANEL_MENU.addNotiExtra("Some connection(s) is unsolved. This may caused by render node not being update properly, or image path is broken.");
}
APPENDING = false;
PANEL_ANIMATION.updatePropertyList();

View file

@ -6,7 +6,9 @@ function scrollBox(_data, _onModify) constructor {
hover = false;
open = false;
function draw(_x, _y, _w, _h, _text, _m, _rx, _ry) {
align = fa_center;
static draw = function(_x, _y, _w, _h, _text, _m, _rx, _ry) {
if(!open) {
if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h)) {
draw_sprite_stretched(s_textbox, 1, _x, _y, _w, _h);
@ -15,6 +17,7 @@ function scrollBox(_data, _onModify) constructor {
with(dialogCall(o_dialog_scrollbox, _x + _rx, _y + _ry)) {
scrollbox = other;
dialog_w = _w;
align = other.align;
}
}
if(mouse_check_button(mb_left))
@ -23,8 +26,11 @@ function scrollBox(_data, _onModify) constructor {
draw_sprite_stretched(s_textbox, 0, _x, _y, _w, _h);
}
draw_set_text(f_p0, fa_center, fa_center, c_white);
draw_text(_x + _w / 2, _y + _h / 2, _text);
draw_set_text(f_p0, align, fa_center, c_white);
if(align == fa_center)
draw_text(_x + _w / 2, _y + _h / 2, _text);
else if(align == fa_left)
draw_text(_x + 8, _y + _h / 2, _text);
draw_sprite(s_scroll_box_arrow, 0, _x + _w - 20, _y + _h / 2);
}

View file

@ -11,7 +11,7 @@ function string_cut(str, w, tail = "...") {
var ch = string_char_at(str, ind);
var _w = string_width(ch);
if(ww + _w > w - 16) {
if(ww + _w > w - 10) {
ss += tail;
break;
} else {

View file

@ -198,7 +198,7 @@ function textBox(_input, _onModify) constructor {
break;
}
if(_m != -1) {
if(!sliding && _m != -1) {
for( var i = 1; i <= string_length(_text); i++ ) {
_ch = string_char_at(_text, i);
_chw = string_width(_ch);

View file

@ -4,49 +4,70 @@
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 dimension;
uniform vec2 position;
uniform float scale;
uniform int pattern;
uniform float time;
uniform float contrast;
uniform float middle;
uniform float radiusScale;
uniform float radiusShatter;
#define PI 3.14159265359
#define TAU 6.28318
vec2 random2( vec2 p ) {
return fract(sin(vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)))) * 43758.5453);
}
float random (in vec2 st) {
return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);
}
void main() {
vec2 st = v_vTexcoord + position;
vec2 pos = position / dimension;
vec2 st = v_vTexcoord - pos;
vec3 color = vec3(.0);
// Scale
st *= scale;
// Tile the space
vec2 i_st = floor(st);
vec2 f_st = fract(st);
float m_dist = 1.;
float m_dist = 1.; // minimum distance
if(pattern == 0) {
vec2 i_st = floor(st);
vec2 f_st = fract(st);
for (int y= -1; y <= 1; y++) {
for (int x= -1; x <= 1; x++) {
// Neighbor place in the grid
vec2 neighbor = vec2(float(x),float(y));
for (int y = -1; y <= 1; y++) {
for (int x = -1; x <= 1; x++) {
vec2 neighbor = vec2(float(x),float(y));
vec2 point = random2(i_st + neighbor);
point = 0.5 + 0.5 * sin(time + 6.2831 * point);
// Random position from current + neighbor place in the grid
vec2 point = random2(i_st + neighbor);
point = 0.5 + 0.5 * sin(time + 6.2831 * point);
vec2 _diff = neighbor + point - f_st;
float dist = length(_diff);
m_dist = min(m_dist, dist);
}
}
} else if(pattern == 1) {
for (int j = 0; j <= int(scale / 2.); j++) {
int _amo = int(scale) + int(float(j) * radiusShatter);
for (int i = 0; i <= _amo; i++) {
float ang = TAU / float(_amo) * float(i) + float(j) + time;
float rad = pow(float(j) / scale, radiusScale) * scale * .5 + random(vec2(ang)) * 0.1;
vec2 point = vec2(cos(ang) * rad, sin(ang) * rad) + pos;
// Vector between the pixel and the point
vec2 _diff = neighbor + point - f_st;
vec2 _diff = point - v_vTexcoord;
float dist = length(_diff);
m_dist = min(m_dist, dist);
}
}
}
// Distance to the point
float dist = length(_diff);
// Keep the closer distance
m_dist = min(m_dist, dist);
}
}
// Draw the min distance (distance field)
color += m_dist;
gl_FragColor = vec4(color,1.0);
vec3 c = middle + (color - middle) * contrast;
gl_FragColor = vec4(c, 1.0);
}

View file

@ -4,53 +4,103 @@
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 dimension;
uniform vec2 position;
uniform float scale;
uniform float time;
uniform float contrast;
uniform float middle;
uniform float radiusScale;
uniform float radiusShatter;
uniform int pattern;
#define TAU 6.28318
vec2 random2( vec2 p ) {
return fract(sin(vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)))) * 43758.5453);
}
float random (in vec2 st) {
return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);
}
void main() {
vec2 st = v_vTexcoord + position;
vec2 pos = position / dimension;
vec2 st = v_vTexcoord - pos;
st *= scale;
vec2 i_st = floor(st);
vec2 f_st = fract(st);
float md = 1.;
vec2 mg, mr;
for (int y = -1; y <= 1; y++) {
for (int x = -1; x <= 1; x++) {
vec2 neighbor = vec2(float(x), float(y));
vec2 point = random2(i_st + neighbor);
if(pattern == 0) {
vec2 i_st = floor(st);
vec2 f_st = fract(st);
for (int y = -1; y <= 1; y++) {
for (int x = -1; x <= 1; x++) {
vec2 neighbor = vec2(float(x), float(y));
vec2 point = random2(i_st + neighbor);
point += 0.5 + 0.5 * sin(time + 6.2831 * point);
vec2 _diff = neighbor + point - f_st;
float dist = length(_diff);
if(dist < md) {
md = dist;
mr = _diff;
mg = neighbor;
}
}
}
md = 1.;
for(int y = -2; y <= 2; y++)
for(int x = -2; x <= 2; x++) {
vec2 g = mg + vec2(float(x), float(y));
vec2 point = random2(i_st + g);
point += 0.5 + 0.5 * sin(time + 6.2831 * point);
vec2 _diff = neighbor + point - f_st;
float dist = length(_diff);
vec2 r = g + point - f_st;
if(dot(mr - r, mr - r) > .0001)
md = min( md, dot( 0.5 * (mr + r), normalize(r - mr)) );
}
} else if(pattern == 1) {
for (int j = 0; j <= int(scale / 2.); j++) {
int _amo = int(scale) + int(float(j) * radiusShatter);
for (int i = 0; i <= _amo; i++) {
float ang = TAU / float(_amo) * float(i) + float(j) + time;
float rad = pow(float(j) / scale, radiusScale) * scale * .5 + random(vec2(ang)) * 0.1;
vec2 neighbor = vec2(cos(ang) * rad, sin(ang) * rad);
vec2 point = neighbor + pos;
if(dist < md) {
md = dist;
mr = _diff;
mg = neighbor;
vec2 _diff = point - v_vTexcoord;
float dist = length(_diff);
if(dist < md) {
md = dist;
mr = _diff;
mg = neighbor;
}
}
}
}
}
md = 1.;
for(int y = -2; y <= 2; y++)
for(int x = -2; x <= 2; x++) {
vec2 g = mg + vec2(float(x), float(y));
vec2 point = random2(i_st + g);
point += 0.5 + 0.5 * sin(time + 6.2831 * point);
md = 1.;
for (int j = 0; j <= int(scale / 2.); j++) {
int _amo = int(scale) + int(float(j) * radiusShatter);
for (int i = 0; i <= _amo; i++) {
float ang = TAU / float(_amo) * float(i) + float(j) + time;
float rad = pow(float(j) / scale, radiusScale) * scale * .5 + random(vec2(ang)) * 0.1;
vec2 neighbor = vec2(cos(ang) * rad, sin(ang) * rad);
vec2 point = neighbor + pos;
vec2 r = g + point - f_st;
if(dot(mr - r, mr - r) > .0001)
md = min( md, dot( 0.5 * (mr + r), normalize(r - mr)) );
vec2 r = point - v_vTexcoord;
if(dot(mr - r, mr - r) > .0001)
md = min( md, dot( 0.5 * (mr + r), normalize(r - mr)) );
}
}
}
gl_FragColor = vec4(vec3(md), 1.0);
float c = middle + (md - middle) * contrast;
gl_FragColor = vec4(vec3(c), 1.0);
}

View file

@ -4,9 +4,17 @@
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 dimension;
uniform vec2 position;
uniform float scale;
uniform float time;
uniform float contrast;
uniform float middle;
uniform float radiusScale;
uniform float radiusShatter;
uniform int pattern;
#define TAU 6.28318
vec2 random2( vec2 p ) {
return fract(sin(vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)))) * 43758.5453);
@ -16,8 +24,10 @@ float random (in vec2 st) {
return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);
}
void main() {
vec2 st = v_vTexcoord + position;
vec2 pos = position / dimension;
vec2 st = v_vTexcoord - pos;
vec3 color = vec3(.0);
st *= scale;
@ -27,22 +37,41 @@ void main() {
float m_dist = 1.;
vec2 mp;
for (int y= -1; y <= 1; y++) {
for (int x= -1; x <= 1; x++) {
vec2 neighbor = vec2(float(x),float(y));
vec2 point = random2(i_st + neighbor);
point = 0.5 + 0.5 * sin(time + 6.2831 * point);
if(pattern == 0) {
for (int y = -1; y <= 1; y++) {
for (int x = -1; x <= 1; x++) {
vec2 neighbor = vec2(float(x),float(y));
vec2 point = random2(i_st + neighbor);
point = 0.5 + 0.5 * sin(time + 6.2831 * point);
vec2 _diff = neighbor + point - f_st;
vec2 _diff = neighbor + point - f_st;
float dist = length(_diff);
float dist = length(_diff);
if(dist < m_dist) {
m_dist = dist;
mp = point;
}
}
}
} else if(pattern == 1) {
for (int j = 0; j <= int(scale / 2.); j++) {
int _amo = int(scale) + int(float(j) * radiusShatter);
for (int i = 0; i <= _amo; i++) {
float ang = TAU / float(_amo) * float(i) + float(j) + time;
float rad = pow(float(j) / scale, radiusScale) * scale * .5 + random(vec2(ang)) * 0.1;
vec2 point = vec2(cos(ang) * rad, sin(ang) * rad) + pos;
if(dist < m_dist) {
m_dist = dist;
mp = point;
vec2 _diff = point - v_vTexcoord;
float dist = length(_diff);
if(dist < m_dist) {
m_dist = dist;
mp = point;
}
}
}
}
}
}
gl_FragColor = vec4(vec3(random(mp)),1.0);
float c = middle + (random(mp) - middle) * contrast;
gl_FragColor = vec4(vec3(c), 1.0);
}

View file

@ -7,6 +7,7 @@ varying vec4 v_vColour;
uniform vec2 position;
uniform float scale;
uniform float time;
uniform float contrast;
vec2 random2( vec2 p ) {
return fract(sin(vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)))) * 43758.5453);
@ -49,5 +50,6 @@ void main() {
// Draw the min distance (distance field)
color += m_dist;
gl_FragColor = vec4(color,1.0);
vec3 c = 0.5 + (color - 0.5) * contrast;
gl_FragColor = vec4(c, 1.0);
}

View file

@ -0,0 +1,21 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 position;
uniform vec2 scale;
uniform float width;
void main() {
vec2 _pos = v_vTexcoord + position;
vec2 dist = _pos - floor(_pos * scale) / scale;
float ww = width / 2.;
if(dist == clamp(dist, vec2(ww), vec2(1. / scale - ww)))
gl_FragColor = vec4(1.);
else
gl_FragColor = vec4(vec3(0.), 1.);
}

View file

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

View file

@ -0,0 +1,11 @@
{
"type": 1,
"parent": {
"name": "filter",
"path": "folders/shader/filter.yy",
},
"resourceVersion": "1.0",
"name": "sh_grid",
"tags": [],
"resourceType": "GMShader",
}

View file

@ -4,7 +4,6 @@
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 u_resolution;
uniform vec2 position;
uniform vec2 scale;
uniform float seed;

View file

@ -10,11 +10,14 @@ void main() {
vec2 _index = v_vTexcoord;
vec4 col = texture2D( gm_BaseTexture, v_vTexcoord );
if(col.a > 0.) {
float bright = dot(col.rgb, vec3(0.2126, 0.7152, 0.0722));
if(col.a > 0. && bright > 0.) {
for(float i = -1.; i <= 1.; i++)
for(float j = -1.; j <= 1.; j++) {
vec4 _col = texture2D( gm_BaseTexture, v_vTexcoord + vec2(i, j) / dimension );
if(_col.a > 0. && _col.b == col.b) {
float _bright = dot(_col.rgb, vec3(0.2126, 0.7152, 0.0722));
if(_col.a > 0. && abs(bright - _bright) < 0.1) {
_index.x = min(_index.x, _col.r);
_index.y = min(_index.y, _col.g);
}

View file

@ -44,7 +44,7 @@
{"id":"008bb78e-5edb-4f38-ae8a-21f7ad1419ec","Key":0.0,"Length":1.0,"Stretch":false,"Disabled":false,"IsCreationKey":false,"Channels":{"0":{"Id":{"name":"a723b2d8-4be6-4c70-9f25-3d678cf48b53","path":"sprites/s_node_output/s_node_output.yy",},"resourceVersion":"1.0","resourceType":"SpriteFrameKeyframe",},},"resourceVersion":"1.0","resourceType":"Keyframe<SpriteFrameKeyframe>",},
],"resourceVersion":"1.0","resourceType":"KeyframeStore<SpriteFrameKeyframe>",},"trackColour":0,"inheritsTrackColour":true,"builtinName":0,"traits":0,"interpolation":1,"tracks":[],"events":[],"isCreationTrack":false,"resourceVersion":"1.0","tags":[],"resourceType":"GMSpriteFramesTrack","modifiers":[],},
],
"visibleRange": {"x":0.0,"y":0.0,},
"visibleRange": null,
"lockOrigin": false,
"showBackdrop": true,
"showBackdropImage": false,