[Normalize] Add localized normal mode.

This commit is contained in:
Tanasart 2025-01-12 10:53:32 +07:00
parent 23ed5c0acc
commit a3fc6c57e6
25 changed files with 469 additions and 111 deletions

View file

@ -993,6 +993,7 @@
{"name":"node_path_reverse","order":11,"path":"scripts/node_path_reverse/node_path_reverse.yy",},
{"name":"node_path_sample","order":7,"path":"scripts/node_path_sample/node_path_sample.yy",},
{"name":"node_path_scatter","order":25,"path":"scripts/node_path_scatter/node_path_scatter.yy",},
{"name":"node_path_sdf","order":27,"path":"scripts/node_path_sdf/node_path_sdf.yy",},
{"name":"node_path_separate_folder","order":12,"path":"scripts/node_path_separate_folder/node_path_separate_folder.yy",},
{"name":"node_path_shape","order":2,"path":"scripts/node_path_shape/node_path_shape.yy",},
{"name":"node_path_shift","order":8,"path":"scripts/node_path_shift/node_path_shift.yy",},
@ -1088,7 +1089,7 @@
{"name":"node_scale","order":12,"path":"scripts/node_scale/node_scale.yy",},
{"name":"node_scatter_points","order":7,"path":"scripts/node_scatter_points/node_scatter_points.yy",},
{"name":"node_scatter","order":13,"path":"scripts/node_scatter/node_scatter.yy",},
{"name":"node_segment_filter","order":27,"path":"scripts/node_segment_filter/node_segment_filter.yy",},
{"name":"node_segment_filter","order":29,"path":"scripts/node_segment_filter/node_segment_filter.yy",},
{"name":"node_separate_color","order":42,"path":"scripts/node_separate_color/node_separate_color.yy",},
{"name":"node_sequence_anim","order":5,"path":"scripts/node_sequence_anim/node_sequence_anim.yy",},
{"name":"node_shadow_cast","order":27,"path":"scripts/node_shadow_cast/node_shadow_cast.yy",},
@ -1393,6 +1394,7 @@
{"name":"theme_definition","order":14,"path":"scripts/theme_definition/theme_definition.yy",},
{"name":"tiler_tool_brush_shape","order":7,"path":"scripts/tiler_tool_brush_shape/tiler_tool_brush_shape.yy",},
{"name":"tiler_tool_brush","order":5,"path":"scripts/tiler_tool_brush/tiler_tool_brush.yy",},
{"name":"sh_normalize_local","order":1,"path":"shaders/sh_normalize_local/sh_normalize_local.yy",},
{"name":"tiler_tool_fill","order":6,"path":"scripts/tiler_tool_fill/tiler_tool_fill.yy",},
{"name":"tiler_tool_selection_shape","order":9,"path":"scripts/tiler_tool_selection_shape/tiler_tool_selection_shape.yy",},
{"name":"tiler_tool_selection","order":8,"path":"scripts/tiler_tool_selection/tiler_tool_selection.yy",},
@ -1603,8 +1605,8 @@
{"name":"sh_freeform_fill_pass2","order":8,"path":"shaders/sh_freeform_fill_pass2/sh_freeform_fill_pass2.yy",},
{"name":"sh_FXAA","order":26,"path":"shaders/sh_FXAA/sh_FXAA.yy",},
{"name":"sh_gamma_map","order":33,"path":"shaders/sh_gamma_map/sh_gamma_map.yy",},
{"name":"sh_get_max_downsampled","order":1,"path":"shaders/sh_get_max_downsampled/sh_get_max_downsampled.yy",},
{"name":"sh_get_min_downsampled","order":2,"path":"shaders/sh_get_min_downsampled/sh_get_min_downsampled.yy",},
{"name":"sh_get_max_downsampled","order":2,"path":"shaders/sh_get_max_downsampled/sh_get_max_downsampled.yy",},
{"name":"sh_get_min_downsampled","order":3,"path":"shaders/sh_get_min_downsampled/sh_get_min_downsampled.yy",},
{"name":"sh_glow","order":21,"path":"shaders/sh_glow/sh_glow.yy",},
{"name":"sh_gradient_display_alpha","order":1,"path":"shaders/sh_gradient_display_alpha/sh_gradient_display_alpha.yy",},
{"name":"sh_gradient_points","order":3,"path":"shaders/sh_gradient_points/sh_gradient_points.yy",},
@ -1695,6 +1697,7 @@
{"name":"sh_palette_shift","order":31,"path":"shaders/sh_palette_shift/sh_palette_shift.yy",},
{"name":"sh_path_fill_profile","order":16,"path":"shaders/sh_path_fill_profile/sh_path_fill_profile.yy",},
{"name":"sh_path_morph","order":23,"path":"shaders/sh_path_morph/sh_path_morph.yy",},
{"name":"sh_path_sdf","order":28,"path":"shaders/sh_path_sdf/sh_path_sdf.yy",},
{"name":"sh_pb_blob","order":1,"path":"shaders/sh_pb_blob/sh_pb_blob.yy",},
{"name":"sh_pb_brick","order":9,"path":"shaders/sh_pb_brick/sh_pb_brick.yy",},
{"name":"sh_pb_draw_mask","order":8,"path":"shaders/sh_pb_draw_mask/sh_pb_draw_mask.yy",},
@ -2183,6 +2186,7 @@
{"name":"s_node_path_reverse","order":100,"path":"sprites/s_node_path_reverse/s_node_path_reverse.yy",},
{"name":"s_node_path_sample","order":101,"path":"sprites/s_node_path_sample/s_node_path_sample.yy",},
{"name":"s_node_path_scatter","order":107,"path":"sprites/s_node_path_scatter/s_node_path_scatter.yy",},
{"name":"s_node_path_sdf","order":138,"path":"sprites/s_node_path_sdf/s_node_path_sdf.yy",},
{"name":"s_node_path_separate_folder","order":83,"path":"sprites/s_node_path_separate_folder/s_node_path_separate_folder.yy",},
{"name":"s_node_path_shape","order":110,"path":"sprites/s_node_path_shape/s_node_path_shape.yy",},
{"name":"s_node_path_shift","order":102,"path":"sprites/s_node_path_shift/s_node_path_shift.yy",},

View file

@ -435,6 +435,12 @@
{"$GMIncludedFile":"","%Name":"shader.vs","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom/ExtraBlur/ExtraBlur_Two_Passes","name":"shader.vs","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"tooltip_spr.png","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom/ExtraBlur/ExtraBlur_Two_Passes","name":"tooltip_spr.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"display_data.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom/ShaderToy","name":"display_data.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"icon.png","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom/ShaderToy/ShaderToy_Brannan","name":"icon.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom/ShaderToy/ShaderToy_Brannan","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"node.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom/ShaderToy/ShaderToy_Brannan","name":"node.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"shader.fs","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom/ShaderToy/ShaderToy_Brannan","name":"shader.fs","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"shader.vs","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom/ShaderToy/ShaderToy_Brannan","name":"shader.vs","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"tooltip_spr.png","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom/ShaderToy/ShaderToy_Brannan","name":"tooltip_spr.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"icon.png","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom/ShaderToy/ShaderToy_CRT","name":"icon.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom/ShaderToy/ShaderToy_CRT","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"node.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom/ShaderToy/ShaderToy_CRT","name":"node.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
@ -1133,6 +1139,7 @@
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Node_Path_Reverse","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Node_Path_Sample","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Node_Path_Scatter","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Node_Path_SDF","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Node_Path_Separate_Folder","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Node_Path_Shape","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Node_Path_Shift","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
@ -1197,11 +1204,7 @@
{"$GMIncludedFile":"","%Name":"related_node.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes","name":"related_node.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"tileset_gamemaker2_room.yy","CopyToMask":-1,"filePath":"datafiles/data/TemplateStrings","name":"tileset_gamemaker2_room.yy","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"Theme.zip","CopyToMask":-1,"filePath":"datafiles/data","name":"Theme.zip","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"dllcredits.txt","ConfigValues":{
"Itch":{
"CopyToMask":"0",
},
},"CopyToMask":0,"filePath":"datafiles","name":"dllcredits.txt","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"dllcredits.txt","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":0,"filePath":"datafiles","name":"dllcredits.txt","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"dlltest1.dll","CopyToMask":-1,"filePath":"datafiles","name":"dlltest1.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"ffmpeg.exe","CopyToMask":-1,"filePath":"datafiles/ffmpeg/bin","name":"ffmpeg.exe","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"LICENSE","CopyToMask":-1,"filePath":"datafiles/ffmpeg","name":"LICENSE","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
@ -1220,11 +1223,7 @@
{"$GMIncludedFile":"","%Name":"mf.dll","CopyToMask":-1,"filePath":"datafiles","name":"mf.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"mfcore.dll","CopyToMask":-1,"filePath":"datafiles","name":"mfcore.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"mfplat.dll","CopyToMask":-1,"filePath":"datafiles","name":"mfplat.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"PixelComposer_profile-2.provisionprofile","ConfigValues":{
"Itch":{
"CopyToMask":"2",
},
},"CopyToMask":-1,"filePath":"datafiles","name":"PixelComposer_profile-2.provisionprofile","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"PixelComposer_profile-2.provisionprofile","ConfigValues":{"Itch":{"CopyToMask":"2",},},"CopyToMask":-1,"filePath":"datafiles","name":"PixelComposer_profile-2.provisionprofile","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"data.win","CopyToMask":-1,"filePath":"datafiles/report","name":"data.win","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"execute_shell_simple_ext_x64.dll","CopyToMask":-1,"filePath":"datafiles/report","name":"execute_shell_simple_ext_x64.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
{"$GMIncludedFile":"","%Name":"options.ini","CopyToMask":-1,"filePath":"datafiles/report","name":"options.ini","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
@ -1653,6 +1652,7 @@
{"id":{"name":"d3d_torus","path":"scripts/d3d_torus/d3d_torus.yy",},},
{"id":{"name":"d3d_transformation","path":"scripts/d3d_transformation/d3d_transformation.yy",},},
{"id":{"name":"d3d_uvsphere","path":"scripts/d3d_uvsphere/d3d_uvsphere.yy",},},
{"id":{"name":"sh_normalize_local","path":"shaders/sh_normalize_local/sh_normalize_local.yy",},},
{"id":{"name":"d3d_vertex","path":"scripts/d3d_vertex/d3d_vertex.yy",},},
{"id":{"name":"d3d_wall_builder","path":"scripts/d3d_wall_builder/d3d_wall_builder.yy",},},
{"id":{"name":"debug","path":"scripts/debug/debug.yy",},},
@ -2157,6 +2157,7 @@
{"id":{"name":"node_path_reverse","path":"scripts/node_path_reverse/node_path_reverse.yy",},},
{"id":{"name":"node_path_sample","path":"scripts/node_path_sample/node_path_sample.yy",},},
{"id":{"name":"node_path_scatter","path":"scripts/node_path_scatter/node_path_scatter.yy",},},
{"id":{"name":"node_path_sdf","path":"scripts/node_path_sdf/node_path_sdf.yy",},},
{"id":{"name":"node_path_separate_folder","path":"scripts/node_path_separate_folder/node_path_separate_folder.yy",},},
{"id":{"name":"node_path_shape","path":"scripts/node_path_shape/node_path_shape.yy",},},
{"id":{"name":"node_path_shift","path":"scripts/node_path_shift/node_path_shift.yy",},},
@ -2955,6 +2956,7 @@
{"id":{"name":"sh_palette_shift","path":"shaders/sh_palette_shift/sh_palette_shift.yy",},},
{"id":{"name":"sh_path_fill_profile","path":"shaders/sh_path_fill_profile/sh_path_fill_profile.yy",},},
{"id":{"name":"sh_path_morph","path":"shaders/sh_path_morph/sh_path_morph.yy",},},
{"id":{"name":"sh_path_sdf","path":"shaders/sh_path_sdf/sh_path_sdf.yy",},},
{"id":{"name":"sh_pb_blob","path":"shaders/sh_pb_blob/sh_pb_blob.yy",},},
{"id":{"name":"sh_pb_brick","path":"shaders/sh_pb_brick/sh_pb_brick.yy",},},
{"id":{"name":"sh_pb_draw_mask","path":"shaders/sh_pb_draw_mask/sh_pb_draw_mask.yy",},},
@ -3485,6 +3487,7 @@
{"id":{"name":"s_node_path_reverse","path":"sprites/s_node_path_reverse/s_node_path_reverse.yy",},},
{"id":{"name":"s_node_path_sample","path":"sprites/s_node_path_sample/s_node_path_sample.yy",},},
{"id":{"name":"s_node_path_scatter","path":"sprites/s_node_path_scatter/s_node_path_scatter.yy",},},
{"id":{"name":"s_node_path_sdf","path":"sprites/s_node_path_sdf/s_node_path_sdf.yy",},},
{"id":{"name":"s_node_path_separate_folder","path":"sprites/s_node_path_separate_folder/s_node_path_separate_folder.yy",},},
{"id":{"name":"s_node_path_shape","path":"sprites/s_node_path_shape/s_node_path_shape.yy",},},
{"id":{"name":"s_node_path_shift","path":"sprites/s_node_path_shift/s_node_path_shift.yy",},},

Binary file not shown.

View file

@ -0,0 +1,11 @@
{
"name":"Path To SDF",
"tooltip":"Draw distance field from path.",
"alias":[],
"spr":"s_node_path_sdf",
"pxc_version":118068,
"baseNode":"Node_Path_SDF",
"io":[
"pathnode"
],
}

View file

@ -351,6 +351,7 @@
"Node_Blur_Box",
"Node_Blur_Shape",
"Node_High_Pass",
"Node_FXAA",
{ "label": "/Linear" },
"Node_Blur_Directional",
"Node_Blur_Slope",
@ -762,6 +763,7 @@
"Node_Path_Fill",
"Node_Path_Map",
"Node_Path_Morph",
"Node_Path_SDF",
{ "label": "/Segments" },
"Node_Segment_Filter",

View file

@ -17,7 +17,7 @@ function Node_3D_Light(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
#macro __d3d_input_list_light ["Light", false], in_d3d + 0, in_d3d + 1, in_d3d + 2
static setLight = function(light, _data) { #region
static setLight = function(light, _data) {
var _col = _data[in_d3d + 1];
var _int = _data[in_d3d + 2];
@ -25,11 +25,11 @@ function Node_3D_Light(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
light.intensity = _int;
return light;
} #endregion
}
static processData = function(_output, _data, _output_index, _array_index = 0) { }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
PROCESSOR_OVERLAY_CHECK
var _colr = current_data[in_d3d + 1];
@ -39,5 +39,5 @@ function Node_3D_Light(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
draw_set_circle_precision(32);
draw_circle(bbox.xc, bbox.yc, 8 * _s, false);
draw_circle(bbox.xc, bbox.yc, 12 * _s, true);
} #endregion
}
}

View file

@ -44,7 +44,7 @@
VERSION = 1_18_06_2;
SAVE_VERSION = 1_18_05_0;
VERSION_STRING = MAC? "1.18.003m" : "1.18.7.007";
BUILD_NUMBER = 1_18_06_8;
BUILD_NUMBER = 118068;
PREF_VERSION = 1_17_1;
var _vsp = string_split(VERSION_STRING, ".");

View file

@ -659,7 +659,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
updateKeyMap();
return;
}
var base = prop.def_val;
for(var i = 0; i < array_length(_data); i++) {

View file

@ -252,7 +252,8 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
function createControl() {
var index = array_length(inputs);
newInput(index, nodeValue_Float("Control point", self, [ PUPPET_FORCE_MODE.move, 16, 16, 8, 0, 8, 8 ]))
newInput(index, nodeValue_Float("Control point", self))
.setValue([ PUPPET_FORCE_MODE.move, 16, 16, 8, 0, 8, 8 ])
.setDisplay(VALUE_DISPLAY.puppet_control)
array_push(input_display_list, index);

View file

@ -3,9 +3,15 @@ function Node_Normalize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
newInput(0, nodeValue_Surface("Surface in", self));
newInput(1, nodeValue_Enum_Button("Mode", self, 0, [ "BW", "RGB" ]));
newInput(1, nodeValue_Enum_Button("Channels", self, 0, [ "BW", "RGB" ]));
input_display_list = [ 0, 1 ];
newInput(2, nodeValue_Enum_Button("Modes", self, 0, [ "Global", "Local" ]));
newInput(3, nodeValue_Int("Radius", self, 4));
input_display_list = [ 0, 1,
["Normalize", false], 2, 3,
];
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
@ -13,98 +19,110 @@ function Node_Normalize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
temp_surface = [ surface_create(1, 1), surface_create(1, 1), surface_create(1, 1), surface_create(1, 1) ];
static step = function() {
}
static step = function() {}
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _surf = _data[0];
var _mode = _data[1];
var _chan = _data[1];
var _mode = _data[2];
var _lrad = _data[3];
var _sw = surface_get_width(_surf);
var _sh = surface_get_height(_surf);
var _itr = ceil(logn(4, _sw * _sh / 1024));
var _sww = ceil(_sw / 2);
var _shh = ceil(_sh / 2);
for (var i = 0, n = array_length(temp_surface); i < n; i++)
temp_surface[i] = surface_verify(temp_surface[i], _sw, _sh);
surface_set_shader(temp_surface[0]);
draw_surface_safe(_surf);
surface_reset_shader();
surface_set_shader(temp_surface[1]);
draw_surface_safe(_surf);
surface_reset_shader();
surface_clear(temp_surface[2]);
surface_clear(temp_surface[3]);
var _ind = 1;
repeat(_itr) {
surface_resize(temp_surface[(_ind) * 2 + 0], _sww, _shh);
surface_resize(temp_surface[(_ind) * 2 + 1], _sww, _shh);
shader_set(sh_get_max_downsampled);
surface_set_target_ext(0, temp_surface[(_ind) * 2 + 0]);
surface_set_target_ext(1, temp_surface[(_ind) * 2 + 1]);
shader_set_f("dimension", _sww, _shh);
shader_set_surface("surfaceMax", temp_surface[(!_ind) * 2 + 0]);
shader_set_surface("surfaceMin", temp_surface[(!_ind) * 2 + 1]);
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _sww, _shh);
surface_reset_target();
shader_reset();
_sww = ceil(_sww / 2);
_shh = ceil(_shh / 2);
_ind = !_ind;
}
var _sMax = temp_surface[(!_ind) * 2 + 0];
var _sMin = temp_surface[(!_ind) * 2 + 1];
var _ssw = surface_get_width(_sMax);
var _ssh = surface_get_height(_sMax);
var _max = [ 0, 0, 0 ];
var _min = [ 1, 1, 1 ];
var _bMax = buffer_from_surface(_sMax, false);
var _bMin = buffer_from_surface(_sMin, false);
buffer_seek(_bMax, buffer_seek_start, 0);
buffer_seek(_bMin, buffer_seek_start, 0);
repeat(_ssw * _ssh) {
var _cc = buffer_read(_bMax, buffer_u32);
_max[0] = max(_max[0], _color_get_red(_cc));
_max[1] = max(_max[1], _color_get_green(_cc));
_max[2] = max(_max[2], _color_get_blue(_cc));
var _cc = buffer_read(_bMin, buffer_u32);
_min[0] = min(_min[0], _color_get_red(_cc));
_min[1] = min(_min[1], _color_get_green(_cc));
_min[2] = min(_min[2], _color_get_blue(_cc));
}
buffer_delete(_bMax);
buffer_delete(_bMin);
if(_mode == 0) {
var _bmax = (_max[0] + _max[1] + _max[2]) / 3;
var _bmin = (_min[0] + _min[1] + _min[2]) / 3;
var _itr = ceil(logn(4, _sw * _sh / 1024));
_max = [ _bmax, _bmax, _bmax ];
_min = [ _bmin, _bmin, _bmin ];
var _sww = ceil(_sw / 2);
var _shh = ceil(_sh / 2);
for (var i = 0, n = array_length(temp_surface); i < n; i++)
temp_surface[i] = surface_verify(temp_surface[i], _sw, _sh);
surface_set_shader(temp_surface[0]);
draw_surface_safe(_surf);
surface_reset_shader();
surface_set_shader(temp_surface[1]);
draw_surface_safe(_surf);
surface_reset_shader();
surface_clear(temp_surface[2]);
surface_clear(temp_surface[3]);
var _ind = 1;
repeat(_itr) {
surface_resize(temp_surface[(_ind) * 2 + 0], _sww, _shh);
surface_resize(temp_surface[(_ind) * 2 + 1], _sww, _shh);
shader_set(sh_get_max_downsampled);
surface_set_target_ext(0, temp_surface[(_ind) * 2 + 0]);
surface_set_target_ext(1, temp_surface[(_ind) * 2 + 1]);
shader_set_f("dimension", _sww, _shh);
shader_set_surface("surfaceMax", temp_surface[(!_ind) * 2 + 0]);
shader_set_surface("surfaceMin", temp_surface[(!_ind) * 2 + 1]);
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _sww, _shh);
surface_reset_target();
shader_reset();
_sww = ceil(_sww / 2);
_shh = ceil(_shh / 2);
_ind = !_ind;
}
var _sMax = temp_surface[(!_ind) * 2 + 0];
var _sMin = temp_surface[(!_ind) * 2 + 1];
var _ssw = surface_get_width(_sMax);
var _ssh = surface_get_height(_sMax);
var _max = [ 0, 0, 0 ];
var _min = [ 1, 1, 1 ];
var _bMax = buffer_from_surface(_sMax, false);
var _bMin = buffer_from_surface(_sMin, false);
buffer_seek(_bMax, buffer_seek_start, 0);
buffer_seek(_bMin, buffer_seek_start, 0);
repeat(_ssw * _ssh) {
var _cc = buffer_read(_bMax, buffer_u32);
_max[0] = max(_max[0], _color_get_red(_cc));
_max[1] = max(_max[1], _color_get_green(_cc));
_max[2] = max(_max[2], _color_get_blue(_cc));
var _cc = buffer_read(_bMin, buffer_u32);
_min[0] = min(_min[0], _color_get_red(_cc));
_min[1] = min(_min[1], _color_get_green(_cc));
_min[2] = min(_min[2], _color_get_blue(_cc));
}
buffer_delete(_bMax);
buffer_delete(_bMin);
if(_chan == 0) {
var _bmax = (_max[0] + _max[1] + _max[2]) / 3;
var _bmin = (_min[0] + _min[1] + _min[2]) / 3;
_max = [ _bmax, _bmax, _bmax ];
_min = [ _bmin, _bmin, _bmin ];
}
surface_set_shader(_outSurf, sh_normalize);
shader_set_f("cMax", _max);
shader_set_f("cMin", _min);
draw_surface_safe(_surf);
surface_reset_shader();
} else if(_mode == 1) {
surface_set_shader(_outSurf, sh_normalize_local);
shader_set_2("dimension", [_sw, _sh]);
shader_set_i("radius", _lrad);
shader_set_i("channels", _chan);
draw_surface_safe(_surf);
surface_reset_shader();
}
surface_set_shader(_outSurf, sh_normalize);
shader_set_f("cMax", _max);
shader_set_f("cMin", _min);
draw_surface_safe(_surf);
surface_reset_shader();
return _outSurf;
}
}

View file

@ -107,7 +107,8 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
static createNewInput = function(_x = 0, _y = 0, _dxx = 0, _dxy = 0, _dyx = 0, _dyy = 0, rec = true) {
var index = array_length(inputs);
newInput(index, nodeValue_Path_Anchor("Anchor", self, newAnchor( _x, _y, _dxx, _dxy, _dyx, _dyy )));
newInput(index, nodeValue_Path_Anchor("Anchor", self, []))
.setValue(newAnchor( _x, _y, _dxx, _dxy, _dyx, _dyy ));
if(rec) {
recordAction(ACTION_TYPE.array_insert, inputs, [ inputs[index], index, $"add path anchor point {index}" ]);

View file

@ -114,7 +114,8 @@ function Node_Path_3D(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
var index = array_length(inputs);
newInput(index, nodeValue_Path_Anchor_3D("Anchor", self, [ _x, _y, _z, _dxx, _dxy, _dxz, _dyx, _dyy, _dyz, false ]));
newInput(index, nodeValue_Path_Anchor_3D("Anchor", self, []))
.setValue([ _x, _y, _z, _dxx, _dxy, _dxz, _dyx, _dyy, _dyz, false ]);
if(!rec) return inputs[index];

View file

@ -0,0 +1,68 @@
function Node_Path_SDF(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Path to SDF";
dimension_index = 1;
newInput(0, nodeValue_PathNode("Path", self, noone))
.setVisible(true, true)
.rejectArray();
newInput(1, nodeValue_Dimension(self));
newInput(2, nodeValue_Int("Subdivision", self, 64))
.setValidator(VV_min(2))
.rejectArray();
newInput(3, nodeValue_Float("Max Distance", self, 16));
newInput(4, nodeValue_Bool("Inverted", self, false));
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
input_display_list = [ 0,
["Path", false], 1, 2,
["Render", false], 3, 4,
]
attribute_surface_depth();
temp_surface = [ 0, 0 ];
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
var _path = getInputData(0);
if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
}
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _path = _data[0];
var _dim = _data[1];
var _sub = _data[2];
var _maxd = _data[3];
var _inv = _data[4];
if(_path == noone) return _outSurf;
var _p = array_create((_sub + 1) * 2);
var _isb = 1 / _sub;
var _pp = new __vec2();
for( var i = 0; i <= _sub; i++ ) {
var _prog = frac(i * _isb);
_pp = _path.getPointRatio(_prog, 0, _pp);
_p[i * 2 + 0] = _pp.x;
_p[i * 2 + 1] = _pp.y;
}
surface_set_shader(_outSurf, sh_path_sdf);
shader_set_2("dimension", _dim);
shader_set_i("subdivision", _sub);
shader_set_f("points", _p);
shader_set_f("maxDistance", _maxd);
shader_set_i("inverted", _inv);
draw_empty();
surface_reset_shader();
return _outSurf;
}
}

View file

@ -0,0 +1,14 @@
{
"$GMScript":"v1",
"%Name":"node_path_sdf",
"isCompatibility":false,
"isDnD":false,
"name":"node_path_sdf",
"parent":{
"name":"path",
"path":"folders/nodes/data/value/path.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",
"tags":[],
}

View file

@ -315,10 +315,14 @@ function NodeObject(_name, _node, _tooltip = "") constructor {
if(struct_has(_data, "tooltip")) setTooltip(_data.tooltip);
if(struct_has(_data, "spr")) {
var _spr = _data[$ "spr"];
_spr = asset_get_index(_spr);
var _ispr = _data[$ "spr"];
_spr = asset_get_index(_ispr);
if(sprite_exists(_spr)) spr = _spr;
if(sprite_exists(_spr))
spr = _spr;
else
print($"Node icon not found {_ispr}");
} else {
var pth = $"{sourceDir}/icon.png";
if(file_exists_empty(pth)) {

View file

@ -0,0 +1,48 @@
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 dimension;
uniform int radius;
uniform int channels;
void main() {
vec2 tx = 1. / dimension;
vec3 _cmin = vec3(1.);
vec3 _cmax = vec3(0.);
float _lmin = 1.;
float _lmax = 1.;
vec4 cc = texture2D(gm_BaseTexture, v_vTexcoord);
float bb = dot(cc.rgb, vec3(0.2126, 0.7152, 0.0722));
for(int i = -radius; i <= radius; i++)
for(int j = -radius; j <= radius; j++) {
vec2 _offsNorm = vec2(float(i) / float(radius), float(j) / float(radius));
float _inf = length(_offsNorm);
if(_inf > 1.) continue;
float inf = smoothstep(0., 1., 1. - _inf);
vec4 c = texture2D(gm_BaseTexture, v_vTexcoord + vec2(float(i), float(j)) * tx);
float b = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722));
vec3 _c = c.rgb + (cc.rgb - c.rgb) * inf;
_cmin = min(_cmin, _c);
_cmax = max(_cmax, _c);
float _b = bb + (b - bb) * inf;
_lmin = min(_lmin, _b);
_lmax = max(_lmax, _b);
}
if(channels == 0) {
vec3 clr = (cc.rgb - _lmin) / (_lmax - _lmin);
gl_FragColor = vec4(clr, cc.a);
} else {
vec3 clr = (cc.rgb - _cmin) / (_cmax - _cmin);
gl_FragColor = vec4(clr, cc.a);
}
}

View file

@ -0,0 +1,14 @@
attribute vec3 in_Position; // (x, y, z)
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,13 @@
{
"$GMShader":"",
"%Name":"sh_normalize_local",
"name":"sh_normalize_local",
"parent":{
"name":"normalize",
"path":"folders/nodes/data/filter/colors/normalize.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"tags":[],
"type":1,
}

View file

@ -0,0 +1,42 @@
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 dimension;
uniform int subdivision;
uniform float maxDistance;
uniform int inverted;
uniform vec2 points[1024];
vec2 pointToLine(in vec2 p, in vec2 l0, in vec2 l1) {
float l2 = pow(l0.x - l1.x, 2.) + pow(l0.y - l1.y, 2.);
if (l2 == 0.) return l0;
float t = ((p.x - l0.x) * (l1.x - l0.x) + (p.y - l0.y) * (l1.y - l0.y)) / l2;
t = clamp(t, 0., 1.);
return mix(l0, l1, t);
}
void main() {
vec2 px = v_vTexcoord * dimension;
float minDist = 9999.;
vec2 ox = points[0], nx;
vec2 p;
for(int i = 1; i < subdivision; i++) {
nx = points[i];
p = pointToLine(px, ox, nx);
float dist = distance(px, p);
minDist = min(minDist, dist);
ox = nx;
}
float distC = minDist / maxDistance;
if(inverted == 1) distC = 1. - distC;
gl_FragColor = vec4(vec3(distC), 1.);
}

View file

@ -0,0 +1,14 @@
attribute vec3 in_Position; // (x, y, z)
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,13 @@
{
"$GMShader":"",
"%Name":"sh_path_sdf",
"name":"sh_path_sdf",
"parent":{
"name":"path",
"path":"folders/nodes/data/value/path.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"tags":[],
"type":1,
}

View file

@ -1,6 +1,3 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View file

@ -0,0 +1,90 @@
{
"$GMSprite":"",
"%Name":"s_node_path_sdf",
"bboxMode":0,
"bbox_bottom":61,
"bbox_left":2,
"bbox_right":61,
"bbox_top":2,
"collisionKind":1,
"collisionTolerance":0,
"DynamicTexturePage":false,
"edgeFiltering":false,
"For3D":false,
"frames":[
{"$GMSpriteFrame":"","%Name":"740e91e8-2b30-4242-bf49-c24d1e6a2996","name":"740e91e8-2b30-4242-bf49-c24d1e6a2996","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
],
"gridX":0,
"gridY":0,
"height":64,
"HTile":false,
"layers":[
{"$GMImageLayer":"","%Name":"6f821eec-dc59-4a9a-96d9-0338724fd767","blendMode":0,"displayName":"default","isLocked":false,"name":"6f821eec-dc59-4a9a-96d9-0338724fd767","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
],
"name":"s_node_path_sdf",
"nineSlice":null,
"origin":4,
"parent":{
"name":"value",
"path":"folders/nodes/icons/value.yy",
},
"preMultiplyAlpha":false,
"resourceType":"GMSprite",
"resourceVersion":"2.0",
"sequence":{
"$GMSequence":"",
"%Name":"s_node_path_sdf",
"autoRecord":true,
"backdropHeight":768,
"backdropImageOpacity":0.5,
"backdropImagePath":"",
"backdropWidth":1366,
"backdropXOffset":0.0,
"backdropYOffset":0.0,
"events":{
"$KeyframeStore<MessageEventKeyframe>":"",
"Keyframes":[],
"resourceType":"KeyframeStore<MessageEventKeyframe>",
"resourceVersion":"2.0",
},
"eventStubScript":null,
"eventToFunction":{},
"length":1.0,
"lockOrigin":false,
"moments":{
"$KeyframeStore<MomentsEventKeyframe>":"",
"Keyframes":[],
"resourceType":"KeyframeStore<MomentsEventKeyframe>",
"resourceVersion":"2.0",
},
"name":"s_node_path_sdf",
"playback":1,
"playbackSpeed":30.0,
"playbackSpeedType":0,
"resourceType":"GMSequence",
"resourceVersion":"2.0",
"showBackdrop":true,
"showBackdropImage":false,
"timeUnits":1,
"tracks":[
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"740e91e8-2b30-4242-bf49-c24d1e6a2996","path":"sprites/s_node_path_sdf/s_node_path_sdf.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
},"Disabled":false,"id":"a74bf031-80e5-4d0b-87cd-cd6e5aa7534f","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
],
"visibleRange":null,
"volume":1.0,
"xorigin":32,
"yorigin":32,
},
"swatchColours":null,
"swfPrecision":0.5,
"textureGroupId":{
"name":"Default",
"path":"texturegroups/Default",
},
"type":0,
"VTile":false,
"width":64,
}