Path, Slope blur

This commit is contained in:
Tanasart 2024-01-23 20:40:03 +07:00
parent c1eca6817f
commit d58834ef9c
27 changed files with 411 additions and 309 deletions

View file

@ -652,6 +652,7 @@
{"name":"d3d_terrain","order":8,"path":"scripts/d3d_terrain/d3d_terrain.yy",},
{"name":"fd_rectangle_get_pressure_width","order":18,"path":"scripts/fd_rectangle_get_pressure_width/fd_rectangle_get_pressure_width.yy",},
{"name":"node_mk_flag","order":5,"path":"scripts/node_mk_flag/node_mk_flag.yy",},
{"name":"sh_blur_slope","order":10,"path":"shaders/sh_blur_slope/sh_blur_slope.yy",},
{"name":"sh_blend_normal","order":1,"path":"shaders/sh_blend_normal/sh_blend_normal.yy",},
{"name":"node_feedback_output","order":2,"path":"scripts/node_feedback_output/node_feedback_output.yy",},
{"name":"node_lua_surface","order":2,"path":"scripts/node_lua_surface/node_lua_surface.yy",},
@ -945,7 +946,7 @@
{"name":"s_node_animation_control","order":31,"path":"sprites/s_node_animation_control/s_node_animation_control.yy",},
{"name":"sh_image_trace","order":45,"path":"shaders/sh_image_trace/sh_image_trace.yy",},
{"name":"node_perlin","order":8,"path":"scripts/node_perlin/node_perlin.yy",},
{"name":"node_blur_simple","order":4,"path":"scripts/node_blur_simple/node_blur_simple.yy",},
{"name":"node_blur_non_uniform","order":4,"path":"scripts/node_blur_non_uniform/node_blur_non_uniform.yy",},
{"name":"node_feedback_input","order":1,"path":"scripts/node_feedback_input/node_feedback_input.yy",},
{"name":"s_node_vfx_trail","order":13,"path":"sprites/s_node_vfx_trail/s_node_vfx_trail.yy",},
{"name":"s_node_gui_in","order":37,"path":"sprites/s_node_gui_in/s_node_gui_in.yy",},
@ -1929,6 +1930,7 @@
{"name":"Obj_FirebaseFirestore_Collection_Query_Equal","order":3,"path":"objects/Obj_FirebaseFirestore_Collection_Query_Equal/Obj_FirebaseFirestore_Collection_Query_Equal.yy",},
{"name":"sh_local_analyze","order":28,"path":"shaders/sh_local_analyze/sh_local_analyze.yy",},
{"name":"s_node_array_zip","order":13,"path":"sprites/s_node_array_zip/s_node_array_zip.yy",},
{"name":"node_blur_slope","order":9,"path":"scripts/node_blur_slope/node_blur_slope.yy",},
{"name":"fd_rectangle_get_material_width","order":15,"path":"scripts/fd_rectangle_get_material_width/fd_rectangle_get_material_width.yy",},
{"name":"FirebaseREST_Firestore_collection_query_decode","order":7,"path":"scripts/FirebaseREST_Firestore_collection_query_decode/FirebaseREST_Firestore_collection_query_decode.yy",},
{"name":"node_noise_wavelet","order":13,"path":"scripts/node_noise_wavelet/node_noise_wavelet.yy",},

View file

@ -894,6 +894,7 @@
{"id":{"name":"d3d_terrain","path":"scripts/d3d_terrain/d3d_terrain.yy",},},
{"id":{"name":"fd_rectangle_get_pressure_width","path":"scripts/fd_rectangle_get_pressure_width/fd_rectangle_get_pressure_width.yy",},},
{"id":{"name":"node_mk_flag","path":"scripts/node_mk_flag/node_mk_flag.yy",},},
{"id":{"name":"sh_blur_slope","path":"shaders/sh_blur_slope/sh_blur_slope.yy",},},
{"id":{"name":"s_node_strandSim_render","path":"sprites/s_node_strandSim_render/s_node_strandSim_render.yy",},},
{"id":{"name":"sh_blend_normal","path":"shaders/sh_blend_normal/sh_blend_normal.yy",},},
{"id":{"name":"node_feedback_output","path":"scripts/node_feedback_output/node_feedback_output.yy",},},
@ -1232,7 +1233,7 @@
{"id":{"name":"node_align_functions","path":"scripts/node_align_functions/node_align_functions.yy",},},
{"id":{"name":"sh_image_trace","path":"shaders/sh_image_trace/sh_image_trace.yy",},},
{"id":{"name":"node_perlin","path":"scripts/node_perlin/node_perlin.yy",},},
{"id":{"name":"node_blur_simple","path":"scripts/node_blur_simple/node_blur_simple.yy",},},
{"id":{"name":"node_blur_non_uniform","path":"scripts/node_blur_non_uniform/node_blur_non_uniform.yy",},},
{"id":{"name":"node_feedback_input","path":"scripts/node_feedback_input/node_feedback_input.yy",},},
{"id":{"name":"s_node_vfx_trail","path":"sprites/s_node_vfx_trail/s_node_vfx_trail.yy",},},
{"id":{"name":"o_dialog_add_multiple_images","path":"objects/o_dialog_add_multiple_images/o_dialog_add_multiple_images.yy",},},
@ -2361,6 +2362,7 @@
{"id":{"name":"Obj_FirebaseFirestore_Collection_Query_Equal","path":"objects/Obj_FirebaseFirestore_Collection_Query_Equal/Obj_FirebaseFirestore_Collection_Query_Equal.yy",},},
{"id":{"name":"sh_local_analyze","path":"shaders/sh_local_analyze/sh_local_analyze.yy",},},
{"id":{"name":"s_node_array_zip","path":"sprites/s_node_array_zip/s_node_array_zip.yy",},},
{"id":{"name":"node_blur_slope","path":"scripts/node_blur_slope/node_blur_slope.yy",},},
{"id":{"name":"fd_rectangle_get_material_width","path":"scripts/fd_rectangle_get_material_width/fd_rectangle_get_material_width.yy",},},
{"id":{"name":"FirebaseREST_Firestore_collection_query_decode","path":"scripts/FirebaseREST_Firestore_collection_query_decode/FirebaseREST_Firestore_collection_query_decode.yy",},},
{"id":{"name":"node_noise_wavelet","path":"scripts/node_noise_wavelet/node_noise_wavelet.yy",},},

View file

@ -1,5 +1,5 @@
function Node_Blur_Simple(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Simple blur";
name = "Non-Uniform Blur";
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
inputs[| 1] = nodeValue("Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 3)

View file

@ -0,0 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "node_blur_non_uniform",
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "blur",
"path": "folders/nodes/data/filter/blur.yy",
},
}

View file

@ -0,0 +1,70 @@
function Node_Blur_Slope(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Slope Blur";
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
inputs[| 1] = nodeValue("Strength", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4)
.setDisplay(VALUE_DISPLAY.slider, { range: [1, 32, 1] })
.setMappable(9);
inputs[| 2] = nodeValue("Slope Map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| 3] = nodeValue("Mask", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
inputs[| 4] = nodeValue("Mix", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setDisplay(VALUE_DISPLAY.slider);
inputs[| 5] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 5;
inputs[| 6] = nodeValue("Channel", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0b1111)
.setDisplay(VALUE_DISPLAY.toggle, { data: array_create(4, THEME.inspector_channel) });
__init_mask_modifier(3); // inputs 7, 8
//////////////////////////////////////////////////////////////////////////////////////////////////
inputs[| 9] = nodeValueMap("Strength map", self);
//////////////////////////////////////////////////////////////////////////////////////////////////
inputs[| 10] = nodeValue("Step", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.1)
.setDisplay(VALUE_DISPLAY.slider, { range: [0, 1, 0.01] });
input_display_list = [ 5, 6,
["Surfaces", true], 0, 3, 4, 7, 8,
["Blur", false], 2, 1, 9, 10,
]
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
attribute_surface_depth();
attribute_oversample();
attribute_interpolation();
static step = function() { #region
__step_mask_modifier();
inputs[| 1].mappableStep();
} #endregion
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
surface_set_shader(_outSurf, sh_blur_slope);
shader_set_interpolation(_data[0]);
shader_set_f("dimension", surface_get_dimension(_data[0]));
shader_set_f_map("strength", _data[1], _data[ 9], inputs[| 1]);
shader_set_f("stepSize", _data[10]);
shader_set_surface("slopeMap", _data[2]);
shader_set_f("slopeMapDim", surface_get_dimension(_data[2]));
shader_set_i("sampleMode", struct_try_get(attributes, "oversample"));
draw_surface_safe(_data[0], 0, 0);
surface_reset_shader();
__process_mask_modifier(_data);
_outSurf = mask_apply(_data[0], _outSurf, _data[3], _data[4]);
_outSurf = channel_apply(_data[0], _outSurf, _data[6]);
return _outSurf;
} #endregion
}

View file

@ -1,7 +1,7 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "node_blur_simple",
"name": "node_blur_slope",
"isCompatibility": false,
"isDnD": false,
"parent": {

View file

@ -0,0 +1,37 @@
function Node_create_BW(_x, _y) {
var node = new Node_BW(_x, _y);
ds_list_add(PANEL_GRAPH.nodes_list, node);
return node;
}
function Node_BW(_x, _y) : Node_Processor(_x, _y) constructor {
name = "BW";
uniform_exp = shader_get_uniform(sh_bw, "brightness");
uniform_con = shader_get_uniform(sh_bw, "contrast");
inputs[| 0] = new NodeValue(0, "Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
inputs[| 1] = new NodeValue(1, "Brightness", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0);
inputs[| 1].setDisplay(VALUE_DISPLAY.slider, [ -1, 1, 0.01]);
inputs[| 2] = new NodeValue(2, "Contrast", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1);
inputs[| 2].setDisplay(VALUE_DISPLAY.slider, [ -1, 4, 0.01]);
outputs[| 0] = new NodeValue(0, "Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, surface_create(1, 1));
function process_data(_inSurf, _outSurf, _data) {
var _exp = _data[1];
var _con = _data[2];
surface_set_target(_outSurf);
draw_clear_alpha(0, 0);
shader_set(sh_bw);
shader_set_uniform_f(uniform_exp, _exp);
shader_set_uniform_f(uniform_con, _con);
draw_surface(_inSurf, 0, 0);
shader_reset();
surface_reset_target();
return _outSurf;
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,6 @@
function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Lua Compute";
update_on_frame = true;
inputs[| 0] = nodeValue("Function name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "render" + string(irandom_range(100000, 999999)));
@ -34,9 +35,6 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru
lua_state = lua_create();
error_notification = noone;
compiled = false;
static createNewInput = function() { #region
var index = ds_list_size(inputs);
inputs[| index + 0] = nodeValue("Argument name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" );
@ -50,35 +48,8 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru
inputs[| index + 2].editWidget.interactable = false;
} if(!LOADING && !APPENDING) createNewInput(); #endregion
static stepBegin = function() { #region
if(PROJECT.animator.frame_progress)
setRenderStatus(false);
setHeight();
doStepBegin();
value_validation[VALIDATION.error] = !compiled;
if(!compiled && error_notification == noone) {
error_notification = noti_error("Lua node [" + string(name) + "] not compiled.");
error_notification.onClick = function() { PANEL_GRAPH.focusNode(self); };
}
if(compiled && error_notification != noone) {
noti_remove(error_notification);
error_notification = noone;
}
var _type = getInputData(1);
switch(_type) {
case 0 : outputs[| 1].setType(VALUE_TYPE.float); break;
case 1 : outputs[| 1].setType(VALUE_TYPE.text); break;
case 2 : outputs[| 1].setType(VALUE_TYPE.struct); break;
}
} #endregion
static getState = function() { #region
if(inputs[| 3].isLeaf())
return lua_state;
if(inputs[| 3].isLeaf()) return lua_state;
return inputs[| 3].value_from.node.getState();
} #endregion
@ -126,29 +97,20 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru
createNewInput();
} #endregion
static onValueFromUpdate = function(index) { #region
if(index == 0 || index == 2) compiled = false;
} #endregion
static onValueUpdate = function(index = 0) { #region
if(index == 0 || index == 2) compiled = false;
if(index == 3) {
for( var i = 0; i < array_length(outputs[| 0].value_to); i++ ) {
var _j = outputs[| 0].value_to[i];
if(_j.value_from != outputs[| 0]) continue;
_j.node.compiled = false;
}
compiled = false;
}
if(LOADING || APPENDING) return;
compiled = false;
refreshDynamicInput();
if((index - input_fix_len) % data_length == 0) refreshDynamicInput();
} #endregion
static step = function() { #region
var _type = getInputData(1);
switch(_type) {
case 0 : outputs[| 1].setType(VALUE_TYPE.float); break;
case 1 : outputs[| 1].setType(VALUE_TYPE.text); break;
case 2 : outputs[| 1].setType(VALUE_TYPE.struct); break;
}
for( var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length ) {
var name = getInputData(i + 0);
inputs[| i + 2].name = name;
@ -156,27 +118,21 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru
} #endregion
static update = function(frame = CURRENT_FRAME) { #region
if(!compiled) return;
//if(!PROJECT.animator.is_playing || !PROJECT.animator.frame_progress) return;
var _func = getInputData(0);
var _dimm = getInputData(1);
var _exec = getInputData(4);
if(!_exec) return;
update_on_frame = _exec;
argument_val = [];
for( var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length )
array_push(argument_val, getInputData(i + 2));
lua_projectData(getState());
addCode();
var res = 0;
try {
res = lua_call_w(getState(), _func, argument_val);
} catch(e) {
noti_warning(exception_print(e),, self);
}
try { res = lua_call_w(getState(), _func, argument_val); }
catch(e) { noti_warning(exception_print(e),, self); }
outputs[| 1].setValue(res);
} #endregion
@ -190,44 +146,17 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru
array_push(argument_name, getInputData(i + 0));
}
var lua_code = "function " + _func + "(";
var lua_code = $"function {_func}(";
for( var i = 0, n = array_length(argument_name); i < n; i++ ) {
if(i) lua_code += ", "
lua_code += argument_name[i];
}
lua_code += ")\n";
lua_code += _code;
lua_code += "\nend";
lua_code += $")\n{_code}\nend";
lua_add_code(getState(), lua_code);
} #endregion
insp1UpdateTooltip = __txt("Compile");
insp1UpdateIcon = [ THEME.refresh, 1, COLORS._main_value_positive ];
static onInspector1Update = function() { #region
var thrd = inputs[| 3].value_from;
if(thrd == noone) {
doCompile();
return;
}
thrd.node.onInspector1Update();
} #endregion
static doCompile = function() { #region
compiled = true;
addCode();
for( var i = 0; i < array_length(outputs[| 0].value_to); i++ ) {
var _j = outputs[| 0].value_to[i];
if(_j.value_from != outputs[| 0]) continue;
_j.node.doCompile();
}
doUpdate();
} #endregion
static doApplyDeserialize = function() { #region
refreshDynamicInput();

View file

@ -14,94 +14,28 @@ function Node_Lua_Global(_x, _y, _group = noone) : Node(_x, _y, _group) construc
outputs[| 0] = nodeValue("Execution thread", self, JUNCTION_CONNECT.output, VALUE_TYPE.node, noone );
input_display_list = [
["Main", false], 2, 1, 0,
["Main", false], 2, 1, 0,
];
lua_state = lua_create();
lua_state = lua_create();
is_beginning = false;
error_notification = noone;
compiled = false;
static stepBegin = function() { #region
var _type = getInputData(1);
if(PROJECT.animator.is_playing && PROJECT.animator.frame_progress && (IS_FIRST_FRAME || _type == 1))
setRenderStatus(false);
setHeight();
doStepBegin();
value_validation[VALIDATION.error] = !compiled;
if(!compiled && error_notification == noone) {
error_notification = noti_error("Lua node [" + string(name) + "] not compiled.");
error_notification.onClick = function() { PANEL_GRAPH.focusNode(self); };
}
if(compiled && error_notification != noone) {
noti_remove(error_notification);
error_notification = noone;
}
} #endregion
static getState = function() { #region
if(inputs[| 2].isLeaf()) return lua_state;
return inputs[| 2].value_from.node.getState();
} #endregion
static onValueFromUpdate = function(index) { #region
if(index == 0 || index == 2) compiled = false;
} #endregion
static onValueUpdate = function(index = 0) { #region
if(index == 0 || index == 2) compiled = false;
} #endregion
static update = function(frame = CURRENT_FRAME) { #region
if(!compiled) return;
//if(!PROJECT.animator.is_playing || !PROJECT.animator.frame_progress) return;
var _code = getInputData(0);
var _type = getInputData(1);
//if(IS_FIRST_FRAME) { //rerfesh state on the first frame
// lua_state_destroy(lua_state);
// lua_state = lua_create();
// addCode();
//}
update_on_frame = _type;
lua_projectData(getState());
if(IS_FIRST_FRAME || _type == 1) {
try { lua_add_code(getState(), _code); }
catch(e) { noti_warning(exception_print(e),, self); }
}
try { lua_add_code(getState(), _code); }
catch(e) { noti_warning(exception_print(e),, self); }
} #endregion
static onInspector1Update = function() { #region
var thrd = inputs[| 2].value_from;
if(thrd == noone) {
doCompile();
return;
}
thrd.node.onInspector1Update();
} #endregion
static doCompile = function() { #region
compiled = true;
for( var i = 0; i < array_length(outputs[| 0].value_to); i++ ) {
var _j = outputs[| 0].value_to[i];
if(_j.value_from != outputs[| 0]) continue;
_j.node.doCompile();
}
doUpdate();
} #endregion
static doApplyDeserialize = function() { doCompile(); }
static onDestroy = function() { #region
lua_state_destroy(lua_state);
if(error_notification != noone)

View file

@ -1,6 +1,7 @@
function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Lua Surface";
preview_channel = 1;
update_on_frame = true;
inputs[| 0] = nodeValue("Function name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "render" + string(irandom_range(100000, 999999)));
@ -36,9 +37,6 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru
lua_state = lua_create();
error_notification = noone;
compiled = false;
static createNewInput = function() { #region
var index = ds_list_size(inputs);
inputs[| index + 0] = nodeValue("Argument name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" );
@ -52,25 +50,6 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru
inputs[| index + 2].editWidget.interactable = false;
} if(!LOADING && !APPENDING) createNewInput(); #endregion
static stepBegin = function() { #region
if(PROJECT.animator.frame_progress)
setRenderStatus(false);
setHeight();
doStepBegin();
value_validation[VALIDATION.error] = !compiled;
if(!compiled && error_notification == noone) {
error_notification = noti_error("Lua node [" + string(name) + "] not compiled.");
error_notification.onClick = function() { PANEL_GRAPH.focusNode(self); };
}
if(compiled && error_notification != noone) {
noti_remove(error_notification);
error_notification = noone;
}
} #endregion
static getState = function() { #region
if(inputs[| 3].isLeaf())
return lua_state;
@ -121,26 +100,10 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru
createNewInput();
} #endregion
static onValueFromUpdate = function(index) { #region
if(index == 0 || index == 2) compiled = false;
} #endregion
static onValueUpdate = function(index = 0) { #region
if(index == 0 || index == 2) compiled = false;
if(index == 3) {
for( var i = 0; i < array_length(outputs[| 0].value_to); i++ ) {
var _j = outputs[| 0].value_to[i];
if(_j.value_from != outputs[| 0]) continue;
_j.node.compiled = false;
}
compiled = false;
}
if(LOADING || APPENDING) return;
compiled = false;
refreshDynamicInput();
if((index - input_fix_len) % data_length == 0) refreshDynamicInput();
} #endregion
static step = function() { #region
@ -151,34 +114,24 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru
} #endregion
static update = function(frame = CURRENT_FRAME) { #region
if(!compiled) return;
//if(!PROJECT.animator.is_playing || !PROJECT.animator.frame_progress) return;
var _func = getInputData(0);
var _dimm = getInputData(1);
var _exec = getInputData(4);
if(!_exec) return;
update_on_frame = _exec;
argument_val = [];
for( var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length ) {
for( var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length )
array_push(argument_val, getInputData(i + 2));
}
//if(IS_FIRST_FRAME) { //rerfesh state on the first frame
// lua_state_destroy(lua_state);
// lua_state = lua_create();
// addCode();
//}
lua_projectData(getState());
addCode();
var _outSurf = outputs[| 1].getValue();
_outSurf = surface_verify(_outSurf, _dimm[0], _dimm[1], attrDepth());
surface_set_target(_outSurf);
try { lua_call_w(getState(), _func, argument_val); }
catch(e) { noti_warning(exception_print(e),, self); }
catch(e) { noti_warning(exception_print(e),, self); }
surface_reset_target();
outputs[| 1].setValue(_outSurf);
@ -193,44 +146,17 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru
array_push(argument_name, getInputData(i + 0));
}
var lua_code = "function " + _func + "(";
var lua_code = $"function {_func}(";
for( var i = 0, n = array_length(argument_name); i < n; i++ ) {
if(i) lua_code += ", "
lua_code += argument_name[i];
}
lua_code += ")\n";
lua_code += _code;
lua_code += "\nend";
lua_code += $")\n{_code}\nend";
lua_add_code(getState(), lua_code);
} #endregion
insp1UpdateTooltip = __txt("Compile");
insp1UpdateIcon = [ THEME.refresh, 1, COLORS._main_value_positive ];
static onInspector1Update = function() { #region
var thrd = inputs[| 3].value_from;
if(thrd == noone) {
doCompile();
return;
}
thrd.node.onInspector1Update();
} #endregion
static doCompile = function() { #region
addCode();
compiled = true;
for( var i = 0; i < array_length(outputs[| 0].value_to); i++ ) {
var _j = outputs[| 0].value_to[i];
if(_j.value_from != outputs[| 0]) continue;
_j.node.doCompile();
}
doUpdate();
} #endregion
static doApplyDeserialize = function() { #region
refreshDynamicInput();

View file

@ -104,14 +104,6 @@ function Node_Path_Smooth(_x, _y, _group = noone) : Node(_x, _y, _group) constru
var a = inputs[| i].drawOverlay(_act, _x, _y, _s, _mx, _my, _snx, _sny);
_act &= !a;
if(a) _anchor_hover = i;
//var a = anchors[ i - input_fix_len];
//var c = controls[i - input_fix_len];
//draw_set_color(c_red);
//draw_circle(_x + (a[0] + c[0]) * _s, _y + (a[1] + c[1]) * _s, 4, false);
//draw_set_color(c_blue);
//draw_circle(_x + (a[0] + c[2]) * _s, _y + (a[1] + c[3]) * _s, 4, false);
}
#endregion
}
@ -158,8 +150,8 @@ function Node_Path_Smooth(_x, _y, _group = noone) : Node(_x, _y, _group) constru
var con = loop? ansize : ansize - 1;
for(var i = 0; i < con; i++) {
var _a0 = anchors[(i + 0) % ansize];
var _a1 = anchors[(i + 1) % ansize];
var _a0 = anchors[ (i + 0) % ansize];
var _a1 = anchors[ (i + 1) % ansize];
var _c0 = controls[(i + 0) % ansize];
var _c1 = controls[(i + 1) % ansize];
@ -213,11 +205,11 @@ function Node_Path_Smooth(_x, _y, _group = noone) : Node(_x, _y, _group) constru
var ansize = ds_list_size(inputs) - input_fix_len;
if(ansize == 0) return out;
var _a0, _a1;
for(var i = 0; i < ansize; i++) {
_a0 = anchors[(i + 0) % ansize];
_a1 = anchors[(i + 1) % ansize];
var _a0 = anchors[ (i + 0) % ansize];
var _a1 = anchors[ (i + 1) % ansize];
var _c0 = controls[(i + 0) % ansize];
var _c1 = controls[(i + 1) % ansize];
if(_dist > lengths[i]) {
_dist -= lengths[i];
@ -225,7 +217,9 @@ function Node_Path_Smooth(_x, _y, _group = noone) : Node(_x, _y, _group) constru
}
var _t = _dist / lengths[i];
//var _p = eval_bezier(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _a0[4], _a0[1] + _a0[5], _a1[0] + _a1[2], _a1[1] + _a1[3]);
var _p = eval_bezier(_t, _a0[0], _a0[1], _a1[0], _a1[1],
_a0[0] + _c0[2], _a0[1] + _c0[3],
_a1[0] + _c1[0], _a1[1] + _c1[1]);
out.x = _p[0];
out.y = _p[1];

View file

@ -495,8 +495,9 @@ function __initNodes() {
ds_list_add(filter, "Blurs");
addNodeObject(filter, "Blur", s_node_blur, "Node_Blur", [1, Node_Blur], ["gaussian blur"], "Blur image smoothly.");
addNodeObject(filter, "Simple Blur", s_node_blur_simple, "Node_Blur_Simple", [1, Node_Blur_Simple],, "Blur image using simpler algorithm. Allowing for variable blur strength.").setVersion(1070);
addNodeObject(filter, "Non-Uniform Blur", s_node_blur_simple, "Node_Blur_Simple", [1, Node_Blur_Simple],, "Blur image using simpler algorithm. Allowing for variable blur strength.").setVersion(1070);
addNodeObject(filter, "Directional Blur", s_node_blur_directional,"Node_Blur_Directional",[1, Node_Blur_Directional], ["motion blur"], "Blur image given a direction.");
/**/ addNodeObject(filter, "Slope Blur", s_node_blur_directional,"Node_Blur_Slope", [1, Node_Blur_Slope], ["motion blur"], "Blur along a gradient of a slope map.").setVersion(11640);
addNodeObject(filter, "Zoom Blur", s_node_zoom, "Node_Blur_Zoom", [1, Node_Blur_Zoom],, "Blur image by zooming in/out from a mid point.");
addNodeObject(filter, "Radial Blur", s_node_radial, "Node_Blur_Radial", [1, Node_Blur_Radial],, "Blur image by rotating aroung a mid point.").setVersion(1110);
addNodeObject(filter, "Lens Blur", s_node_bokeh, "Node_Blur_Bokeh", [1, Node_Blur_Bokeh], ["bokeh"], "Create bokeh effect. Blur lighter color in a lens-like manner.").setVersion(1110);

View file

@ -0,0 +1,115 @@
#define MAX_STRENGTH 64.
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 dimension;
uniform sampler2D slopeMap;
uniform vec2 slopeMapDim;
uniform float stepSize;
uniform vec2 strength;
uniform int strengthUseSurf;
uniform sampler2D strengthSurf;
uniform int sampleMode;
vec2 tx;
vec2 txMap;
#region /////////////// SAMPLING ///////////////
const float PI = 3.14159265358979323846;
uniform int interpolation;
uniform vec2 sampleDimension;
const int RSIN_RADIUS = 1;
float sinc ( float x ) { return x == 0.? 1. : sin(x * PI) / (x * PI); }
vec4 texture2D_rsin( sampler2D texture, vec2 uv ) {
vec2 tx = 1.0 / sampleDimension;
vec2 p = uv * sampleDimension - vec2(0.5);
vec4 sum = vec4(0.0);
float weights = 0.;
for (int x = -RSIN_RADIUS; x <= RSIN_RADIUS; x++)
for (int y = -RSIN_RADIUS; y <= RSIN_RADIUS; y++) {
float a = length(vec2(float(x), float(y))) / float(RSIN_RADIUS);
if(a > 1.) continue;
float w = sinc(a * PI * tx.x) * sinc(a * PI * tx.y);
vec2 offset = vec2(float(x), float(y)) * tx;
vec4 sample = texture2D(texture, (p + offset + vec2(0.5)) / sampleDimension);
sum += w * sample;
weights += w;
}
return sum / weights;
}
vec4 texture2D_bicubic( sampler2D texture, vec2 uv ) {
uv = uv * sampleDimension + 0.5;
vec2 iuv = floor( uv );
vec2 fuv = fract( uv );
uv = iuv + fuv * fuv * (3.0 - 2.0 * fuv);
uv = (uv - 0.5) / sampleDimension;
return texture2D( texture, uv );
}
vec4 texture2Dintp( sampler2D texture, vec2 uv ) {
if(interpolation == 2) return texture2D_bicubic( texture, uv );
else if(interpolation == 3) return texture2D_rsin( texture, uv );
return texture2D( texture, uv );
}
#endregion
vec4 sampleTexture(sampler2D texture, vec2 pos) { #region
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
return texture2Dintp(texture, pos);
if(sampleMode == 0) return vec4(0.);
if(sampleMode == 1) return texture2Dintp(texture, clamp(pos, 0., 1.));
if(sampleMode == 2) return texture2Dintp(texture, fract(pos));
return vec4(0.);
} #endregion
float sampleBright(vec2 pos) { vec4 c = sampleTexture(slopeMap, pos); return (c.r + c.g + c.b) / 3.; }
vec2 sampleSlope(vec2 pos) { #region
float h0 = sampleBright(pos + vec2(-txMap.x, 0.));
float h1 = sampleBright(pos + vec2( txMap.x, 0.));
float h2 = sampleBright(pos + vec2(0., -txMap.y));
float h3 = sampleBright(pos + vec2(0., txMap.y));
return vec2(h1 - h0, h3 - h2);
} #endregion
void main() {
float str = strength.x;
if(strengthUseSurf == 1) {
vec4 _vMap = texture2D( strengthSurf, v_vTexcoord );
str = mix(strength.x, strength.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
tx = 1. / dimension;
txMap = 1. / slopeMapDim;
float alpha = 0.;
vec4 colr = vec4(0.);
vec2 pos = v_vTexcoord;
for(float i = 0.; i < MAX_STRENGTH; i++) {
if(i > str) break;
float str = 1. - (i / str);
vec4 c = sampleTexture(gm_BaseTexture, pos);
colr += c * str;
alpha += str;
vec2 slp = sampleSlope(pos);
pos += slp * stepSize;
}
gl_FragColor = colr / alpha;
}

View file

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

View file

@ -0,0 +1,10 @@
{
"resourceType": "GMShader",
"resourceVersion": "1.0",
"name": "sh_blur_slope",
"parent": {
"name": "blur",
"path": "folders/shader/filter/blur.yy",
},
"type": 1,
}

View file

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

View file

@ -12,7 +12,7 @@ uniform vec2 dimension;
uniform sampler2D normalMap;
uniform float normalHeight;
uniform vec3 ambiance;
uniform vec4 ambiance;
uniform int lightType;
uniform vec4 lightPosition;
uniform vec4 lightColor;
@ -23,7 +23,7 @@ void main() {
vec3 normal = normalize(texture2D( normalMap, v_vTexcoord ).rgb * -2.0 + 1.0) * normalHeight;
float aspect = dimension.x / dimension.y;
vec3 result = ambiance * base_color.rgb;
vec3 result = ambiance.rgb * base_color.rgb;
vec3 lightPos = vec3(lightPosition.x / dimension.x, lightPosition.y / dimension.y, lightPosition.z);
float attenuation = lightIntensity;

View file

@ -1,58 +1,53 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform sampler2D map;
/////////////// SAMPLING ///////////////
#region /////////////// SAMPLING ///////////////
const float PI = 3.14159265358979323846;
uniform int interpolation;
uniform vec2 sampleDimension;
const float PI = 3.14159265358979323846;
uniform int interpolation;
uniform vec2 sampleDimension;
const int RSIN_RADIUS = 1;
const int RSIN_RADIUS = 1;
float sinc ( float x ) { return x == 0.? 1. : sin(x * PI) / (x * PI); }
float sinc ( float x ) { return x == 0.? 1. : sin(x * PI) / (x * PI); }
vec4 texture2D_rsin( sampler2D texture, vec2 uv ) {
vec2 tx = 1.0 / sampleDimension;
vec2 p = uv * sampleDimension - vec2(0.5);
vec4 texture2D_rsin( sampler2D texture, vec2 uv ) {
vec2 tx = 1.0 / sampleDimension;
vec2 p = uv * sampleDimension - vec2(0.5);
vec4 sum = vec4(0.0);
float weights = 0.;
vec4 sum = vec4(0.0);
float weights = 0.;
for (int x = -RSIN_RADIUS; x <= RSIN_RADIUS; x++)
for (int y = -RSIN_RADIUS; y <= RSIN_RADIUS; y++) {
float a = length(vec2(float(x), float(y))) / float(RSIN_RADIUS);
if(a > 1.) continue;
float w = sinc(a * PI * tx.x) * sinc(a * PI * tx.y);
vec2 offset = vec2(float(x), float(y)) * tx;
vec4 sample = texture2D(texture, (p + offset + vec2(0.5)) / sampleDimension);
sum += w * sample;
weights += w;
}
for (int x = -RSIN_RADIUS; x <= RSIN_RADIUS; x++)
for (int y = -RSIN_RADIUS; y <= RSIN_RADIUS; y++) {
float a = length(vec2(float(x), float(y))) / float(RSIN_RADIUS);
if(a > 1.) continue;
float w = sinc(a * PI * tx.x) * sinc(a * PI * tx.y);
vec2 offset = vec2(float(x), float(y)) * tx;
vec4 sample = texture2D(texture, (p + offset + vec2(0.5)) / sampleDimension);
sum += w * sample;
weights += w;
}
return sum / weights;
}
return sum / weights;
}
vec4 texture2D_bicubic( sampler2D texture, vec2 uv ) {
uv = uv * sampleDimension + 0.5;
vec2 iuv = floor( uv );
vec2 fuv = fract( uv );
uv = iuv + fuv * fuv * (3.0 - 2.0 * fuv);
uv = (uv - 0.5) / sampleDimension;
return texture2D( texture, uv );
}
vec4 texture2D_bicubic( sampler2D texture, vec2 uv ) {
uv = uv * sampleDimension + 0.5;
vec2 iuv = floor( uv );
vec2 fuv = fract( uv );
uv = iuv + fuv * fuv * (3.0 - 2.0 * fuv);
uv = (uv - 0.5) / sampleDimension;
return texture2D( texture, uv );
}
vec4 texture2Dintp( sampler2D texture, vec2 uv ) {
if(interpolation == 2) return texture2D_bicubic( texture, uv );
else if(interpolation == 3) return texture2D_rsin( texture, uv );
return texture2D( texture, uv );
}
/////////////// SAMPLING ///////////////
vec4 texture2Dintp( sampler2D texture, vec2 uv ) {
if(interpolation == 2) return texture2D_bicubic( texture, uv );
else if(interpolation == 3) return texture2D_rsin( texture, uv );
return texture2D( texture, uv );
}
#endregion
void main() {
vec4 map = texture2Dintp( map, v_vTexcoord );