This commit is contained in:
Tanasart 2024-12-30 17:05:35 +07:00
parent 690f187cf7
commit 548e54b6ab
4 changed files with 168 additions and 21 deletions

View file

@ -607,8 +607,12 @@ event_inherited();
hh += _lbh + ui(4);
yy += _lbh + ui(4);
while(index + 1 < node_count && !is_string(_list[| index + 1]))
while(index + 1 < node_count) {
var _s = _list[| index + 1];
if(is_string(_s) && (!string_starts_with(_s, "/") || PREFERENCES.dialog_add_node_grouping == 2)) break;
index++;
}
} else {
hh += _lbh + ui(12);
yy += _lbh + ui(12);
@ -761,7 +765,7 @@ event_inherited();
var bg_ind = 0;
var yy = _y + ui(12);
var pd = ui(8);
var sec_pd = PREFERENCES.dialog_add_node_grouping == 1? ui(8) : ui(6);
var sec_pd = ui(4);
hh += list_height;
for(var i = 0; i < node_count; i++) {
@ -787,8 +791,12 @@ event_inherited();
hh += _lbh;
yy += _lbh;
while(i + 1 < node_count && !is_string(_list[| i + 1]))
while(i + 1 < node_count) {
var _s = _list[| i + 1];
if(is_string(_s) && (!string_starts_with(_s, "/") || PREFERENCES.dialog_add_node_grouping == 2)) break;
i++;
}
} else {
hh += _lbh + sec_pd;
yy += _lbh + sec_pd;
@ -1036,7 +1044,7 @@ event_inherited();
var hh = 0;
var _hover = sHOVER && search_pane.hover;
var grid_size = ui(64);
var grid_size = ui(56);
var grid_width = ui(80);
var grid_space = ui(16);
@ -1315,20 +1323,22 @@ event_inherited();
}
node_focusing = -1;
var s_sfz = list_height * 4;
var s_sfz = PREFERENCES.dialog_add_node_view == 1? list_height * 4 : 0;
if(keyboard_check_pressed(vk_up)) {
node_selecting = safe_mod(node_selecting - 1 + amo, amo);
node_focusing = node_selecting;
search_pane.scroll_y_to = max(search_pane.scroll_y_to, -list_height * node_selecting + s_sfz);
if(PREFERENCES.dialog_add_node_view == 1)
search_pane.scroll_y_to = max(search_pane.scroll_y_to, -list_height * node_selecting + s_sfz);
}
if(keyboard_check_pressed(vk_down)) {
node_selecting = safe_mod(node_selecting + 1, amo);
node_focusing = node_selecting;
search_pane.scroll_y_to = min(search_pane.scroll_y_to, -list_height * node_selecting - s_sfz + search_pane.h);
if(PREFERENCES.dialog_add_node_view == 1)
search_pane.scroll_y_to = min(search_pane.scroll_y_to, -list_height * node_selecting - s_sfz + search_pane.h);
}
return hh;

View file

@ -4,7 +4,7 @@ function Node_Mirror_Polar(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
newInput(0, nodeValue_Surface("Surface in", self));
newInput(1, nodeValue_Vec2("Position", self, [ 0.5, 0.5 ]))
.setUnitRef(function(index) { return getDimension(index); }, VALUE_UNIT.reference);
.setUnitRef(function(i) /*=>*/ {return getDimension(i)}, VALUE_UNIT.reference);
newInput(2, nodeValue_Rotation("Angle", self, 0));
@ -15,15 +15,26 @@ function Node_Mirror_Polar(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
newInput(5, nodeValue_Bool("Reflective", self, false));
newInput(6, nodeValue_Vec2("Scale", self, [ 1, 1 ]));
newInput(7, nodeValue_Enum_Scroll("Output Dimension", self, 0, [ "Same as input", "Relative", "Constant" ]));
newInput(8, nodeValue_Vec2("Relative Dimension", self, [ 1, 1 ]));
newInput(9, nodeValue_Vec2("Constant Dimension", self, DEF_SURF));
newInput(10, nodeValue_Enum_Scroll("Radial Scale", self, 0, [ "Linear", "Exponential" ]));
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
input_display_list = [ 3,
["Surfaces", false], 0,
["Mirror", false], 1, 2,
["Surfaces", false], 0, 7, 8, 9,
["Mirror", false], 1, 2, 6, 10,
["Spokes", false], 4, 5,
]
attribute_surface_depth();
attribute_interpolation();
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
PROCESSOR_OVERLAY_CHECK
@ -48,23 +59,56 @@ function Node_Mirror_Polar(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
return _hov;
}
static getDimension = function(arr = 0) {
var _surf = getSingleValue(0, arr);
var _outt = getSingleValue(7, arr);
var _relS = getSingleValue(8, arr);
var _conS = getSingleValue(9, arr);
var _dim = surface_get_dimension(_surf);
switch(_outt) {
case 1 :
_dim[0] *= _relS[0];
_dim[1] *= _relS[1];
break;
case 2 : _dim = _conS; break;
}
return _dim;
}
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _suf = _data[0];
var _pos = _data[1];
var _ang = _data[2];
var _spk = _data[4];
var _ref = _data[5];
var _sca = _data[6];
var _dim = surface_get_dimension(_suf);
var _outt = _data[7];
var _relS = _data[8];
var _conS = _data[9];
var _rsca = _data[10];
inputs[8].setVisible(_outt == 1);
inputs[9].setVisible(_outt == 2);
var _dim = surface_get_dimension(_outSurf);
surface_set_shader(_outSurf, sh_mirror_polar);
shader_set_interpolation(_data[0]);
shader_set_f("dimension", _dim);
shader_set_2("position", _pos);
shader_set_f("angle", degtorad(_ang));
shader_set_f("spokes", _spk);
shader_set_i("reflecc", _ref);
shader_set_2("scale", _sca);
shader_set_i("rscale", _rsca);
draw_surface_safe(_suf);
draw_surface_stretched(_suf, 0, 0, _dim[0], _dim[1]);
surface_reset_shader();
return _outSurf;

View file

@ -232,7 +232,7 @@ function NodeObject(_name, _spr, _node, _create, _tooltip = "") constructor {
if(point_in_circle(_mx, _my, spr_x, spr_y, ui(10))) TOOLTIP = __txt("Supporter exclusive");
tx += ui(16);
tx += ui(12);
}
return tx;

View file

@ -1,3 +1,94 @@
#pragma use(sampler)
#region -- sampler -- [1730686036.7372286]
uniform int interpolation;
uniform vec2 sampleDimension;
uniform int sampleMode;
const float PI = 3.14159265358979323846;
float sinc ( float x ) { return x == 0.? 1. : sin(x * PI) / (x * PI); }
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 );
}
const int RSIN_RADIUS = 1;
vec4 texture2D_rsin( sampler2D texture, vec2 uv ) {
vec2 tx = 1.0 / sampleDimension;
vec2 p = uv * sampleDimension;
vec4 col = vec4(0.);
float wei = 0.;
for (int x = -RSIN_RADIUS; x <= RSIN_RADIUS; x++)
for (int y = -RSIN_RADIUS; y <= RSIN_RADIUS; y++) {
vec2 sx = vec2(float(x), float(y));
float a = length(sx) / float(RSIN_RADIUS);
// if(a > 1.) continue;
vec4 sample = texture2D(texture, uv + sx * tx);
float w = sinc(a * PI * tx.x) * sinc(a * PI * tx.y);
col += w * sample;
wei += w;
}
col /= wei;
return col;
}
const int LANCZOS_RADIUS = 3;
float lanczosWeight(float d, float n) { return d == 0.0 ? 1.0 : (d * d < n * n ? sinc(d) * sinc(d / n) : 0.0); }
vec4 texture2D_lanczos3( sampler2D texture, vec2 uv ) {
vec2 center = uv - (mod(uv * sampleDimension, 1.0) - 0.5) / sampleDimension;
vec2 offset = (uv - center) * sampleDimension;
vec2 tx = 1. / sampleDimension;
vec4 col = vec4(0.);
float wei = 0.;
for(int x = -LANCZOS_RADIUS; x < LANCZOS_RADIUS; x++)
for(int y = -LANCZOS_RADIUS; y < LANCZOS_RADIUS; y++) {
float wx = lanczosWeight(float(x) - offset.x, float(LANCZOS_RADIUS));
float wy = lanczosWeight(float(y) - offset.y, float(LANCZOS_RADIUS));
float w = wx * wy;
col += w * texture2D(texture, center + vec2(x, y) * tx);
wei += w;
}
col /= wei;
return col;
}
vec4 texture2Dintp( sampler2D texture, vec2 uv ) {
if(interpolation <= 2) return texture2D( texture, uv );
else if(interpolation == 3) return texture2D_bicubic( texture, uv );
else if(interpolation == 4) return texture2D_lanczos3( texture, uv );
return texture2D( texture, uv );
}
vec4 sampleTexture( sampler2D texture, vec2 pos) {
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
return texture2Dintp(texture, pos);
if(sampleMode <= 1) return vec4(0.);
else if(sampleMode == 2) return texture2Dintp(texture, clamp(pos, 0., 1.));
else if(sampleMode == 3) return texture2Dintp(texture, fract(pos));
else if(sampleMode == 4) return vec4(vec3(0.), 1.);
return vec4(0.);
}
#endregion -- sampler --
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
@ -6,9 +97,11 @@ varying vec4 v_vColour;
uniform vec2 dimension;
uniform vec2 position;
uniform vec2 scale;
uniform float angle;
uniform float spokes;
uniform int reflecc;
uniform int rscale;
float round(in float a) { return floor(a + .5); }
@ -25,18 +118,18 @@ void main() {
if(reflecc == 1 && _angle > a / 2.) _angle = a - _angle;
if(_angle < PI) {
float _alpha = (angle + PI) - (_angle + angle);
float inv_angle = (angle + PI) + _alpha;
float dist = length(px);
ps = (position + vec2(cos(inv_angle) * dist, -sin(inv_angle) * dist )) / dimension;
}
float dist = length(px);
if(rscale == 0) dist = dist * scale.y;
else if(rscale == 1) dist = pow(dist, scale.y);
float _alpha = (angle + PI) - (_angle + angle);
float iangle = (angle + PI) + _alpha * scale.x;
ps = (position + vec2(cos(iangle) * dist, -sin(iangle) * dist )) / dimension;
ps = fract(ps);
if(mod(floor(ps.x), 2.) > 1.) ps.x = 1. - ps.x;
if(mod(floor(ps.y), 2.) > 1.) ps.y = 1. - ps.y;
gl_FragColor = texture2D( gm_BaseTexture, ps );
gl_FragColor = sampleTexture( gm_BaseTexture, ps );
}