2024-06-22 12:09:44 +02:00
|
|
|
function Node_Blur_Path(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
|
|
|
name = "Path Blur";
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(0, nodeValue_Surface("Surface in", self));
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(1, nodeValue_PathNode("Blur Path", self, noone))
|
2024-06-22 12:09:44 +02:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(2, nodeValue_Int("Resolution", self, 32));
|
2024-06-22 12:09:44 +02:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(3, nodeValue_Surface("Mask", self));
|
2024-06-22 12:09:44 +02:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(4, nodeValue_Float("Mix", self, 1))
|
2024-06-22 12:09:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider);
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(5, nodeValue_Bool("Active", self, true));
|
2024-06-22 12:09:44 +02:00
|
|
|
active_index = 5;
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(6, nodeValue_Toggle("Channel", self, 0b1111, { data: array_create(4, THEME.inspector_channel) }));
|
2024-06-22 12:09:44 +02:00
|
|
|
|
|
|
|
__init_mask_modifier(3); // inputs 7, 8
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(9, nodeValue_Float("Intensity", self, 1));
|
2024-06-22 12:09:44 +02:00
|
|
|
|
[Blend, Composite] Add blends modes: color burn. linear burn, color dodge, linear dodge, soft light, hard light, vivid light, linear light, pin light, exclusion, divide.
2024-10-05 09:27:38 +02:00
|
|
|
newInput(10, nodeValue_Curve("Intensity Along Path", self, CURVE_DEF_11));
|
2024-06-22 12:09:44 +02:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(11, nodeValue_Slider_Range("Range", self, [ 0, 1 ]));
|
2024-06-22 12:09:44 +02:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(12, nodeValue_Float("Path Origin", self, 0))
|
2024-07-22 07:10:46 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider);
|
|
|
|
|
2024-06-22 12:09:44 +02:00
|
|
|
input_display_list = [ 5, 6,
|
|
|
|
["Surfaces", true], 0, 3, 4, 7, 8,
|
2024-07-22 07:10:46 +02:00
|
|
|
["Path", false], 1, 12, 11,
|
2024-06-22 12:09:44 +02:00
|
|
|
["Blur", false], 2, 9, 10,
|
|
|
|
];
|
|
|
|
|
2024-09-04 03:57:11 +02:00
|
|
|
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
|
2024-06-22 12:09:44 +02:00
|
|
|
|
|
|
|
attribute_surface_depth();
|
|
|
|
attribute_oversample();
|
|
|
|
|
|
|
|
static step = function() {
|
|
|
|
__step_mask_modifier();
|
|
|
|
}
|
|
|
|
|
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
|
|
|
if(!is_surface(_data[0])) return _outSurf;
|
|
|
|
|
|
|
|
var _samp = struct_try_get(attributes, "oversample");
|
|
|
|
var _surf = _data[0];
|
|
|
|
var _path = _data[1];
|
|
|
|
var _reso = _data[2];
|
|
|
|
var _intn = _data[9];
|
|
|
|
var _curv = _data[10];
|
|
|
|
var _rang = _data[11];
|
2024-07-22 07:10:46 +02:00
|
|
|
var _orig = _data[12];
|
2024-06-22 12:09:44 +02:00
|
|
|
|
|
|
|
var _pntc = clamp(_reso, 2, 128);
|
|
|
|
if(!is_struct(_path)) return _outSurf;
|
|
|
|
|
|
|
|
var _dim = surface_get_dimension(_surf)
|
|
|
|
var _points_x = array_create(_pntc);
|
|
|
|
var _points_y = array_create(_pntc);
|
|
|
|
var _p = new __vec2();
|
|
|
|
|
|
|
|
var _rst = _rang[0];
|
|
|
|
var _red = _rang[1];
|
|
|
|
var _rrr = _red - _rst;
|
|
|
|
|
|
|
|
var ox = 0, oy = 0;
|
2024-07-22 07:10:46 +02:00
|
|
|
_p = _path.getPointRatio(_orig, 0, _p);
|
2024-06-22 12:09:44 +02:00
|
|
|
ox = _p.x;
|
|
|
|
oy = _p.y;
|
|
|
|
|
|
|
|
for(var i = 0; i < _pntc; i++) {
|
|
|
|
var _pg = clamp(_rst + _rrr * i / (_pntc - 1), 0., 0.99);
|
|
|
|
_p = _path.getPointRatio(_pg, 0, _p);
|
|
|
|
|
|
|
|
_points_x[i] = (_p.x - ox) / _dim[0];
|
|
|
|
_points_y[i] = (_p.y - oy) / _dim[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
surface_set_shader(_outSurf, sh_blur_path);
|
|
|
|
shader_set_f("dimension", _dim);
|
|
|
|
shader_set_i("sampleMode", _samp);
|
|
|
|
|
|
|
|
shader_set_i("resolution", _pntc);
|
|
|
|
shader_set_i("pointAmount", _pntc);
|
|
|
|
shader_set_f("points_x", _points_x);
|
|
|
|
shader_set_f("points_y", _points_y);
|
|
|
|
|
|
|
|
shader_set_f("intensity", _intn);
|
|
|
|
shader_set_f("i_curve", _curv);
|
|
|
|
shader_set_i("i_amount", array_length(_curv));
|
|
|
|
|
|
|
|
draw_surface_safe(_surf);
|
|
|
|
surface_reset_shader();
|
|
|
|
|
|
|
|
__process_mask_modifier(_data);
|
|
|
|
_outSurf = mask_apply(_surf, _outSurf, _data[3], _data[4]);
|
|
|
|
_outSurf = channel_apply(_surf, _outSurf, _data[6]);
|
|
|
|
|
|
|
|
return _outSurf;
|
|
|
|
}
|
|
|
|
}
|