mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-03-04 06:34:48 +01:00
[CurveBox] Add linear, step mode.
This commit is contained in:
parent
a75e5c120e
commit
1a9e011f52
20 changed files with 1121 additions and 839 deletions
115
datafiles/Shaders/curve.glsl
Normal file
115
datafiles/Shaders/curve.glsl
Normal file
|
@ -0,0 +1,115 @@
|
|||
|
||||
#ifdef _YY_HLSL11_
|
||||
#define CURVE_MAX 512
|
||||
#else
|
||||
#define CURVE_MAX 256
|
||||
#endif
|
||||
|
||||
uniform int curve_offset;
|
||||
|
||||
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
|
||||
float p = prog;
|
||||
float i = 1. - p;
|
||||
|
||||
return _y0 * i*i*i +
|
||||
ay0 * 3. * i*i*p +
|
||||
by1 * 3. * i*p*p +
|
||||
_y1 * p*p*p;
|
||||
}
|
||||
|
||||
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
||||
float _xt = _x;
|
||||
int _binRep = 8;
|
||||
|
||||
if(_x <= 0.) return _y0;
|
||||
if(_x >= 1.) return _y1;
|
||||
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
|
||||
|
||||
for(int i = 0; i < _binRep; i++) {
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.);
|
||||
|
||||
if(abs(_ftx - _x) < _prec)
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
|
||||
if(_xt < _x) st = _xt;
|
||||
else ed = _xt;
|
||||
|
||||
_xt = (st + ed) / 2.;
|
||||
}
|
||||
|
||||
int _newRep = 16;
|
||||
|
||||
for(int i = 0; i < _newRep; i++) {
|
||||
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
|
||||
+ (-12. * ax0 + 6. * bx1) * _xt
|
||||
+ 3. * ax0;
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.)
|
||||
- _x;
|
||||
|
||||
_xt -= _ftx / slope;
|
||||
|
||||
if(abs(_ftx) < _prec)
|
||||
break;
|
||||
}
|
||||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
|
||||
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
|
||||
|
||||
int _segs = (amo - curve_offset) / 6 - 1;
|
||||
float _shift = curve[0];
|
||||
float _scale = curve[1];
|
||||
float _type = curve[2];
|
||||
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0., 1.);
|
||||
|
||||
if(_type == 0.) {
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
float _y0 = curve[ind + 3];
|
||||
float ax0 = _x0 + curve[ind + 4];
|
||||
float ay0 = _y0 + curve[ind + 5];
|
||||
|
||||
float _x1 = curve[ind + 6 + 2];
|
||||
float _y1 = curve[ind + 6 + 3];
|
||||
float bx1 = _x1 + curve[ind + 6 + 0];
|
||||
float by1 = _y1 + curve[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
float t = (_x - _x0) / (_x1 - _x0);
|
||||
if(curve[ind + 4] == 0. && curve[ind + 5] == 0. && curve[ind + 6 + 0] == 0. && curve[ind + 6 + 1] == 0.)
|
||||
return mix(_y0, _y1, t);
|
||||
|
||||
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, t);
|
||||
}
|
||||
|
||||
} else if(_type == 1.) {
|
||||
float y0 = curve[curve_offset + 3];
|
||||
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
|
||||
if(_x < _x0) return y0;
|
||||
y0 = curve[ind + 3];
|
||||
}
|
||||
|
||||
return y0;
|
||||
}
|
||||
|
||||
return curve[amo - 3];
|
||||
}
|
Binary file not shown.
Binary file not shown.
|
@ -6,7 +6,7 @@ function curveBox(_onModify) : widget() constructor {
|
|||
anc_mirror = [];
|
||||
linear_mode = false;
|
||||
|
||||
curve_surface = surface_create(1, 1);
|
||||
curve_surface = noone;
|
||||
node_dragging = -1;
|
||||
node_drag_typ = -1;
|
||||
node_drag_break = false;
|
||||
|
@ -90,12 +90,8 @@ function curveBox(_onModify) : widget() constructor {
|
|||
|
||||
var _h = h - ui(4);
|
||||
|
||||
var _amo = array_length(_data);
|
||||
_shf = _amo % 6;
|
||||
var points = (_amo - _shf) / 6;
|
||||
|
||||
var _shift = 0;
|
||||
var _scale = 1;
|
||||
var _amo = array_length(_data);
|
||||
var points = (_amo - CURVE_PADD) / 6;
|
||||
|
||||
var zoom_size = ui(12);
|
||||
var zoom_padd = zoom_size + ui(8);
|
||||
|
@ -103,14 +99,16 @@ function curveBox(_onModify) : widget() constructor {
|
|||
var tbh = line_get_height(font) + ui(4);
|
||||
|
||||
cw = _w - zoom_padd;
|
||||
ch = _h - zoom_padd - (tbh + ui(4)) * bool(_shf);
|
||||
ch = _h - zoom_padd - (tbh + ui(4));
|
||||
|
||||
hovering = false;
|
||||
curr_data = _data;
|
||||
if(_shf == 1) { _shift = _data[0]; }
|
||||
else if(_shf == 2) { _shift = _data[0]; _scale = _data[1]; }
|
||||
|
||||
linear_mode = curr_data[2 + 0] == 0 && curr_data[2 + 4] == 0;
|
||||
var _shift = _data[0];
|
||||
var _scale = _data[1];
|
||||
var _type = _data[2];
|
||||
|
||||
linear_mode = curr_data[CURVE_PADD + 0] == 0 && curr_data[CURVE_PADD + 4] == 0;
|
||||
|
||||
display_pos_x = lerp(minx, maxx, (_m[0] - _x) / cw);
|
||||
display_pos_y = lerp(miny, maxy, 1 - (_m[1] - _y) / ch);
|
||||
|
@ -130,7 +128,7 @@ function curveBox(_onModify) : widget() constructor {
|
|||
var _my = 1 - (_m[1] - _y) / ch;
|
||||
_my = clamp(_my * (maxy - miny) + miny, 0, 1);
|
||||
|
||||
var node_point = (node_dragging - _shf - 2) / 6;
|
||||
var node_point = (node_dragging - CURVE_PADD - 2) / 6;
|
||||
if(node_point > 0 && node_point < points - 1) {
|
||||
|
||||
if(key_mod_press(CTRL) || grid_snap)
|
||||
|
@ -207,7 +205,7 @@ function curveBox(_onModify) : widget() constructor {
|
|||
|
||||
var node_hovering = -1;
|
||||
var node_hover_typ = -1;
|
||||
var point_insert = 1;
|
||||
var point_insert = 1;
|
||||
var _x1 = 0;
|
||||
|
||||
var msx = _m[0] - _x;
|
||||
|
@ -250,13 +248,11 @@ function curveBox(_onModify) : widget() constructor {
|
|||
draw_line(_px, 0, _px, ch);
|
||||
}
|
||||
|
||||
if(_shf) {
|
||||
draw_set_color(merge_color(COLORS._main_icon, COLORS._main_icon_dark, 0.5));
|
||||
draw_curve(0, 0, cw, ch, _data, minx, maxx, miny, maxy, _shift, _scale);
|
||||
}
|
||||
draw_set_color(merge_color(COLORS._main_icon, COLORS._main_icon_dark, 0.5));
|
||||
draw_curve(0, 0, cw, ch, _data, minx, maxx, miny, maxy, _shift, _scale);
|
||||
|
||||
for( var i = 0; i < points; i++ ) {
|
||||
var ind = _shf + i * 6;
|
||||
var ind = CURVE_PADD + i * 6;
|
||||
var _x0 = _data[ind + 2];
|
||||
var _y0 = _data[ind + 3];
|
||||
|
||||
|
@ -281,36 +277,38 @@ function curveBox(_onModify) : widget() constructor {
|
|||
ay0 = get_y(ay0);
|
||||
|
||||
draw_set_color(COLORS.widget_curve_line);
|
||||
if(i > 0) { //draw pre line
|
||||
draw_line(bx0, by0, _x0, _y0);
|
||||
|
||||
draw_circle_prec(bx0, by0, 3, false);
|
||||
if(hover && point_in_circle(msx, msy, bx0, by0, 10)) {
|
||||
draw_circle_prec(bx0, by0, 5, false);
|
||||
node_hovering = ind + 2;
|
||||
node_hover_typ = -1;
|
||||
|
||||
display_pos_x = _data[ind + 0];
|
||||
display_pos_y = _data[ind + 1];
|
||||
display_sel = 2;
|
||||
if(_type == 0) {
|
||||
if(i > 0) { //draw pre line
|
||||
draw_line(bx0, by0, _x0, _y0);
|
||||
|
||||
draw_circle_prec(bx0, by0, 3, false);
|
||||
if(hover && point_in_circle(msx, msy, bx0, by0, 10)) {
|
||||
draw_circle_prec(bx0, by0, 5, false);
|
||||
node_hovering = ind + 2;
|
||||
node_hover_typ = -1;
|
||||
|
||||
display_pos_x = _data[ind + 0];
|
||||
display_pos_y = _data[ind + 1];
|
||||
display_sel = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(i < points - 1) { //draw post line
|
||||
draw_line(ax0, ay0, _x0, _y0);
|
||||
|
||||
draw_circle_prec(ax0, ay0, 3, false);
|
||||
if(hover && point_in_circle(msx, msy, ax0, ay0, 10)) {
|
||||
draw_circle_prec(ax0, ay0, 5, false);
|
||||
node_hovering = ind + 2;
|
||||
node_hover_typ = 1;
|
||||
|
||||
display_pos_x = _data[ind + 4];
|
||||
display_pos_y = _data[ind + 5];
|
||||
display_sel = 2;
|
||||
if(i < points - 1) { //draw post line
|
||||
draw_line(ax0, ay0, _x0, _y0);
|
||||
|
||||
draw_circle_prec(ax0, ay0, 3, false);
|
||||
if(hover && point_in_circle(msx, msy, ax0, ay0, 10)) {
|
||||
draw_circle_prec(ax0, ay0, 5, false);
|
||||
node_hovering = ind + 2;
|
||||
node_hover_typ = 1;
|
||||
|
||||
display_pos_x = _data[ind + 4];
|
||||
display_pos_y = _data[ind + 5];
|
||||
display_sel = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
draw_set_color(COLORS._main_accent);
|
||||
draw_circle_prec(_x0, _y0, 3, false);
|
||||
if(hover && point_in_circle(msx, msy, _x0, _y0, 10)) {
|
||||
|
@ -386,7 +384,7 @@ function curveBox(_onModify) : widget() constructor {
|
|||
|
||||
var bxW = _w - zoom_padd;
|
||||
var bx = _x;
|
||||
var by = _y + _h - bs - (tbh + ui(4)) * bool(_shf);
|
||||
var by = _y + _h - bs - (tbh + ui(4));
|
||||
|
||||
var zx0 = bx + bs / 2 + (bxW - bs) * (minx - zminx) / (zmaxx - zminx);
|
||||
var zx1 = bx + bs / 2 + (bxW - bs) * (maxx - zminx) / (zmaxx - zminx);
|
||||
|
@ -465,7 +463,7 @@ function curveBox(_onModify) : widget() constructor {
|
|||
////- Height drag
|
||||
|
||||
var _bhx = _x + _w - bs;
|
||||
var _bhy = _y + _h - bs - (tbh + ui(4)) * bool(_shf);
|
||||
var _bhy = _y + _h - bs - (tbh + ui(4));
|
||||
var _hov = false;
|
||||
|
||||
if(point_in_rectangle(_m[0], _m[1], _bhx, _bhy, _bhx + bs, _bhy + bs)) {
|
||||
|
@ -496,7 +494,7 @@ function curveBox(_onModify) : widget() constructor {
|
|||
|
||||
if(mouse_press(mb_left, active)) {
|
||||
if(node_hovering == -1) {
|
||||
var _ind = _shf + point_insert * 6;
|
||||
var _ind = CURVE_PADD + point_insert * 6;
|
||||
var _px = (_m[0] - _x) / cw;
|
||||
var _py = 1 - (_m[1] - _y) / ch;
|
||||
|
||||
|
@ -546,18 +544,39 @@ function curveBox(_onModify) : widget() constructor {
|
|||
]),
|
||||
-1,
|
||||
|
||||
menuItem(__txt("Linear Curve"), function() /*=>*/ {
|
||||
var _lin = linear_mode;
|
||||
|
||||
for( var i = 2, n = array_length(curr_data); i < n; i += 6 ) {
|
||||
curr_data[@ i + 0] = _lin? -1/3 : 0;
|
||||
curr_data[@ i + 1] = _lin? 0 : 0;
|
||||
curr_data[@ i + 4] = _lin? 1/3 : 0;
|
||||
curr_data[@ i + 5] = _lin? 0 : 0;
|
||||
}
|
||||
|
||||
onModify(curr_data);
|
||||
}, noone, noone, function() /*=>*/ {return linear_mode}),
|
||||
menuItemGroup(__txt("Modes"), [
|
||||
[ [THEME.curve_type, 0], function() /*=>*/ {
|
||||
var _dat = variable_clone(curr_data);
|
||||
|
||||
_dat[2] = 0;
|
||||
for( var i = CURVE_PADD, n = array_length(_dat); i < n; i += 6 ) {
|
||||
_dat[i + 0] = -1/3;
|
||||
_dat[i + 1] = 0;
|
||||
_dat[i + 4] = 1/3;
|
||||
_dat[i + 5] = 0;
|
||||
}
|
||||
onModify(_dat);
|
||||
} ],
|
||||
[ [THEME.curve_type, 1], function() /*=>*/ {
|
||||
var _dat = variable_clone(curr_data);
|
||||
|
||||
_dat[2] = 0;
|
||||
for( var i = CURVE_PADD, n = array_length(_dat); i < n; i += 6 ) {
|
||||
_dat[i + 0] = 0;
|
||||
_dat[i + 1] = 0;
|
||||
_dat[i + 4] = 0;
|
||||
_dat[i + 5] = 0;
|
||||
}
|
||||
onModify(_dat);
|
||||
} ],
|
||||
[ [THEME.curve_type, 2], function() /*=>*/ {
|
||||
var _dat = variable_clone(curr_data);
|
||||
|
||||
_dat[2] = 1;
|
||||
onModify(_dat);
|
||||
} ],
|
||||
]),
|
||||
-1,
|
||||
|
||||
menuItem(__txt("Reset View"), function() /*=>*/ { minx = 0; maxx = 1; miny = 0; maxy = 1; } ),
|
||||
menuItem(__txt("Grid"), function() /*=>*/ { grid_show = !grid_show; }, noone, noone, function() /*=>*/ {return grid_show} ),
|
||||
|
@ -576,15 +595,16 @@ function curveBox(_onModify) : widget() constructor {
|
|||
select_type = node_hover_typ;
|
||||
select_data = _data;
|
||||
|
||||
var _pnt = (selecting - _shf - 2) / 6;
|
||||
var _pnt = (selecting - CURVE_PADD - 2) / 6;
|
||||
var _menu = [];
|
||||
|
||||
array_push(_menu, menuItem(__txt("Reset Controls"), function() /*=>*/ {
|
||||
array_push(_menu, menuItem(__txt("Toggle Controls"), function() /*=>*/ {
|
||||
var _ind = selecting - 2;
|
||||
var _lin = select_data[_ind + 0] == 0 && select_data[_ind + 4] == 0;
|
||||
|
||||
select_data[@ _ind + 0] = -1/3;
|
||||
select_data[@ _ind + 0] = _lin? -1/3 : 0;
|
||||
select_data[@ _ind + 1] = 0;
|
||||
select_data[@ _ind + 4] = 1/3;
|
||||
select_data[@ _ind + 4] = _lin? 1/3 : 0;
|
||||
select_data[@ _ind + 5] = 0;
|
||||
onModify(select_data);
|
||||
}));
|
||||
|
@ -615,22 +635,20 @@ function curveBox(_onModify) : widget() constructor {
|
|||
show_coord = false;
|
||||
}
|
||||
|
||||
if(_shf) {
|
||||
var tby = _y + h - tbh;
|
||||
var tbw = _w / 2;
|
||||
var tby = _y + h - tbh;
|
||||
var tbw = _w / 2;
|
||||
|
||||
tb_shift.setFocusHover(active, hover);
|
||||
tb_scale.setFocusHover(active, hover);
|
||||
|
||||
tb_shift.hide = true;
|
||||
tb_scale.hide = true;
|
||||
|
||||
tb_shift.setFocusHover(active, hover);
|
||||
tb_scale.setFocusHover(active, hover);
|
||||
|
||||
tb_shift.hide = true;
|
||||
tb_scale.hide = true;
|
||||
|
||||
draw_sprite_stretched_ext(THEME.textbox, 3, _x, tby, _w, tbh, c_white, 1);
|
||||
draw_sprite_stretched_ext(THEME.textbox, 0, _x, tby, _w, tbh, c_white, 0.5 + 0.5 * interactable);
|
||||
|
||||
tb_shift.draw(_x, tby, tbw, tbh, _data[0], _m);
|
||||
tb_scale.draw(_x + tbw, tby, tbw, tbh, _data[1], _m);
|
||||
}
|
||||
draw_sprite_stretched_ext(THEME.textbox, 3, _x, tby, _w, tbh, c_white, 1);
|
||||
draw_sprite_stretched_ext(THEME.textbox, 0, _x, tby, _w, tbh, c_white, 0.5 + 0.5 * interactable);
|
||||
|
||||
tb_shift.draw(_x, tby, tbw, tbh, _data[0], _m);
|
||||
tb_scale.draw(_x + tbw, tby, tbw, tbh, _data[1], _m);
|
||||
|
||||
resetFocus();
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
//curve format [-cx0, -cy0, x0, y0, +cx0, +cy0, -cx1, -cy1, x1, y1, +cx1, +cy1]
|
||||
//segment format [y0, +cx0, +cy0, -cx1, -cy1, y1]
|
||||
|
||||
#macro CURVE_DEF_00 [0, 1, /**/ 0, 0, 0, 0, 1/3, 0, /**/ -1/3, 0, 1, 0, 0, 0]
|
||||
#macro CURVE_DEF_01 [0, 1, /**/ 0, 0, 0, 0, 1/3, 1/3, /**/ -1/3, -1/3, 1, 1, 0, 0]
|
||||
#macro CURVE_DEF_10 [0, 1, /**/ 0, 0, 0, 1, 1/3, -1/3, /**/ -1/3, 1/3, 1, 0, 0, 0]
|
||||
#macro CURVE_DEF_11 [0, 1, /**/ 0, 0, 0, 1, 1/3, 0, /**/ -1/3, 0, 1, 1, 0, 0]
|
||||
#macro CURVE_DEF_00 [0, 1, 0, 0, 0, 0, /**/ 0, 0, 0, 0, 1/3, 0, /**/ -1/3, 0, 1, 0, 0, 0]
|
||||
#macro CURVE_DEF_01 [0, 1, 0, 0, 0, 0, /**/ 0, 0, 0, 0, 1/3, 1/3, /**/ -1/3, -1/3, 1, 1, 0, 0]
|
||||
#macro CURVE_DEF_10 [0, 1, 0, 0, 0, 0, /**/ 0, 0, 0, 1, 1/3, -1/3, /**/ -1/3, 1/3, 1, 0, 0, 0]
|
||||
#macro CURVE_DEF_11 [0, 1, 0, 0, 0, 0, /**/ 0, 0, 0, 1, 1/3, 0, /**/ -1/3, 0, 1, 1, 0, 0]
|
||||
#macro CURVE_PADD 6
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////// DRAW ////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -30,89 +31,129 @@ function eval_curve_segment_t_position(_t, bbz) {
|
|||
}
|
||||
|
||||
function draw_curve(x0, y0, _w, _h, _bz, minx = 0, maxx = 1, miny = 0, maxy = 1, _shift = 0, _scale = 1) {
|
||||
var _amo = array_length(_bz);
|
||||
var _shf = _amo % 6;
|
||||
var _amo = array_length(_bz);
|
||||
var _type = _bz[2];
|
||||
|
||||
var segments = (_amo - _shf) / 6 - 1;
|
||||
var _ox, _oy;
|
||||
var segments = (_amo - CURVE_PADD) / 6;
|
||||
if(_type == 0) segments--;
|
||||
|
||||
var _ox, _oy, _nx, _ny;
|
||||
var _rx, _ry;
|
||||
|
||||
var rngx = maxx - minx;
|
||||
var rngy = maxy - miny;
|
||||
|
||||
for( var i = 0; i < segments; i++ ) {
|
||||
var ind = _shf + i * 6;
|
||||
var ind = CURVE_PADD + i * 6;
|
||||
|
||||
var _x0 = _bz[ind + 2];
|
||||
var _y0 = _bz[ind + 3];
|
||||
var _x1 = _bz[ind + 6 + 2];
|
||||
var _y1 = _bz[ind + 6 + 3];
|
||||
|
||||
var _xr = _x1 - _x0;
|
||||
var _yr = _y1 - _y0;
|
||||
|
||||
var smp = max(abs(_yr) * _h / 2, ceil(_xr / rngx * 32));
|
||||
|
||||
if(i == 0) {
|
||||
var _rx = _x0 * _scale + _shift;
|
||||
var _ry = _y0;
|
||||
_rx = _x0 * _scale + _shift;
|
||||
_ry = _y0;
|
||||
|
||||
_rx = ( _rx - minx ) / rngx;
|
||||
_ry = ( _ry - miny ) / rngy;
|
||||
|
||||
var _nx = x0 + _w * _rx;
|
||||
var _ny = y0 + _h * (1 - _ry);
|
||||
_nx = x0 + _w * _rx;
|
||||
_ny = y0 + _h * (1 - _ry);
|
||||
|
||||
draw_line(x0, _ny, _nx, _ny);
|
||||
}
|
||||
|
||||
if(i == segments - 1) {
|
||||
var _rx = _x1 * _scale + _shift;
|
||||
var _ry = _y1;
|
||||
|
||||
_rx = ( _rx - minx ) / rngx;
|
||||
_ry = ( _ry - miny ) / rngy;
|
||||
|
||||
var _nx = x0 + _w * _rx;
|
||||
var _ny = y0 + _h * (1 - _ry);
|
||||
|
||||
draw_line(x0 + _w, _ny, _nx, _ny);
|
||||
}
|
||||
switch(_type) {
|
||||
case 0 :
|
||||
var _x1 = _bz[ind + 6 + 2];
|
||||
var _y1 = _bz[ind + 6 + 3];
|
||||
|
||||
if(i == segments - 1) {
|
||||
_rx = _x1 * _scale + _shift;
|
||||
_ry = _y1;
|
||||
|
||||
_rx = ( _rx - minx ) / rngx;
|
||||
_ry = ( _ry - miny ) / rngy;
|
||||
|
||||
_nx = x0 + _w * _rx;
|
||||
_ny = y0 + _h * (1 - _ry);
|
||||
|
||||
draw_line(x0 + _w, _ny, _nx, _ny);
|
||||
}
|
||||
|
||||
if(_bz[ind + 4] == 0 && _bz[ind + 5] == 0 && _bz[ind + 6 + 0] == 0 && _bz[ind + 6 + 1] == 0) {
|
||||
draw_line(x0 + _x0 * _w, y0 + (1 - _y0) * _h,
|
||||
x0 + _x1 * _w, y0 + (1 - _y1) * _h);
|
||||
continue;
|
||||
}
|
||||
if(_bz[ind + 4] == 0 && _bz[ind + 5] == 0 && _bz[ind + 6 + 0] == 0 && _bz[ind + 6 + 1] == 0) {
|
||||
draw_line(x0 + _x0 * _w, y0 + (1 - _y0) * _h,
|
||||
x0 + _x1 * _w, y0 + (1 - _y1) * _h);
|
||||
continue;
|
||||
}
|
||||
|
||||
var _xr = _x1 - _x0;
|
||||
var _yr = _y1 - _y0;
|
||||
|
||||
var smp = max(abs(_yr) * _h / 2, ceil(_xr / rngx * 32));
|
||||
|
||||
var ax0 = _x0 + _bz[ind + 4];
|
||||
var ay0 = _y0 + _bz[ind + 5];
|
||||
|
||||
var bx1 = _x1 + _bz[ind + 6 + 0];
|
||||
var by1 = _y1 + _bz[ind + 6 + 1];
|
||||
|
||||
var bbz = [ _y0, ax0, ay0, bx1, by1, _y1 ];
|
||||
|
||||
for(var j = 0; j <= smp; j++) {
|
||||
var _t = j / smp;
|
||||
var _r = eval_curve_segment_t_position(_t, bbz);
|
||||
|
||||
var _rx = _r[0] * _xr + _x0;
|
||||
var _ry = _r[1];
|
||||
|
||||
_rx = _rx * _scale + _shift;
|
||||
|
||||
_rx = ( _rx - minx ) / rngx;
|
||||
_ry = ( _ry - miny ) / rngy;
|
||||
|
||||
var _nx = x0 + _w * _rx;
|
||||
var _ny = y0 + _h * (1 - _ry);
|
||||
|
||||
if(j) draw_line(_ox, _oy, _nx, _ny);
|
||||
|
||||
_ox = _nx;
|
||||
_oy = _ny;
|
||||
|
||||
if(_nx > x0 + _w) return;
|
||||
var ax0 = _x0 + _bz[ind + 4];
|
||||
var ay0 = _y0 + _bz[ind + 5];
|
||||
|
||||
var bx1 = _x1 + _bz[ind + 6 + 0];
|
||||
var by1 = _y1 + _bz[ind + 6 + 1];
|
||||
|
||||
var bbz = [ _y0, ax0, ay0, bx1, by1, _y1 ];
|
||||
|
||||
for(var j = 0; j <= smp; j++) {
|
||||
var _t = j / smp;
|
||||
var _r = eval_curve_segment_t_position(_t, bbz);
|
||||
|
||||
_rx = _r[0] * _xr + _x0;
|
||||
_ry = _r[1];
|
||||
|
||||
_rx = _rx * _scale + _shift;
|
||||
|
||||
_rx = ( _rx - minx ) / rngx;
|
||||
_ry = ( _ry - miny ) / rngy;
|
||||
|
||||
_nx = x0 + _w * _rx;
|
||||
_ny = y0 + _h * (1 - _ry);
|
||||
|
||||
if(j) draw_line(_ox, _oy, _nx, _ny);
|
||||
|
||||
_ox = _nx;
|
||||
_oy = _ny;
|
||||
|
||||
if(_nx > x0 + _w) return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
if(i == segments - 1) {
|
||||
_rx = _x0 * _scale + _shift;
|
||||
_ry = _y0;
|
||||
|
||||
_rx = ( _rx - minx ) / rngx;
|
||||
_ry = ( _ry - miny ) / rngy;
|
||||
|
||||
_nx = x0 + _w * _rx;
|
||||
_ny = y0 + _h * (1 - _ry);
|
||||
|
||||
draw_line(x0 + _w, _ny, _nx, _ny);
|
||||
}
|
||||
|
||||
_rx = _x0 * _scale + _shift;
|
||||
_ry = _y0;
|
||||
|
||||
_rx = ( _rx - minx ) / rngx;
|
||||
_ry = ( _ry - miny ) / rngy;
|
||||
|
||||
_nx = x0 + _w * _rx;
|
||||
_ny = y0 + _h * (1 - _ry);
|
||||
|
||||
if(i) {
|
||||
draw_line(_ox, _oy, _nx, _oy);
|
||||
draw_line(_nx, _oy, _nx, _ny);
|
||||
}
|
||||
|
||||
_ox = _nx;
|
||||
_oy = _ny;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,48 +171,59 @@ function eval_curve_segment_t(_bz, t) {
|
|||
}
|
||||
|
||||
function eval_curve_x(_bz, _x, _tolr = 0.00001) {
|
||||
static _CURVE_DEF_01 = [0, 1, /**/ 0, 0, 0, 0, 1/3, 1/3, /**/ -1/3, -1/3, 1, 1, 0, 0];
|
||||
static _CURVE_DEF_10 = [0, 1, /**/ 0, 0, 0, 1, 1/3, -1/3, /**/ -1/3, 1/3, 1, 0, 0, 0];
|
||||
static _CURVE_DEF_11 = [0, 1, /**/ 0, 0, 0, 1, 1/3, 0, /**/ -1/3, 0, 1, 1, 0, 0];
|
||||
static _CURVE_DEF_01 = [0, 1, 0, 0, 0, 0, /**/ 0, 0, 0, 0, 1/3, 1/3, /**/ -1/3, -1/3, 1, 1, 0, 0];
|
||||
static _CURVE_DEF_10 = [0, 1, 0, 0, 0, 0, /**/ 0, 0, 0, 1, 1/3, -1/3, /**/ -1/3, 1/3, 1, 0, 0, 0];
|
||||
static _CURVE_DEF_11 = [0, 1, 0, 0, 0, 0, /**/ 0, 0, 0, 1, 1/3, 0, /**/ -1/3, 0, 1, 1, 0, 0];
|
||||
|
||||
if(array_equals(_bz, _CURVE_DEF_11)) return 1;
|
||||
if(array_equals(_bz, _CURVE_DEF_01)) return _x;
|
||||
if(array_equals(_bz, _CURVE_DEF_10)) return 1 - _x;
|
||||
|
||||
var _amo = array_length(_bz);
|
||||
var _shf = _amo % 6;
|
||||
var _shift = 0;
|
||||
var _scale = 1;
|
||||
|
||||
if(_shf) {
|
||||
var _shift = _bz[0];
|
||||
var _scale = _bz[1];
|
||||
}
|
||||
var _shift = _bz[0];
|
||||
var _scale = _bz[1];
|
||||
var _type = _bz[2];
|
||||
|
||||
var segments = (_amo - CURVE_PADD) / 6 - 1;
|
||||
|
||||
var segments = (_amo - _shf) / 6 - 1;
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0, 1);
|
||||
|
||||
for( var i = 0; i < segments; i++ ) {
|
||||
var ind = _shf + i * 6;
|
||||
var _x0 = _bz[ind + 2];
|
||||
var _y0 = _bz[ind + 3];
|
||||
//var bx0 = _x0 + _bz[ind + 0];
|
||||
//var by0 = _y0 + _bz[ind + 1];
|
||||
var ax0 = _x0 + _bz[ind + 4];
|
||||
var ay0 = _y0 + _bz[ind + 5];
|
||||
|
||||
var _x1 = _bz[ind + 6 + 2];
|
||||
var _y1 = _bz[ind + 6 + 3];
|
||||
var bx1 = _x1 + _bz[ind + 6 + 0];
|
||||
var by1 = _y1 + _bz[ind + 6 + 1];
|
||||
//var ax1 = _x1 + _bz[ind + 6 + 4];
|
||||
//var ay1 = _y1 + _bz[ind + 6 + 5];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
return eval_curve_segment_x([_y0, ax0, ay0, bx1, by1, _y1], (_x - _x0) / (_x1 - _x0), _tolr);
|
||||
switch(_type) {
|
||||
case 0 :
|
||||
for( var i = 0; i < segments; i++ ) {
|
||||
var ind = CURVE_PADD + i * 6;
|
||||
var _x0 = _bz[ind + 2];
|
||||
var _y0 = _bz[ind + 3];
|
||||
var ax0 = _x0 + _bz[ind + 4];
|
||||
var ay0 = _y0 + _bz[ind + 5];
|
||||
|
||||
var _x1 = _bz[ind + 6 + 2];
|
||||
var _y1 = _bz[ind + 6 + 3];
|
||||
var bx1 = _x1 + _bz[ind + 6 + 0];
|
||||
var by1 = _y1 + _bz[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
return eval_curve_segment_x([_y0, ax0, ay0, bx1, by1, _y1], (_x - _x0) / (_x1 - _x0), _tolr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
var _y0 = _bz[CURVE_PADD + 3];
|
||||
|
||||
for( var i = 0; i < segments; i++ ) {
|
||||
var ind = CURVE_PADD + i * 6;
|
||||
var _x0 = _bz[ind + 2];
|
||||
|
||||
if(_x <= _x0) return _y0;
|
||||
_y0 = _bz[ind + 3];
|
||||
}
|
||||
|
||||
return _y0;
|
||||
break;
|
||||
}
|
||||
|
||||
return array_safe_get_fast(_bz, array_length(_bz) - 3);
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
LATEST_VERSION = 1_18_00_0;
|
||||
VERSION = 1_18_08_0;
|
||||
SAVE_VERSION = 1_18_09_0;
|
||||
SAVE_VERSION = 1_18_09_1;
|
||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.9.011";
|
||||
BUILD_NUMBER = 118080.011;
|
||||
PREF_VERSION = 1_17_1;
|
||||
|
|
|
@ -102,8 +102,7 @@ function Node_Blur_Path(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
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));
|
||||
shader_set_curve("i", _curv);
|
||||
|
||||
draw_surface_safe(_surf);
|
||||
surface_reset_shader();
|
||||
|
|
|
@ -46,20 +46,11 @@ function Node_Curve(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
|
|||
var _acur = _data[11];
|
||||
|
||||
surface_set_shader(_outSurf, sh_curve);
|
||||
shader_set_f("w_curve", _wcur);
|
||||
shader_set_i("w_amount", array_length(_wcur));
|
||||
|
||||
shader_set_f("r_curve", _rcur);
|
||||
shader_set_i("r_amount", array_length(_rcur));
|
||||
|
||||
shader_set_f("g_curve", _gcur);
|
||||
shader_set_i("g_amount", array_length(_gcur));
|
||||
|
||||
shader_set_f("b_curve", _bcur);
|
||||
shader_set_i("b_amount", array_length(_bcur));
|
||||
|
||||
shader_set_f("a_curve", _acur);
|
||||
shader_set_i("a_amount", array_length(_acur));
|
||||
shader_set_curve("w", _wcur);
|
||||
shader_set_curve("r", _rcur);
|
||||
shader_set_curve("g", _gcur);
|
||||
shader_set_curve("b", _bcur);
|
||||
shader_set_curve("a", _acur);
|
||||
|
||||
draw_surface_safe(_data[0]);
|
||||
surface_reset_shader();
|
||||
|
|
|
@ -40,15 +40,9 @@ function Node_Curve_HSV(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
var _vcur = _data[3];
|
||||
|
||||
surface_set_shader(_outSurf, sh_curve_hsv);
|
||||
|
||||
shader_set_f("h_curve", _hcur);
|
||||
shader_set_i("h_amount", array_length(_hcur));
|
||||
|
||||
shader_set_f("s_curve", _scur);
|
||||
shader_set_i("s_amount", array_length(_scur));
|
||||
|
||||
shader_set_f("v_curve", _vcur);
|
||||
shader_set_i("v_amount", array_length(_vcur));
|
||||
shader_set_curve("h_curve", _hcur);
|
||||
shader_set_curve("s_curve", _scur);
|
||||
shader_set_curve("v_curve", _vcur);
|
||||
|
||||
draw_surface_safe(_data[0]);
|
||||
surface_reset_shader();
|
||||
|
|
|
@ -683,20 +683,17 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
|
|||
_val = json_try_parse(value);
|
||||
|
||||
} else if(prop.display_type == VALUE_DISPLAY.matrix) {
|
||||
var mat = new Matrix();
|
||||
_val = mat.deserialize(value);
|
||||
_val = new Matrix().deserialize(value);
|
||||
|
||||
} else if(_typ == VALUE_TYPE.path && prop.display_type == VALUE_DISPLAY.path_array) {
|
||||
for(var j = 0; j < array_length(value); j++)
|
||||
_val[j] = value[j];
|
||||
|
||||
} else if(_typ == VALUE_TYPE.gradient) {
|
||||
var grad = new gradientObject();
|
||||
_val = grad.deserialize(value);
|
||||
_val = new gradientObject().deserialize(value);
|
||||
|
||||
} else if(_typ == VALUE_TYPE.d3Material) {
|
||||
var mat = new __d3dMaterial();
|
||||
_val = mat.deserialize(value);
|
||||
_val = new __d3dMaterial().deserialize(value);
|
||||
|
||||
} else if(_typ == VALUE_TYPE.color) {
|
||||
if(is_array(_val)) {
|
||||
|
@ -721,9 +718,13 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
|
|||
_val[j] = processValue(value);
|
||||
}
|
||||
|
||||
if(prop.type == VALUE_TYPE.curve && array_length(value) % 6 == 0) {
|
||||
array_insert(_val, 0, 0);
|
||||
array_insert(_val, 1, 1);
|
||||
if(prop.type == VALUE_TYPE.curve && LOADING_VERSION < 1_18_09_1) {
|
||||
if(array_length(value) % 6 == 0)
|
||||
array_insert(_val, 0, /**/ 0, 1, 0, 0, 0, 0);
|
||||
else {
|
||||
var _insert = CURVE_PADD - array_length(value) % 6;
|
||||
repeat(_insert) array_insert(_val, 2, /**/ 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,8 +121,7 @@ function Node_Path_Morph(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
|||
shader_set_f("point1", _p1);
|
||||
shader_set_f("point2", _p2);
|
||||
|
||||
shader_set_f("w_curve", _cur);
|
||||
shader_set_i("w_amount", array_length(_cur));
|
||||
shader_set_curve("w", _cur);
|
||||
|
||||
draw_empty();
|
||||
surface_reset_shader();
|
||||
|
|
|
@ -57,8 +57,7 @@ function Node_Pixel_Cloud(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
|||
|
||||
shader_set_gradient(_data[4], _data[9], _data[10], inputs[4]);
|
||||
|
||||
shader_set_f("alpha_curve" , _data[6]);
|
||||
shader_set_i("curve_amount", array_length(_data[6]));
|
||||
shader_set_curve("alpha" , _data[6]);
|
||||
shader_set_f("randomAmount", _data[7]);
|
||||
|
||||
draw_surface_safe(_data[0]);
|
||||
|
|
|
@ -571,8 +571,7 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
|
|||
shader_set_2("dfLevel", _level);
|
||||
shader_set_i("tile", _tile);
|
||||
shader_set_f("corner", _corner);
|
||||
shader_set_f("w_curve", _curve);
|
||||
shader_set_i("w_amount", array_length(_curve));
|
||||
shader_set_curve("w", _curve);
|
||||
shader_set_i("cornerShape", _data[36]);
|
||||
|
||||
shader_set_2("center", _center);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
function shader_set_i(uniform, value) {
|
||||
INLINE
|
||||
|
||||
var shader = shader_current();
|
||||
if(shader == -1) return;
|
||||
|
@ -21,15 +20,11 @@ function shader_set_i(uniform, value) {
|
|||
}
|
||||
}
|
||||
|
||||
function shader_set_i_array(shader, uniform, array) {
|
||||
INLINE
|
||||
|
||||
shader_set_uniform_i_array(shader_get_uniform(shader, uniform), array);
|
||||
}
|
||||
function shader_set_i_array(shader, uniform, array) { shader_set_uniform_i_array(shader_get_uniform(shader, uniform), array); }
|
||||
|
||||
function shader_set_2(uniform, v) { INLINE var shader = shader_current(); shader_set_uniform_f(shader_get_uniform(shader, uniform), aGetF(v, 0), aGetF(v, 1)); }
|
||||
function shader_set_3(uniform, v) { INLINE var shader = shader_current(); shader_set_uniform_f(shader_get_uniform(shader, uniform), aGetF(v, 0), aGetF(v, 1), aGetF(v, 2)); }
|
||||
function shader_set_4(uniform, v) { INLINE var shader = shader_current(); shader_set_uniform_f(shader_get_uniform(shader, uniform), aGetF(v, 0), aGetF(v, 1), aGetF(v, 2), aGetF(v, 3)); }
|
||||
function shader_set_2(uniform, v) { var shader = shader_current(); shader_set_uniform_f(shader_get_uniform(shader, uniform), aGetF(v, 0), aGetF(v, 1)); }
|
||||
function shader_set_3(uniform, v) { var shader = shader_current(); shader_set_uniform_f(shader_get_uniform(shader, uniform), aGetF(v, 0), aGetF(v, 1), aGetF(v, 2)); }
|
||||
function shader_set_4(uniform, v) { var shader = shader_current(); shader_set_uniform_f(shader_get_uniform(shader, uniform), aGetF(v, 0), aGetF(v, 1), aGetF(v, 2), aGetF(v, 3)); }
|
||||
|
||||
function shader_set_f_array(uniform, value, max_length = 128) {
|
||||
var shader = shader_current();
|
||||
|
@ -40,7 +35,6 @@ function shader_set_f_array(uniform, value, max_length = 128) {
|
|||
}
|
||||
|
||||
function shader_set_f(uniform, value) {
|
||||
INLINE
|
||||
|
||||
var shader = shader_current();
|
||||
if(shader == -1) return;
|
||||
|
@ -63,12 +57,9 @@ function shader_set_f(uniform, value) {
|
|||
shader_set_uniform_f_array(shader_get_uniform(shader, uniform), array)
|
||||
}
|
||||
|
||||
if(argument_count == 2)
|
||||
shader_set_uniform_f(shader_get_uniform(shader, uniform), value);
|
||||
else if(argument_count == 3)
|
||||
shader_set_uniform_f(shader_get_uniform(shader, uniform), value, argument[2]);
|
||||
else if(argument_count == 4)
|
||||
shader_set_uniform_f(shader_get_uniform(shader, uniform), value, argument[2], argument[3]);
|
||||
if(argument_count == 2) shader_set_uniform_f(shader_get_uniform(shader, uniform), value);
|
||||
else if(argument_count == 3) shader_set_uniform_f(shader_get_uniform(shader, uniform), value, argument[2]);
|
||||
else if(argument_count == 4) shader_set_uniform_f(shader_get_uniform(shader, uniform), value, argument[2], argument[3]);
|
||||
else {
|
||||
var array = array_create(argument_count - 1);
|
||||
for( var i = 1; i < argument_count; i++ )
|
||||
|
@ -78,7 +69,6 @@ function shader_set_f(uniform, value) {
|
|||
}
|
||||
|
||||
function shader_set_f_map(uniform, value, surface = noone, junc = noone) {
|
||||
INLINE
|
||||
|
||||
shader_set_f(uniform, is_array(value)? value : [ value, value ]);
|
||||
|
||||
|
@ -91,14 +81,12 @@ function shader_set_f_map(uniform, value, surface = noone, junc = noone) {
|
|||
}
|
||||
|
||||
function shader_set_f_map_s(uniform, value, surface, junc) {
|
||||
INLINE
|
||||
|
||||
shader_set_f(uniform, is_array(value)? value : [ value, value ]);
|
||||
shader_set_i(uniform + "UseSurf", junc.attributes.mapped && is_surface(surface));
|
||||
}
|
||||
|
||||
function shader_set_uniform_f_array_safe(uniform, array, max_length = 4096) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(array)) return;
|
||||
|
||||
|
@ -110,7 +98,6 @@ function shader_set_uniform_f_array_safe(uniform, array, max_length = 4096) {
|
|||
}
|
||||
|
||||
function shader_set_surface(sampler, surface, linear = false, _repeat = false) {
|
||||
INLINE
|
||||
|
||||
var shader = shader_current();
|
||||
if(shader == -1) return noone;
|
||||
|
@ -129,7 +116,6 @@ function shader_set_surface(sampler, surface, linear = false, _repeat = false) {
|
|||
}
|
||||
|
||||
function shader_set_surface_dimension(uniform, surface) {
|
||||
INLINE
|
||||
|
||||
var shader = shader_current();
|
||||
if(!is_surface(surface)) return;
|
||||
|
@ -146,20 +132,21 @@ function shader_set_surface_dimension(uniform, surface) {
|
|||
}
|
||||
|
||||
function shader_set_dim(uniform = "dimension", surf = noone) {
|
||||
INLINE
|
||||
|
||||
if(!is_surface(surf)) return;
|
||||
shader_set_f(uniform, surface_get_width_safe(surf), surface_get_height_safe(surf));
|
||||
}
|
||||
|
||||
function shader_set_color(uniform, col, alpha = 1) {
|
||||
INLINE
|
||||
function shader_set_color(uniform, col, alpha = 1) { shader_set_f(uniform, colToVec4(col, alpha)); }
|
||||
|
||||
function shader_set_curve(uniform, curve) {
|
||||
shader_set_i($"curve_offset", CURVE_PADD);
|
||||
shader_set_f($"{uniform}_curve", curve);
|
||||
shader_set_i($"{uniform}_amount", array_length(curve));
|
||||
|
||||
shader_set_f(uniform, colToVec4(col, alpha));
|
||||
}
|
||||
|
||||
function shader_set_palette(pal, pal_uni = "palette", amo_uni = "paletteAmount", max_length = 1024) {
|
||||
INLINE
|
||||
|
||||
if(MAC) max_length = min(max_length, 256);
|
||||
var _amo = min(max_length, array_length(pal));
|
||||
|
@ -184,26 +171,22 @@ function shader_set_palette(pal, pal_uni = "palette", amo_uni = "paletteAmount",
|
|||
}
|
||||
|
||||
function shader_preset_interpolation(shader = sh_sample) {
|
||||
INLINE
|
||||
|
||||
shader_set_uniform_i(shader_get_uniform(shader, "interpolation"), getAttribute("interpolate"));
|
||||
shader_set_uniform_i(shader_get_uniform(shader, "sampleMode"), getAttribute("oversample"));
|
||||
}
|
||||
|
||||
function shader_postset_interpolation() {
|
||||
INLINE
|
||||
|
||||
gpu_set_tex_filter(false);
|
||||
}
|
||||
|
||||
function shader_set_interpolation_surface(surface) {
|
||||
INLINE
|
||||
|
||||
shader_set_f("sampleDimension", surface_get_width_safe(surface), surface_get_height_safe(surface));
|
||||
}
|
||||
|
||||
function shader_set_interpolation(surface, _dim = noone) {
|
||||
INLINE
|
||||
|
||||
var intp = getAttribute("interpolate");
|
||||
|
||||
|
|
|
@ -1,11 +1,123 @@
|
|||
#pragma use(curve)
|
||||
|
||||
#ifdef _YY_HLSL11_
|
||||
#define CURVE_MAX 1024
|
||||
#define MAX_POINTS 256
|
||||
#else
|
||||
#define CURVE_MAX 256
|
||||
#define MAX_POINTS 128
|
||||
#endif
|
||||
#region -- curve -- [1740201118.8128765]
|
||||
|
||||
#ifdef _YY_HLSL11_
|
||||
#define CURVE_MAX 512
|
||||
#else
|
||||
#define CURVE_MAX 256
|
||||
#endif
|
||||
|
||||
uniform int curve_offset;
|
||||
|
||||
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
|
||||
float p = prog;
|
||||
float i = 1. - p;
|
||||
|
||||
return _y0 * i*i*i +
|
||||
ay0 * 3. * i*i*p +
|
||||
by1 * 3. * i*p*p +
|
||||
_y1 * p*p*p;
|
||||
}
|
||||
|
||||
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
||||
float _xt = _x;
|
||||
int _binRep = 8;
|
||||
|
||||
if(_x <= 0.) return _y0;
|
||||
if(_x >= 1.) return _y1;
|
||||
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
|
||||
|
||||
for(int i = 0; i < _binRep; i++) {
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.);
|
||||
|
||||
if(abs(_ftx - _x) < _prec)
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
|
||||
if(_xt < _x) st = _xt;
|
||||
else ed = _xt;
|
||||
|
||||
_xt = (st + ed) / 2.;
|
||||
}
|
||||
|
||||
int _newRep = 16;
|
||||
|
||||
for(int i = 0; i < _newRep; i++) {
|
||||
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
|
||||
+ (-12. * ax0 + 6. * bx1) * _xt
|
||||
+ 3. * ax0;
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.)
|
||||
- _x;
|
||||
|
||||
_xt -= _ftx / slope;
|
||||
|
||||
if(abs(_ftx) < _prec)
|
||||
break;
|
||||
}
|
||||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
|
||||
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
|
||||
|
||||
int _segs = (amo - curve_offset) / 6 - 1;
|
||||
float _shift = curve[0];
|
||||
float _scale = curve[1];
|
||||
float _type = curve[2];
|
||||
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0., 1.);
|
||||
|
||||
if(_type == 0.) {
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
float _y0 = curve[ind + 3];
|
||||
float ax0 = _x0 + curve[ind + 4];
|
||||
float ay0 = _y0 + curve[ind + 5];
|
||||
|
||||
float _x1 = curve[ind + 6 + 2];
|
||||
float _y1 = curve[ind + 6 + 3];
|
||||
float bx1 = _x1 + curve[ind + 6 + 0];
|
||||
float by1 = _y1 + curve[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
float t = (_x - _x0) / (_x1 - _x0);
|
||||
if(curve[ind + 4] == 0. && curve[ind + 5] == 0. && curve[ind + 6 + 0] == 0. && curve[ind + 6 + 1] == 0.)
|
||||
return mix(_y0, _y1, t);
|
||||
|
||||
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, t);
|
||||
}
|
||||
|
||||
} else if(_type == 1.) {
|
||||
float y0 = curve[curve_offset + 3];
|
||||
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
|
||||
if(_x < _x0) return y0;
|
||||
y0 = curve[ind + 3];
|
||||
}
|
||||
|
||||
return y0;
|
||||
}
|
||||
|
||||
return curve[amo - 3];
|
||||
}
|
||||
|
||||
#endregion -- curve --
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
@ -15,8 +127,8 @@ uniform int sampleMode;
|
|||
|
||||
uniform int resolution;
|
||||
uniform int pointAmount;
|
||||
uniform float points_x[MAX_POINTS];
|
||||
uniform float points_y[MAX_POINTS];
|
||||
uniform float points_x[256];
|
||||
uniform float points_y[256];
|
||||
|
||||
uniform float intensity;
|
||||
uniform float i_curve[CURVE_MAX];
|
||||
|
@ -41,98 +153,6 @@ vec4 sample(vec2 pos) { #region
|
|||
return vec4(0.);
|
||||
} #endregion
|
||||
|
||||
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
|
||||
float p = prog;
|
||||
float i = 1. - p;
|
||||
|
||||
return _y0 * i*i*i +
|
||||
ay0 * 3. * i*i*p +
|
||||
by1 * 3. * i*p*p +
|
||||
_y1 * p*p*p;
|
||||
}
|
||||
|
||||
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
||||
float _xt = _x;
|
||||
int _binRep = 8;
|
||||
|
||||
if(_x <= 0.) return _y0;
|
||||
if(_x >= 1.) return _y1;
|
||||
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
|
||||
|
||||
for(int i = 0; i < _binRep; i++) {
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.);
|
||||
|
||||
if(abs(_ftx - _x) < _prec)
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
|
||||
if(_xt < _x) st = _xt;
|
||||
else ed = _xt;
|
||||
|
||||
_xt = (st + ed) / 2.;
|
||||
}
|
||||
|
||||
int _newRep = 16;
|
||||
|
||||
for(int i = 0; i < _newRep; i++) {
|
||||
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
|
||||
+ (-12. * ax0 + 6. * bx1) * _xt
|
||||
+ 3. * ax0;
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.)
|
||||
- _x;
|
||||
|
||||
_xt -= _ftx / slope;
|
||||
|
||||
if(abs(_ftx) < _prec)
|
||||
break;
|
||||
}
|
||||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
|
||||
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
|
||||
|
||||
int _shf = amo - int(floor(float(amo) / 6.) * 6.);
|
||||
int _segs = (amo - _shf) / 6 - 1;
|
||||
float _shift = _shf > 0? curve[0] : 0.;
|
||||
float _scale = _shf > 1? curve[1] : 1.;
|
||||
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0., 1.);
|
||||
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = _shf + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
float _y0 = curve[ind + 3];
|
||||
float ax0 = _x0 + curve[ind + 4];
|
||||
float ay0 = _y0 + curve[ind + 5];
|
||||
|
||||
float _x1 = curve[ind + 6 + 2];
|
||||
float _y1 = curve[ind + 6 + 3];
|
||||
float bx1 = _x1 + curve[ind + 6 + 0];
|
||||
float by1 = _y1 + curve[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
float t = (_x - _x0) / (_x1 - _x0);
|
||||
if(curve[ind + 4] == 0. && curve[ind + 5] == 0. && curve[ind + 6 + 0] == 0. && curve[ind + 6 + 1] == 0.)
|
||||
return mix(_y0, _y1, t);
|
||||
|
||||
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, t);
|
||||
}
|
||||
|
||||
return curve[0];
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 p = vec4(0.);
|
||||
float a = 0.;
|
||||
|
|
|
@ -1,8 +1,123 @@
|
|||
#ifdef _YY_HLSL11_
|
||||
#define CURVE_MAX 256
|
||||
#else
|
||||
#define CURVE_MAX 256
|
||||
#endif
|
||||
#pragma use(curve)
|
||||
|
||||
#region -- curve -- [1740201118.8128765]
|
||||
|
||||
#ifdef _YY_HLSL11_
|
||||
#define CURVE_MAX 512
|
||||
#else
|
||||
#define CURVE_MAX 256
|
||||
#endif
|
||||
|
||||
uniform int curve_offset;
|
||||
|
||||
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
|
||||
float p = prog;
|
||||
float i = 1. - p;
|
||||
|
||||
return _y0 * i*i*i +
|
||||
ay0 * 3. * i*i*p +
|
||||
by1 * 3. * i*p*p +
|
||||
_y1 * p*p*p;
|
||||
}
|
||||
|
||||
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
||||
float _xt = _x;
|
||||
int _binRep = 8;
|
||||
|
||||
if(_x <= 0.) return _y0;
|
||||
if(_x >= 1.) return _y1;
|
||||
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
|
||||
|
||||
for(int i = 0; i < _binRep; i++) {
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.);
|
||||
|
||||
if(abs(_ftx - _x) < _prec)
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
|
||||
if(_xt < _x) st = _xt;
|
||||
else ed = _xt;
|
||||
|
||||
_xt = (st + ed) / 2.;
|
||||
}
|
||||
|
||||
int _newRep = 16;
|
||||
|
||||
for(int i = 0; i < _newRep; i++) {
|
||||
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
|
||||
+ (-12. * ax0 + 6. * bx1) * _xt
|
||||
+ 3. * ax0;
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.)
|
||||
- _x;
|
||||
|
||||
_xt -= _ftx / slope;
|
||||
|
||||
if(abs(_ftx) < _prec)
|
||||
break;
|
||||
}
|
||||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
|
||||
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
|
||||
|
||||
int _segs = (amo - curve_offset) / 6 - 1;
|
||||
float _shift = curve[0];
|
||||
float _scale = curve[1];
|
||||
float _type = curve[2];
|
||||
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0., 1.);
|
||||
|
||||
if(_type == 0.) {
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
float _y0 = curve[ind + 3];
|
||||
float ax0 = _x0 + curve[ind + 4];
|
||||
float ay0 = _y0 + curve[ind + 5];
|
||||
|
||||
float _x1 = curve[ind + 6 + 2];
|
||||
float _y1 = curve[ind + 6 + 3];
|
||||
float bx1 = _x1 + curve[ind + 6 + 0];
|
||||
float by1 = _y1 + curve[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
float t = (_x - _x0) / (_x1 - _x0);
|
||||
if(curve[ind + 4] == 0. && curve[ind + 5] == 0. && curve[ind + 6 + 0] == 0. && curve[ind + 6 + 1] == 0.)
|
||||
return mix(_y0, _y1, t);
|
||||
|
||||
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, t);
|
||||
}
|
||||
|
||||
} else if(_type == 1.) {
|
||||
float y0 = curve[curve_offset + 3];
|
||||
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
|
||||
if(_x < _x0) return y0;
|
||||
y0 = curve[ind + 3];
|
||||
}
|
||||
|
||||
return y0;
|
||||
}
|
||||
|
||||
return curve[amo - 3];
|
||||
}
|
||||
|
||||
#endregion -- curve --
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
@ -22,98 +137,6 @@ uniform int b_amount;
|
|||
uniform float a_curve[CURVE_MAX];
|
||||
uniform int a_amount;
|
||||
|
||||
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
|
||||
float p = prog;
|
||||
float i = 1. - p;
|
||||
|
||||
return _y0 * i*i*i +
|
||||
ay0 * 3. * i*i*p +
|
||||
by1 * 3. * i*p*p +
|
||||
_y1 * p*p*p;
|
||||
}
|
||||
|
||||
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
||||
float _xt = _x;
|
||||
int _binRep = 8;
|
||||
|
||||
if(_x <= 0.) return _y0;
|
||||
if(_x >= 1.) return _y1;
|
||||
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
|
||||
|
||||
for(int i = 0; i < _binRep; i++) {
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.);
|
||||
|
||||
if(abs(_ftx - _x) < _prec)
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
|
||||
if(_xt < _x) st = _xt;
|
||||
else ed = _xt;
|
||||
|
||||
_xt = (st + ed) / 2.;
|
||||
}
|
||||
|
||||
int _newRep = 16;
|
||||
|
||||
for(int i = 0; i < _newRep; i++) {
|
||||
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
|
||||
+ (-12. * ax0 + 6. * bx1) * _xt
|
||||
+ 3. * ax0;
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.)
|
||||
- _x;
|
||||
|
||||
_xt -= _ftx / slope;
|
||||
|
||||
if(abs(_ftx) < _prec)
|
||||
break;
|
||||
}
|
||||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
|
||||
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
|
||||
|
||||
int _shf = amo - int(floor(float(amo) / 6.) * 6.);
|
||||
int _segs = (amo - _shf) / 6 - 1;
|
||||
float _shift = _shf > 0? curve[0] : 0.;
|
||||
float _scale = _shf > 1? curve[1] : 1.;
|
||||
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0., 1.);
|
||||
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = _shf + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
float _y0 = curve[ind + 3];
|
||||
float ax0 = _x0 + curve[ind + 4];
|
||||
float ay0 = _y0 + curve[ind + 5];
|
||||
|
||||
float _x1 = curve[ind + 6 + 2];
|
||||
float _y1 = curve[ind + 6 + 3];
|
||||
float bx1 = _x1 + curve[ind + 6 + 0];
|
||||
float by1 = _y1 + curve[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
float t = (_x - _x0) / (_x1 - _x0);
|
||||
if(curve[ind + 4] == 0. && curve[ind + 5] == 0. && curve[ind + 6 + 0] == 0. && curve[ind + 6 + 1] == 0.)
|
||||
return mix(_y0, _y1, t);
|
||||
|
||||
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, t);
|
||||
}
|
||||
|
||||
return curve[0];
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 col = texture2D( gm_BaseTexture, v_vTexcoord );
|
||||
|
||||
|
|
|
@ -1,9 +1,123 @@
|
|||
#pragma use(curve)
|
||||
|
||||
#ifdef _YY_HLSL11_
|
||||
#define CURVE_MAX 256
|
||||
#else
|
||||
#define CURVE_MAX 256
|
||||
#endif
|
||||
#region -- curve -- [1740201118.8128765]
|
||||
|
||||
#ifdef _YY_HLSL11_
|
||||
#define CURVE_MAX 512
|
||||
#else
|
||||
#define CURVE_MAX 256
|
||||
#endif
|
||||
|
||||
uniform int curve_offset;
|
||||
|
||||
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
|
||||
float p = prog;
|
||||
float i = 1. - p;
|
||||
|
||||
return _y0 * i*i*i +
|
||||
ay0 * 3. * i*i*p +
|
||||
by1 * 3. * i*p*p +
|
||||
_y1 * p*p*p;
|
||||
}
|
||||
|
||||
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
||||
float _xt = _x;
|
||||
int _binRep = 8;
|
||||
|
||||
if(_x <= 0.) return _y0;
|
||||
if(_x >= 1.) return _y1;
|
||||
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
|
||||
|
||||
for(int i = 0; i < _binRep; i++) {
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.);
|
||||
|
||||
if(abs(_ftx - _x) < _prec)
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
|
||||
if(_xt < _x) st = _xt;
|
||||
else ed = _xt;
|
||||
|
||||
_xt = (st + ed) / 2.;
|
||||
}
|
||||
|
||||
int _newRep = 16;
|
||||
|
||||
for(int i = 0; i < _newRep; i++) {
|
||||
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
|
||||
+ (-12. * ax0 + 6. * bx1) * _xt
|
||||
+ 3. * ax0;
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.)
|
||||
- _x;
|
||||
|
||||
_xt -= _ftx / slope;
|
||||
|
||||
if(abs(_ftx) < _prec)
|
||||
break;
|
||||
}
|
||||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
|
||||
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
|
||||
|
||||
int _segs = (amo - curve_offset) / 6 - 1;
|
||||
float _shift = curve[0];
|
||||
float _scale = curve[1];
|
||||
float _type = curve[2];
|
||||
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0., 1.);
|
||||
|
||||
if(_type == 0.) {
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
float _y0 = curve[ind + 3];
|
||||
float ax0 = _x0 + curve[ind + 4];
|
||||
float ay0 = _y0 + curve[ind + 5];
|
||||
|
||||
float _x1 = curve[ind + 6 + 2];
|
||||
float _y1 = curve[ind + 6 + 3];
|
||||
float bx1 = _x1 + curve[ind + 6 + 0];
|
||||
float by1 = _y1 + curve[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
float t = (_x - _x0) / (_x1 - _x0);
|
||||
if(curve[ind + 4] == 0. && curve[ind + 5] == 0. && curve[ind + 6 + 0] == 0. && curve[ind + 6 + 1] == 0.)
|
||||
return mix(_y0, _y1, t);
|
||||
|
||||
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, t);
|
||||
}
|
||||
|
||||
} else if(_type == 1.) {
|
||||
float y0 = curve[curve_offset + 3];
|
||||
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
|
||||
if(_x < _x0) return y0;
|
||||
y0 = curve[ind + 3];
|
||||
}
|
||||
|
||||
return y0;
|
||||
}
|
||||
|
||||
return curve[amo - 3];
|
||||
}
|
||||
|
||||
#endregion -- curve --
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
@ -17,98 +131,6 @@ uniform int s_amount;
|
|||
uniform float v_curve[CURVE_MAX];
|
||||
uniform int v_amount;
|
||||
|
||||
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
|
||||
float p = prog;
|
||||
float i = 1. - p;
|
||||
|
||||
return _y0 * i*i*i +
|
||||
ay0 * 3. * i*i*p +
|
||||
by1 * 3. * i*p*p +
|
||||
_y1 * p*p*p;
|
||||
}
|
||||
|
||||
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
||||
float _xt = _x;
|
||||
int _binRep = 8;
|
||||
|
||||
if(_x <= 0.) return _y0;
|
||||
if(_x >= 1.) return _y1;
|
||||
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
|
||||
|
||||
for(int i = 0; i < _binRep; i++) {
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.);
|
||||
|
||||
if(abs(_ftx - _x) < _prec)
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
|
||||
if(_xt < _x) st = _xt;
|
||||
else ed = _xt;
|
||||
|
||||
_xt = (st + ed) / 2.;
|
||||
}
|
||||
|
||||
int _newRep = 16;
|
||||
|
||||
for(int i = 0; i < _newRep; i++) {
|
||||
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
|
||||
+ (-12. * ax0 + 6. * bx1) * _xt
|
||||
+ 3. * ax0;
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.)
|
||||
- _x;
|
||||
|
||||
_xt -= _ftx / slope;
|
||||
|
||||
if(abs(_ftx) < _prec)
|
||||
break;
|
||||
}
|
||||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
|
||||
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
|
||||
|
||||
int _shf = amo - int(floor(float(amo) / 6.) * 6.);
|
||||
int _segs = (amo - _shf) / 6 - 1;
|
||||
float _shift = _shf > 0? curve[0] : 0.;
|
||||
float _scale = _shf > 1? curve[1] : 1.;
|
||||
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0., 1.);
|
||||
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = _shf + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
float _y0 = curve[ind + 3];
|
||||
float ax0 = _x0 + curve[ind + 4];
|
||||
float ay0 = _y0 + curve[ind + 5];
|
||||
|
||||
float _x1 = curve[ind + 6 + 2];
|
||||
float _y1 = curve[ind + 6 + 3];
|
||||
float bx1 = _x1 + curve[ind + 6 + 0];
|
||||
float by1 = _y1 + curve[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
float t = (_x - _x0) / (_x1 - _x0);
|
||||
if(curve[ind + 4] == 0. && curve[ind + 5] == 0. && curve[ind + 6 + 0] == 0. && curve[ind + 6 + 1] == 0.)
|
||||
return mix(_y0, _y1, t);
|
||||
|
||||
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, t);
|
||||
}
|
||||
|
||||
return curve[0];
|
||||
}
|
||||
|
||||
#region =========================================== COLORS SPACES ===========================================
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
|
|
|
@ -1,10 +1,123 @@
|
|||
#define PI 3.14159265359
|
||||
#pragma use(curve)
|
||||
|
||||
#ifdef _YY_HLSL11_
|
||||
#define CURVE_MAX 1024
|
||||
#else
|
||||
#define CURVE_MAX 512
|
||||
#endif
|
||||
#region -- curve -- [1740201118.8128765]
|
||||
|
||||
#ifdef _YY_HLSL11_
|
||||
#define CURVE_MAX 512
|
||||
#else
|
||||
#define CURVE_MAX 256
|
||||
#endif
|
||||
|
||||
uniform int curve_offset;
|
||||
|
||||
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
|
||||
float p = prog;
|
||||
float i = 1. - p;
|
||||
|
||||
return _y0 * i*i*i +
|
||||
ay0 * 3. * i*i*p +
|
||||
by1 * 3. * i*p*p +
|
||||
_y1 * p*p*p;
|
||||
}
|
||||
|
||||
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
||||
float _xt = _x;
|
||||
int _binRep = 8;
|
||||
|
||||
if(_x <= 0.) return _y0;
|
||||
if(_x >= 1.) return _y1;
|
||||
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
|
||||
|
||||
for(int i = 0; i < _binRep; i++) {
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.);
|
||||
|
||||
if(abs(_ftx - _x) < _prec)
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
|
||||
if(_xt < _x) st = _xt;
|
||||
else ed = _xt;
|
||||
|
||||
_xt = (st + ed) / 2.;
|
||||
}
|
||||
|
||||
int _newRep = 16;
|
||||
|
||||
for(int i = 0; i < _newRep; i++) {
|
||||
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
|
||||
+ (-12. * ax0 + 6. * bx1) * _xt
|
||||
+ 3. * ax0;
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.)
|
||||
- _x;
|
||||
|
||||
_xt -= _ftx / slope;
|
||||
|
||||
if(abs(_ftx) < _prec)
|
||||
break;
|
||||
}
|
||||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
|
||||
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
|
||||
|
||||
int _segs = (amo - curve_offset) / 6 - 1;
|
||||
float _shift = curve[0];
|
||||
float _scale = curve[1];
|
||||
float _type = curve[2];
|
||||
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0., 1.);
|
||||
|
||||
if(_type == 0.) {
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
float _y0 = curve[ind + 3];
|
||||
float ax0 = _x0 + curve[ind + 4];
|
||||
float ay0 = _y0 + curve[ind + 5];
|
||||
|
||||
float _x1 = curve[ind + 6 + 2];
|
||||
float _y1 = curve[ind + 6 + 3];
|
||||
float bx1 = _x1 + curve[ind + 6 + 0];
|
||||
float by1 = _y1 + curve[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
float t = (_x - _x0) / (_x1 - _x0);
|
||||
if(curve[ind + 4] == 0. && curve[ind + 5] == 0. && curve[ind + 6 + 0] == 0. && curve[ind + 6 + 1] == 0.)
|
||||
return mix(_y0, _y1, t);
|
||||
|
||||
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, t);
|
||||
}
|
||||
|
||||
} else if(_type == 1.) {
|
||||
float y0 = curve[curve_offset + 3];
|
||||
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
|
||||
if(_x < _x0) return y0;
|
||||
y0 = curve[ind + 3];
|
||||
}
|
||||
|
||||
return y0;
|
||||
}
|
||||
|
||||
return curve[amo - 3];
|
||||
}
|
||||
|
||||
#endregion -- curve --
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
@ -20,101 +133,7 @@ uniform int w_amount;
|
|||
uniform vec2 point1[1024];
|
||||
uniform vec2 point2[1024];
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
|
||||
float p = prog;
|
||||
float i = 1. - p;
|
||||
|
||||
return _y0 * i*i*i +
|
||||
ay0 * 3. * i*i*p +
|
||||
by1 * 3. * i*p*p +
|
||||
_y1 * p*p*p;
|
||||
}
|
||||
|
||||
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
||||
float _xt = _x;
|
||||
int _binRep = 8;
|
||||
|
||||
if(_x <= 0.) return _y0;
|
||||
if(_x >= 1.) return _y1;
|
||||
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
|
||||
|
||||
for(int i = 0; i < _binRep; i++) {
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.);
|
||||
|
||||
if(abs(_ftx - _x) < _prec)
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
|
||||
if(_xt < _x) st = _xt;
|
||||
else ed = _xt;
|
||||
|
||||
_xt = (st + ed) / 2.;
|
||||
}
|
||||
|
||||
int _newRep = 16;
|
||||
|
||||
for(int i = 0; i < _newRep; i++) {
|
||||
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
|
||||
+ (-12. * ax0 + 6. * bx1) * _xt
|
||||
+ 3. * ax0;
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.)
|
||||
- _x;
|
||||
|
||||
_xt -= _ftx / slope;
|
||||
|
||||
if(abs(_ftx) < _prec)
|
||||
break;
|
||||
}
|
||||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
|
||||
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
|
||||
|
||||
int _shf = amo - int(floor(float(amo) / 6.) * 6.);
|
||||
int _segs = (amo - _shf) / 6 - 1;
|
||||
float _shift = _shf > 0? curve[0] : 0.;
|
||||
float _scale = _shf > 1? curve[1] : 1.;
|
||||
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0., 1.);
|
||||
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = _shf + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
float _y0 = curve[ind + 3];
|
||||
float ax0 = _x0 + curve[ind + 4];
|
||||
float ay0 = _y0 + curve[ind + 5];
|
||||
|
||||
float _x1 = curve[ind + 6 + 2];
|
||||
float _y1 = curve[ind + 6 + 3];
|
||||
float bx1 = _x1 + curve[ind + 6 + 0];
|
||||
float by1 = _y1 + curve[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
float t = (_x - _x0) / (_x1 - _x0);
|
||||
if(curve[ind + 4] == 0. && curve[ind + 5] == 0. && curve[ind + 6 + 0] == 0. && curve[ind + 6 + 1] == 0.)
|
||||
return mix(_y0, _y1, t);
|
||||
|
||||
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, t);
|
||||
}
|
||||
|
||||
return curve[0];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#define PI 3.14159265359
|
||||
|
||||
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.);
|
||||
|
|
|
@ -1,4 +1,123 @@
|
|||
#define CURVE_MAX 512
|
||||
#pragma use(curve)
|
||||
|
||||
#region -- curve -- [1740201118.8128765]
|
||||
|
||||
#ifdef _YY_HLSL11_
|
||||
#define CURVE_MAX 512
|
||||
#else
|
||||
#define CURVE_MAX 256
|
||||
#endif
|
||||
|
||||
uniform int curve_offset;
|
||||
|
||||
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
|
||||
float p = prog;
|
||||
float i = 1. - p;
|
||||
|
||||
return _y0 * i*i*i +
|
||||
ay0 * 3. * i*i*p +
|
||||
by1 * 3. * i*p*p +
|
||||
_y1 * p*p*p;
|
||||
}
|
||||
|
||||
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
||||
float _xt = _x;
|
||||
int _binRep = 8;
|
||||
|
||||
if(_x <= 0.) return _y0;
|
||||
if(_x >= 1.) return _y1;
|
||||
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
|
||||
|
||||
for(int i = 0; i < _binRep; i++) {
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.);
|
||||
|
||||
if(abs(_ftx - _x) < _prec)
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
|
||||
if(_xt < _x) st = _xt;
|
||||
else ed = _xt;
|
||||
|
||||
_xt = (st + ed) / 2.;
|
||||
}
|
||||
|
||||
int _newRep = 16;
|
||||
|
||||
for(int i = 0; i < _newRep; i++) {
|
||||
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
|
||||
+ (-12. * ax0 + 6. * bx1) * _xt
|
||||
+ 3. * ax0;
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.)
|
||||
- _x;
|
||||
|
||||
_xt -= _ftx / slope;
|
||||
|
||||
if(abs(_ftx) < _prec)
|
||||
break;
|
||||
}
|
||||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
|
||||
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
|
||||
|
||||
int _segs = (amo - curve_offset) / 6 - 1;
|
||||
float _shift = curve[0];
|
||||
float _scale = curve[1];
|
||||
float _type = curve[2];
|
||||
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0., 1.);
|
||||
|
||||
if(_type == 0.) {
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
float _y0 = curve[ind + 3];
|
||||
float ax0 = _x0 + curve[ind + 4];
|
||||
float ay0 = _y0 + curve[ind + 5];
|
||||
|
||||
float _x1 = curve[ind + 6 + 2];
|
||||
float _y1 = curve[ind + 6 + 3];
|
||||
float bx1 = _x1 + curve[ind + 6 + 0];
|
||||
float by1 = _y1 + curve[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
float t = (_x - _x0) / (_x1 - _x0);
|
||||
if(curve[ind + 4] == 0. && curve[ind + 5] == 0. && curve[ind + 6 + 0] == 0. && curve[ind + 6 + 1] == 0.)
|
||||
return mix(_y0, _y1, t);
|
||||
|
||||
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, t);
|
||||
}
|
||||
|
||||
} else if(_type == 1.) {
|
||||
float y0 = curve[curve_offset + 3];
|
||||
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
|
||||
if(_x < _x0) return y0;
|
||||
y0 = curve[ind + 3];
|
||||
}
|
||||
|
||||
return y0;
|
||||
}
|
||||
|
||||
return curve[amo - 3];
|
||||
}
|
||||
|
||||
#endregion -- curve --
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
@ -10,101 +129,10 @@ uniform int useMap;
|
|||
uniform sampler2D strengthMap;
|
||||
|
||||
uniform float alpha_curve[CURVE_MAX];
|
||||
uniform int curve_amount;
|
||||
uniform int alpha_amount;
|
||||
|
||||
uniform float randomAmount;
|
||||
|
||||
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
|
||||
float p = prog;
|
||||
float i = 1. - p;
|
||||
|
||||
return _y0 * i*i*i +
|
||||
ay0 * 3. * i*i*p +
|
||||
by1 * 3. * i*p*p +
|
||||
_y1 * p*p*p;
|
||||
}
|
||||
|
||||
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
||||
float _xt = _x;
|
||||
int _binRep = 8;
|
||||
|
||||
if(_x <= 0.) return _y0;
|
||||
if(_x >= 1.) return _y1;
|
||||
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
|
||||
|
||||
for(int i = 0; i < _binRep; i++) {
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.);
|
||||
|
||||
if(abs(_ftx - _x) < _prec)
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
|
||||
if(_xt < _x) st = _xt;
|
||||
else ed = _xt;
|
||||
|
||||
_xt = (st + ed) / 2.;
|
||||
}
|
||||
|
||||
int _newRep = 16;
|
||||
|
||||
for(int i = 0; i < _newRep; i++) {
|
||||
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
|
||||
+ (-12. * ax0 + 6. * bx1) * _xt
|
||||
+ 3. * ax0;
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.)
|
||||
- _x;
|
||||
|
||||
_xt -= _ftx / slope;
|
||||
|
||||
if(abs(_ftx) < _prec)
|
||||
break;
|
||||
}
|
||||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
|
||||
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
|
||||
|
||||
int _shf = amo - int(floor(float(amo) / 6.) * 6.);
|
||||
int _segs = (amo - _shf) / 6 - 1;
|
||||
float _shift = _shf > 0? curve[0] : 0.;
|
||||
float _scale = _shf > 1? curve[1] : 1.;
|
||||
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0., 1.);
|
||||
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = _shf + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
float _y0 = curve[ind + 3];
|
||||
float ax0 = _x0 + curve[ind + 4];
|
||||
float ay0 = _y0 + curve[ind + 5];
|
||||
|
||||
float _x1 = curve[ind + 6 + 2];
|
||||
float _y1 = curve[ind + 6 + 3];
|
||||
float bx1 = _x1 + curve[ind + 6 + 0];
|
||||
float by1 = _y1 + curve[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
float t = (_x - _x0) / (_x1 - _x0);
|
||||
if(curve[ind + 4] == 0. && curve[ind + 5] == 0. && curve[ind + 6 + 0] == 0. && curve[ind + 6 + 1] == 0.)
|
||||
return mix(_y0, _y1, t);
|
||||
|
||||
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, t);
|
||||
}
|
||||
|
||||
return curve[0];
|
||||
}
|
||||
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
|
@ -271,7 +299,7 @@ void main() {
|
|||
_col = texture2D( gm_BaseTexture, _new_pos );
|
||||
vec4 cc = gradientEval(str + frandom(_pos, 1.235) * randomAmount);
|
||||
_col.rgb *= cc.rgb;
|
||||
_col.a *= cc.a * curveEval(alpha_curve, curve_amount, str + frandom(_pos, 2.984) * randomAmount);
|
||||
_col.a *= cc.a * curveEval(alpha_curve, alpha_amount, str + frandom(_pos, 2.984) * randomAmount);
|
||||
}
|
||||
|
||||
gl_FragColor = _col;
|
||||
|
|
|
@ -1,10 +1,125 @@
|
|||
// 2D Signed Distance equations by InigoQuilez
|
||||
#pragma use(curve)
|
||||
|
||||
#ifdef _YY_HLSL11_
|
||||
#define CURVE_MAX 1024
|
||||
#else
|
||||
#define CURVE_MAX 512
|
||||
#endif
|
||||
#region -- curve -- [1740201118.8128765]
|
||||
|
||||
#ifdef _YY_HLSL11_
|
||||
#define CURVE_MAX 512
|
||||
#else
|
||||
#define CURVE_MAX 256
|
||||
#endif
|
||||
|
||||
uniform int curve_offset;
|
||||
|
||||
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
|
||||
float p = prog;
|
||||
float i = 1. - p;
|
||||
|
||||
return _y0 * i*i*i +
|
||||
ay0 * 3. * i*i*p +
|
||||
by1 * 3. * i*p*p +
|
||||
_y1 * p*p*p;
|
||||
}
|
||||
|
||||
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
||||
float _xt = _x;
|
||||
int _binRep = 8;
|
||||
|
||||
if(_x <= 0.) return _y0;
|
||||
if(_x >= 1.) return _y1;
|
||||
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
|
||||
|
||||
for(int i = 0; i < _binRep; i++) {
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.);
|
||||
|
||||
if(abs(_ftx - _x) < _prec)
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
|
||||
if(_xt < _x) st = _xt;
|
||||
else ed = _xt;
|
||||
|
||||
_xt = (st + ed) / 2.;
|
||||
}
|
||||
|
||||
int _newRep = 16;
|
||||
|
||||
for(int i = 0; i < _newRep; i++) {
|
||||
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
|
||||
+ (-12. * ax0 + 6. * bx1) * _xt
|
||||
+ 3. * ax0;
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.)
|
||||
- _x;
|
||||
|
||||
_xt -= _ftx / slope;
|
||||
|
||||
if(abs(_ftx) < _prec)
|
||||
break;
|
||||
}
|
||||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
|
||||
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
|
||||
|
||||
int _segs = (amo - curve_offset) / 6 - 1;
|
||||
float _shift = curve[0];
|
||||
float _scale = curve[1];
|
||||
float _type = curve[2];
|
||||
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0., 1.);
|
||||
|
||||
if(_type == 0.) {
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
float _y0 = curve[ind + 3];
|
||||
float ax0 = _x0 + curve[ind + 4];
|
||||
float ay0 = _y0 + curve[ind + 5];
|
||||
|
||||
float _x1 = curve[ind + 6 + 2];
|
||||
float _y1 = curve[ind + 6 + 3];
|
||||
float bx1 = _x1 + curve[ind + 6 + 0];
|
||||
float by1 = _y1 + curve[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
float t = (_x - _x0) / (_x1 - _x0);
|
||||
if(curve[ind + 4] == 0. && curve[ind + 5] == 0. && curve[ind + 6 + 0] == 0. && curve[ind + 6 + 1] == 0.)
|
||||
return mix(_y0, _y1, t);
|
||||
|
||||
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, t);
|
||||
}
|
||||
|
||||
} else if(_type == 1.) {
|
||||
float y0 = curve[curve_offset + 3];
|
||||
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = curve_offset + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
|
||||
if(_x < _x0) return y0;
|
||||
y0 = curve[ind + 3];
|
||||
}
|
||||
|
||||
return y0;
|
||||
}
|
||||
|
||||
return curve[amo - 3];
|
||||
}
|
||||
|
||||
#endregion -- curve --
|
||||
|
||||
// 2D Signed Distance equations by InigoQuilez
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
@ -18,6 +133,7 @@ uniform int tile;
|
|||
uniform int drawBG;
|
||||
uniform int drawDF;
|
||||
uniform vec2 dfLevel;
|
||||
|
||||
uniform float w_curve[CURVE_MAX];
|
||||
uniform int w_amount;
|
||||
|
||||
|
@ -70,102 +186,6 @@ float smin( float a, float b, float k ) {
|
|||
return min(a,b) - k*0.5*(1.0+h-sqrt(1.0-h*(h-2.0)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
|
||||
float p = prog;
|
||||
float i = 1. - p;
|
||||
|
||||
return _y0 * i*i*i +
|
||||
ay0 * 3. * i*i*p +
|
||||
by1 * 3. * i*p*p +
|
||||
_y1 * p*p*p;
|
||||
}
|
||||
|
||||
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
||||
float _xt = _x;
|
||||
int _binRep = 8;
|
||||
|
||||
if(_x <= 0.) return _y0;
|
||||
if(_x >= 1.) return _y1;
|
||||
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
|
||||
|
||||
for(int i = 0; i < _binRep; i++) {
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.);
|
||||
|
||||
if(abs(_ftx - _x) < _prec)
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
|
||||
if(_xt < _x) st = _xt;
|
||||
else ed = _xt;
|
||||
|
||||
_xt = (st + ed) / 2.;
|
||||
}
|
||||
|
||||
int _newRep = 16;
|
||||
|
||||
for(int i = 0; i < _newRep; i++) {
|
||||
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
|
||||
+ (-12. * ax0 + 6. * bx1) * _xt
|
||||
+ 3. * ax0;
|
||||
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
|
||||
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
|
||||
+ pow(_xt, 3.)
|
||||
- _x;
|
||||
|
||||
_xt -= _ftx / slope;
|
||||
|
||||
if(abs(_ftx) < _prec)
|
||||
break;
|
||||
}
|
||||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
|
||||
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
|
||||
|
||||
int _shf = amo - int(floor(float(amo) / 6.) * 6.);
|
||||
int _segs = (amo - _shf) / 6 - 1;
|
||||
float _shift = _shf > 0? curve[0] : 0.;
|
||||
float _scale = _shf > 1? curve[1] : 1.;
|
||||
|
||||
_x = _x / _scale - _shift;
|
||||
_x = clamp(_x, 0., 1.);
|
||||
|
||||
for( int i = 0; i < _segs; i++ ) {
|
||||
int ind = _shf + i * 6;
|
||||
float _x0 = curve[ind + 2];
|
||||
float _y0 = curve[ind + 3];
|
||||
float ax0 = _x0 + curve[ind + 4];
|
||||
float ay0 = _y0 + curve[ind + 5];
|
||||
|
||||
float _x1 = curve[ind + 6 + 2];
|
||||
float _y1 = curve[ind + 6 + 3];
|
||||
float bx1 = _x1 + curve[ind + 6 + 0];
|
||||
float by1 = _y1 + curve[ind + 6 + 1];
|
||||
|
||||
if(_x < _x0) continue;
|
||||
if(_x > _x1) continue;
|
||||
|
||||
float t = (_x - _x0) / (_x1 - _x0);
|
||||
if(curve[ind + 4] == 0. && curve[ind + 5] == 0. && curve[ind + 6 + 0] == 0. && curve[ind + 6 + 1] == 0.)
|
||||
return mix(_y0, _y1, t);
|
||||
|
||||
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, t);
|
||||
}
|
||||
|
||||
return curve[0];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float sdRegularPolygon(in vec2 p, in float r, in int n, in float ang ) {
|
||||
// these 4 lines can be precomputed for a given shape
|
||||
float an = PI / float(n);
|
||||
|
|
Loading…
Add table
Reference in a new issue