- New Quasicrystal node
|
@ -970,6 +970,7 @@
|
|||
{"name":"s_node_3d_light_directi","order":17,"path":"sprites/s_node_3d_light_directi/s_node_3d_light_directi.yy",},
|
||||
{"name":"spr_gameframe_pixel","order":3,"path":"sprites/spr_gameframe_pixel/spr_gameframe_pixel.yy",},
|
||||
{"name":"process_functions","order":36,"path":"scripts/process_functions/process_functions.yy",},
|
||||
{"name":"node_quasicrystal","order":9,"path":"scripts/node_quasicrystal/node_quasicrystal.yy",},
|
||||
{"name":"s_node_radial","order":47,"path":"sprites/s_node_radial/s_node_radial.yy",},
|
||||
{"name":"s_node_grid","order":3,"path":"sprites/s_node_grid/s_node_grid.yy",},
|
||||
{"name":"s_patreon_supporter","order":4,"path":"sprites/s_patreon_supporter/s_patreon_supporter.yy",},
|
||||
|
@ -1730,6 +1731,7 @@
|
|||
{"name":"path_parser","order":3,"path":"scripts/path_parser/path_parser.yy",},
|
||||
{"name":"s_node_3d_camera","order":13,"path":"sprites/s_node_3d_camera/s_node_3d_camera.yy",},
|
||||
{"name":"node_crop_content","order":14,"path":"scripts/node_crop_content/node_crop_content.yy",},
|
||||
{"name":"sh_quarsicrystal","order":23,"path":"shaders/sh_quarsicrystal/sh_quarsicrystal.yy",},
|
||||
{"name":"s_node_unicode","order":8,"path":"sprites/s_node_unicode/s_node_unicode.yy",},
|
||||
{"name":"s_node_color_from_hsv","order":4,"path":"sprites/s_node_color_from_hsv/s_node_color_from_hsv.yy",},
|
||||
{"name":"fd_rectangle_get_material_type","order":14,"path":"scripts/fd_rectangle_get_material_type/fd_rectangle_get_material_type.yy",},
|
||||
|
|
|
@ -1258,6 +1258,7 @@
|
|||
{"id":{"name":"s_node_3d_light_directi","path":"sprites/s_node_3d_light_directi/s_node_3d_light_directi.yy",},},
|
||||
{"id":{"name":"spr_gameframe_pixel","path":"sprites/spr_gameframe_pixel/spr_gameframe_pixel.yy",},},
|
||||
{"id":{"name":"process_functions","path":"scripts/process_functions/process_functions.yy",},},
|
||||
{"id":{"name":"node_quasicrystal","path":"scripts/node_quasicrystal/node_quasicrystal.yy",},},
|
||||
{"id":{"name":"s_node_radial","path":"sprites/s_node_radial/s_node_radial.yy",},},
|
||||
{"id":{"name":"s_node_grid","path":"sprites/s_node_grid/s_node_grid.yy",},},
|
||||
{"id":{"name":"s_patreon_supporter","path":"sprites/s_patreon_supporter/s_patreon_supporter.yy",},},
|
||||
|
@ -2125,6 +2126,7 @@
|
|||
{"id":{"name":"path_parser","path":"scripts/path_parser/path_parser.yy",},},
|
||||
{"id":{"name":"s_node_3d_camera","path":"sprites/s_node_3d_camera/s_node_3d_camera.yy",},},
|
||||
{"id":{"name":"node_crop_content","path":"scripts/node_crop_content/node_crop_content.yy",},},
|
||||
{"id":{"name":"sh_quarsicrystal","path":"shaders/sh_quarsicrystal/sh_quarsicrystal.yy",},},
|
||||
{"id":{"name":"s_node_unicode","path":"sprites/s_node_unicode/s_node_unicode.yy",},},
|
||||
{"id":{"name":"s_node_color_from_hsv","path":"sprites/s_node_color_from_hsv/s_node_color_from_hsv.yy",},},
|
||||
{"id":{"name":"fd_rectangle_get_material_type","path":"scripts/fd_rectangle_get_material_type/fd_rectangle_get_material_type.yy",},},
|
||||
|
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
|
@ -104,9 +104,10 @@ if !ready exit;
|
|||
|
||||
if(buttonInstant(THEME.button_hide, bx, by, ui(28), ui(28), mouse_ui, interactable && sFOCUS, sHOVER, __txtx("gradient_editor_key_blend", "Key blending"), THEME.grad_blend) == 2) {
|
||||
menuCall("gradient_window_blend_menu", bx + ui(32), by, [
|
||||
menuItem(__txtx("gradient_editor_blend_hard", "Hard blend"), function() { gradient.type = 1; onApply(gradient); }),
|
||||
menuItem(__txtx("gradient_editor_blend_RGB", "RGB blend"), function() { gradient.type = 0; onApply(gradient); }),
|
||||
menuItem(__txtx("gradient_editor_blend_HSV", "HSV blend"), function() { gradient.type = 2; onApply(gradient); }),
|
||||
menuItem(__txtx("gradient_editor_blend_hard", "Hard blend"), function() { gradient.type = 1; onApply(gradient); }),
|
||||
menuItem(__txtx("gradient_editor_blend_OKLAB", "OKLAB blend"), function() { gradient.type = 3; onApply(gradient); }),
|
||||
],, gradient);
|
||||
}
|
||||
bx -= ui(32);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
function __mat3() constructor {
|
||||
raw = [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
|
||||
function __mat3(raw = [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]) constructor {
|
||||
self.raw = raw;
|
||||
|
||||
static det = function() {
|
||||
return raw[0]*raw[4]*raw[8] + raw[1]*raw[5]*raw[6] + raw[2]*raw[3]*raw[7]
|
||||
- raw[2]*raw[4]*raw[6] - raw[0]*raw[5]*raw[7] - raw[1]*raw[3]*raw[8];
|
||||
return raw[0] * raw[4] * raw[8] + raw[1] * raw[5] * raw[6] + raw[2] * raw[3] * raw[7]
|
||||
- raw[2] * raw[4] * raw[6] - raw[0] * raw[5] * raw[7] - raw[1] * raw[3] * raw[8];
|
||||
};
|
||||
|
||||
static multiplyMatrix = function(matrix) {
|
||||
|
|
|
@ -1,31 +1,53 @@
|
|||
function cola(color, alpha = 1) { INLINE return int64((color & 0xFFFFFF) + (round(alpha * 255) << 24)); }
|
||||
function _cola(color, alpha) { INLINE return int64((color & 0xFFFFFF) + (alpha << 24)); }
|
||||
function colda(color) { INLINE return real(color & 0xFFFFFF); }
|
||||
#region channels
|
||||
function cola(color, alpha = 1) { INLINE return int64((color & 0xFFFFFF) + (round(alpha * 255) << 24)); }
|
||||
function _cola(color, alpha) { INLINE return int64((color & 0xFFFFFF) + (alpha << 24)); }
|
||||
function colda(color) { INLINE return real(color & 0xFFFFFF); }
|
||||
|
||||
function colorFromRGBArray(arr) { #region
|
||||
function color_get_alpha(color) { INLINE return is_real(color)? 255 : (color & (0xFF << 24)) >> 24; }
|
||||
function _color_get_alpha(color) { INLINE return is_real(color)? 1 : color_get_alpha(color) / 255; }
|
||||
|
||||
function _color_get_red(color) { INLINE return color_get_red(color) / 255; }
|
||||
function _color_get_green(color) { INLINE return color_get_green(color) / 255; }
|
||||
function _color_get_blue(color) { INLINE return color_get_blue(color) / 255; }
|
||||
|
||||
function _color_get_hue(color) { INLINE return color_get_hue(color) / 255; }
|
||||
function _color_get_saturation(color) { INLINE return color_get_saturation(color) / 255; }
|
||||
function _color_get_value(color) { INLINE return color_get_value(color) / 255; }
|
||||
#endregion
|
||||
|
||||
#region conversions
|
||||
function make_color_rgba(r, g, b, a) { INLINE return int64(round(r) + (round(g) << 8) + (round(b) << 16) + (round(a) << 24)); }
|
||||
|
||||
function make_color_hsva(h, s, v, a) { INLINE return _cola(make_color_hsv(h, s, v), a); }
|
||||
|
||||
function make_color_oklab(ok, a = 1) { #region
|
||||
INLINE
|
||||
var k = new __vec3(ok[0], ok[1], ok[2]);
|
||||
k.x = power(k.x, 3);
|
||||
k.y = power(k.y, 3);
|
||||
k.z = power(k.z, 3);
|
||||
|
||||
var rg = global.CVTMAT_OKLAB_RGB.multiplyVector(k);
|
||||
rg.x = power(rg.x, 1 / 2.2);
|
||||
rg.y = power(rg.y, 1 / 2.2);
|
||||
rg.z = power(rg.z, 1 / 2.2);
|
||||
|
||||
return make_color_rgba(rg.x, rg.y, rg.z, a);
|
||||
} #endregion
|
||||
|
||||
function colorFromRGBArray(arr) { #region
|
||||
var r = round(real(arr[0]) * 255);
|
||||
var g = round(real(arr[1]) * 255);
|
||||
var b = round(real(arr[2]) * 255);
|
||||
return make_color_rgb(r, g, b);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
function color_get_alpha(color) { INLINE return is_real(color)? 255 : (color & (0xFF << 24)) >> 24; }
|
||||
function _color_get_alpha(color) { INLINE return is_real(color)? 1 : color_get_alpha(color) / 255; }
|
||||
|
||||
function _color_get_red(color) { INLINE return color_get_red(color) / 255; }
|
||||
function _color_get_green(color) { INLINE return color_get_green(color) / 255; }
|
||||
function _color_get_blue(color) { INLINE return color_get_blue(color) / 255; }
|
||||
|
||||
function _color_get_hue(color) { INLINE return color_get_hue(color) / 255; }
|
||||
function _color_get_saturation(color) { INLINE return color_get_saturation(color) / 255; }
|
||||
function _color_get_value(color) { INLINE return color_get_value(color) / 255; }
|
||||
|
||||
function colorArrayFromReal(clr) { #region
|
||||
function colorArrayFromReal(clr) { #region
|
||||
INLINE
|
||||
return [ _color_get_red(clr), _color_get_green(clr), _color_get_blue(clr) ];
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
function paletteToArray(_pal) { #region
|
||||
function paletteToArray(_pal) { #region
|
||||
var _colors = array_create(array_length(_pal) * 4);
|
||||
for(var i = 0; i < array_length(_pal); i++) {
|
||||
_colors[i * 4 + 0] = _color_get_red(_pal[i]);
|
||||
|
@ -35,17 +57,54 @@ function paletteToArray(_pal) { #region
|
|||
}
|
||||
|
||||
return _colors;
|
||||
} #endregion
|
||||
} #endregion
|
||||
#endregion
|
||||
|
||||
function colorBrightness(clr, normalize = true) { #region
|
||||
#region color spaces
|
||||
function color_rgb(col) { #region
|
||||
INLINE
|
||||
return [ color_get_red(col) / 255, color_get_green(col) / 255, color_get_blue(col) / 255 ];
|
||||
} #endregion
|
||||
|
||||
function color_hsv(col) { #region
|
||||
INLINE
|
||||
return [ color_get_hue(col) / 255, color_get_saturation(col) / 255, color_get_value(col) / 255 ];
|
||||
} #endregion
|
||||
|
||||
global.CVTMAT_RGB_OKLAB = new __mat3([ 0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616 ]);
|
||||
|
||||
global.CVTMAT_OKLAB_RGB = new __mat3([ 4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689 ]);
|
||||
|
||||
function color_oklab(col) { #region
|
||||
INLINE
|
||||
var v = new __vec3(color_get_red(col) / 255, color_get_green(col) / 255, color_get_blue(col) / 255);
|
||||
v.x = power(v.x, 2.2);
|
||||
v.y = power(v.y, 2.2);
|
||||
v.z = power(v.z, 2.2);
|
||||
|
||||
var ok = global.CVTMAT_RGB_OKLAB.multiplyVector(v);
|
||||
ok.x = power(ok.x, 1 / 3);
|
||||
ok.y = power(ok.y, 1 / 3);
|
||||
ok.z = power(ok.z, 1 / 3);
|
||||
|
||||
return [ ok.x, ok.y, ok.z ];
|
||||
} #endregion
|
||||
#endregion
|
||||
|
||||
#region data
|
||||
function colorBrightness(clr, normalize = true) { #region
|
||||
INLINE
|
||||
var r2 = color_get_red(clr) / (normalize? 255 : 1);
|
||||
var g2 = color_get_green(clr) / (normalize? 255 : 1);
|
||||
var b2 = color_get_blue(clr) / (normalize? 255 : 1);
|
||||
return 0.299 * r2 + 0.587 * g2 + 0.224 * b2;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
function colorMultiply(c1, c2) { #region
|
||||
function colorMultiply(c1, c2) { #region
|
||||
if(c1 * c2 == 0) return 0;
|
||||
if(c1 == c_white) return c2;
|
||||
if(c2 == c_white) return c1;
|
||||
|
@ -62,9 +121,9 @@ function colorMultiply(c1, c2) { #region
|
|||
|
||||
if(is_real(c1)) return make_color_rgb((r1 * r2) * 255, (g1 * g2) * 255, (b1 * b2) * 255);
|
||||
return make_color_rgba((r1 * r2) * 255, (g1 * g2) * 255, (b1 * b2) * 255, (a1 * a2) * 255);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
function colorAdd(c1, c2) { #region
|
||||
function colorAdd(c1, c2) { #region
|
||||
if(c1 == 0) return c2;
|
||||
if(c2 == 0) return c1;
|
||||
|
||||
|
@ -78,6 +137,7 @@ function colorAdd(c1, c2) { #region
|
|||
|
||||
return make_color_rgb(min(r1 + r2, 255), min(g1 + g2, 255), min(b1 + b2, 255));
|
||||
} #endregion
|
||||
#endregion
|
||||
|
||||
function color_diff(c1, c2, fast = false, alpha = false) { #region
|
||||
var _c1_r = color_get_red(c1);
|
||||
|
@ -104,23 +164,11 @@ function color_diff(c1, c2, fast = false, alpha = false) { #region
|
|||
return sqrt(sqr(_c1_r - _c2_r) + sqr(_c1_g - _c2_g) + sqr(_c1_b - _c2_b) + sqr(_c1_a - _c2_a));
|
||||
} #endregion
|
||||
|
||||
function color_get_brightness(col) { #region
|
||||
INLINE
|
||||
return (0.299 * color_get_red(col) + 0.587 * color_get_green(col) + 0.114 * color_get_blue(col)) / 255;
|
||||
} #endregion
|
||||
#region merge
|
||||
#macro merge_color merge_color_ext
|
||||
#macro __merge_color merge_color
|
||||
|
||||
function color_rgb(col) { #region
|
||||
INLINE
|
||||
return [ color_get_red(col) / 255, color_get_green(col) / 255, color_get_blue(col) / 255 ];
|
||||
} #endregion
|
||||
|
||||
function make_color_rgba(r, g, b, a) { INLINE return int64(round(r) + (round(g) << 8) + (round(b) << 16) + (round(a) << 24)); }
|
||||
function make_color_hsva(h, s, v, a) { INLINE return _cola(make_color_hsv(h, s, v), a); }
|
||||
|
||||
#macro merge_color merge_color_ext
|
||||
#macro __merge_color merge_color
|
||||
|
||||
function merge_color_ext(c0, c1, t) { #region
|
||||
function merge_color_ext(c0, c1, t) { #region
|
||||
INLINE
|
||||
if(is_real(c0)) return __merge_color(c0, c1, t);
|
||||
|
||||
|
@ -130,9 +178,9 @@ function merge_color_ext(c0, c1, t) { #region
|
|||
clamp(round(lerp(color_get_blue(c0), color_get_blue(c1), t)), 0, 255),
|
||||
clamp(round(lerp(color_get_alpha(c0), color_get_alpha(c1), t)), 0, 255),
|
||||
);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
function merge_color_hsv(c0, c1, t) { #region
|
||||
function merge_color_hsv(c0, c1, t) { #region
|
||||
INLINE
|
||||
if(is_real(c0)) return make_color_hsv(
|
||||
clamp(round(lerp(color_get_hue(c0), color_get_hue(c1), t)), 0, 255),
|
||||
|
@ -146,7 +194,25 @@ function merge_color_hsv(c0, c1, t) { #region
|
|||
clamp(round(lerp(color_get_value(c0), color_get_value(c1), t)), 0, 255),
|
||||
clamp(round(lerp(color_get_alpha(c0), color_get_alpha(c1), t)), 0, 255),
|
||||
);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
function merge_color_oklab(c0, c1, t) { #region
|
||||
INLINE
|
||||
|
||||
var ok0 = color_oklab(c0);
|
||||
var ok1 = color_oklab(c1);
|
||||
|
||||
var ok = [
|
||||
lerp(ok0[0], ok1[0], t),
|
||||
lerp(ok0[1], ok1[1], t),
|
||||
lerp(ok0[2], ok1[2], t),
|
||||
];
|
||||
|
||||
var a = is_real(c0)? 255 : clamp(round(lerp(color_get_alpha(c0), color_get_alpha(c1), t)), 0, 255);
|
||||
|
||||
return make_color_oklab(ok, a);
|
||||
} #endregion
|
||||
#endregion
|
||||
|
||||
#region sorting functions
|
||||
function __valHSV(c, h, s, v) { return color_get_hue(c) * h + color_get_saturation(c) * s + color_get_value(c) * v; }
|
||||
|
|
|
@ -16,8 +16,6 @@ function __rot3(_x = 0, _y = 0, _z = 0) constructor {
|
|||
var _y = degtorad( y);
|
||||
var _z = degtorad(-z);
|
||||
|
||||
var rotationMatrix = new __mat3();
|
||||
|
||||
var cosX = cos(_x);
|
||||
var sinX = sin(_x);
|
||||
var cosY = cos(_y);
|
||||
|
@ -25,15 +23,9 @@ function __rot3(_x = 0, _y = 0, _z = 0) constructor {
|
|||
var cosZ = cos(_z);
|
||||
var sinZ = sin(_z);
|
||||
|
||||
rotationMatrix.raw[0][0] = cosY * cosZ;
|
||||
rotationMatrix.raw[0][1] = -cosX * sinZ + sinX * sinY * cosZ;
|
||||
rotationMatrix.raw[0][2] = sinX * sinZ + cosX * sinY * cosZ;
|
||||
rotationMatrix.raw[1][0] = cosY * sinZ;
|
||||
rotationMatrix.raw[1][1] = cosX * cosZ + sinX * sinY * sinZ;
|
||||
rotationMatrix.raw[1][2] = -sinX * cosZ + cosX * sinY * sinZ;
|
||||
rotationMatrix.raw[2][0] = -sinY;
|
||||
rotationMatrix.raw[2][1] = sinX * cosY;
|
||||
rotationMatrix.raw[2][2] = cosX * cosY;
|
||||
var rotationMatrix = new __mat3([ cosY * cosZ, -cosX * sinZ + sinX * sinY * cosZ, sinX * sinZ + cosX * sinY * cosZ,
|
||||
cosY * sinZ, cosX * cosZ + sinX * sinY * sinZ, -sinX * cosZ + cosX * sinY * sinZ,
|
||||
-sinY, sinX * cosY, cosX * cosY ]);
|
||||
|
||||
var initialVector = new __vec3(1, 0, 0);
|
||||
var rotatedVector = rotationMatrix.multiplyVector(initialVector);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
enum GRADIENT_INTER {
|
||||
smooth,
|
||||
none,
|
||||
hue
|
||||
hue,
|
||||
oklab
|
||||
}
|
||||
|
||||
function gradientKey(time, value) constructor { #region
|
||||
|
@ -76,7 +77,8 @@ function gradientObject(color = c_black) constructor { #region
|
|||
|
||||
switch(type) {
|
||||
case GRADIENT_INTER.smooth : return merge_color (_pkey.value, _key.value, rat);
|
||||
case GRADIENT_INTER.hue : return merge_color_hsv(_pkey.value, _key.value, rat);
|
||||
case GRADIENT_INTER.hue : return merge_color_hsv (_pkey.value, _key.value, rat);
|
||||
case GRADIENT_INTER.oklab : return merge_color_oklab(_pkey.value, _key.value, rat);
|
||||
case GRADIENT_INTER.none : return _pkey.value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ function Node_3D_Mesh_Terrain(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _gr
|
|||
for( var i = 0; i < _sub + 1; i++ )
|
||||
for( var j = 0; j < _sub + 1; j++ ) {
|
||||
var cc = surface_getpixel(_his, j * _pxw, i * _pxh);
|
||||
_h[_ind] = color_get_brightness(cc);
|
||||
_h[_ind] = colorBrightness(cc);
|
||||
_ind++;
|
||||
}
|
||||
} else if(_inT == 1 && !array_empty(_hia)) {
|
||||
|
|
|
@ -10,7 +10,7 @@ function Node_Color_Mix(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
.setDisplay(VALUE_DISPLAY.slider);
|
||||
|
||||
inputs[| 3] = nodeValue("Color space", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "RGB", "HSV" ]);
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "RGB", "HSV", "OKLAB" ]);
|
||||
|
||||
outputs[| 0] = nodeValue("Color", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, c_white);
|
||||
|
||||
|
@ -20,6 +20,7 @@ function Node_Color_Mix(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
switch(_data[3]) {
|
||||
case 0 : return merge_color_ext(_data[0], _data[1], _data[2]);
|
||||
case 1 : return merge_color_hsv(_data[0], _data[1], _data[2]);
|
||||
case 2 : return merge_color_oklab(_data[0], _data[1], _data[2]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ function Node_Displace(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
|
||||
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
|
||||
|
||||
inputs[| 1] = nodeValue("Displace map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
|
||||
inputs[| 1] = nodeValue("Displace map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
|
||||
|
||||
inputs[| 2] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [1, 0], "Vector to displace pixel by." )
|
||||
inputs[| 2] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 0 ], "Vector to displace pixel by." )
|
||||
.setDisplay(VALUE_DISPLAY.vector)
|
||||
.setUnitRef(function(index) { return getDimension(index); });
|
||||
|
||||
|
@ -15,11 +15,11 @@ function Node_Displace(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
inputs[| 4] = nodeValue("Mid value", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0., "Brightness value to be use as a basis for 'no displacement'.")
|
||||
.setDisplay(VALUE_DISPLAY.slider);
|
||||
|
||||
inputs[| 5] = nodeValue("Color data", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0, @"Use color data set extra information.
|
||||
- Ignore: Don't use color data.
|
||||
inputs[| 5] = nodeValue("Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0, @"Use color data for extra information.
|
||||
- Linear: Displace along a line.
|
||||
- Vector: Use red as X displacement, green as Y displacement.
|
||||
- Angle: Use red as angle, green as distance.")
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "Ignore", "Vector", "Angle" ]);
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "Linear", "Vector", "Angle" ]);
|
||||
|
||||
inputs[| 6] = nodeValue("Iterate", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false, @"If not set, then strength value is multiplied directly to the displacement.
|
||||
If set, then strength value control how many times the effect applies on itself.");
|
||||
|
@ -50,10 +50,14 @@ If set, then strength value control how many times the effect applies on itself.
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inputs[| 16] = nodeValue("Separate axis", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||
|
||||
inputs[| 17] = nodeValue("Displace map 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
|
||||
|
||||
input_display_list = [ 10, 12,
|
||||
["Surfaces", true], 0, 8, 9, 13, 14,
|
||||
["Displace", false], 1, 3, 15, 4,
|
||||
["Color", false], 5, 2,
|
||||
["Strength", false], 1, 17, 3, 15, 4,
|
||||
["Displacement", false], 5, 16, 2,
|
||||
["Algorithm", true], 6, 11,
|
||||
];
|
||||
|
||||
|
@ -65,9 +69,26 @@ If set, then strength value control how many times the effect applies on itself.
|
|||
|
||||
static step = function() { #region
|
||||
__step_mask_modifier();
|
||||
|
||||
inputs[| 2].setVisible(getInputData(5) == 0);
|
||||
inputs[| 3].mappableStep();
|
||||
|
||||
var _mode = getInputData(5);
|
||||
var _sep = getInputData(16);
|
||||
|
||||
inputs[| 2].setVisible(_mode == 0);
|
||||
inputs[| 16].setVisible(_mode);
|
||||
inputs[| 17].setVisible(_mode && _sep);
|
||||
|
||||
if(_mode == 1 && _sep) {
|
||||
inputs[| 1].setName("Displace X");
|
||||
inputs[| 17].setName("Displace Y");
|
||||
|
||||
} else if(_mode == 2 && _sep) {
|
||||
inputs[| 1].setName("Displace angle");
|
||||
inputs[| 17].setName("Displace amount");
|
||||
|
||||
} else {
|
||||
inputs[| 1].setName("Displace map");
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
|
||||
|
@ -79,14 +100,17 @@ If set, then strength value control how many times the effect applies on itself.
|
|||
surface_set_shader(_outSurf, sh_displace);
|
||||
shader_set_interpolation(_data[0]);
|
||||
shader_set_surface("map", _data[1]);
|
||||
shader_set_surface("map2", _data[17]);
|
||||
|
||||
shader_set_f("dimension", [ww, hh]);
|
||||
shader_set_f("map_dimension", [mw, mh]);
|
||||
shader_set_f("displace", _data[ 2]);
|
||||
shader_set_f_map("strength", _data[ 3], _data[15], inputs[| 3]);
|
||||
shader_set_f("middle", _data[ 4]);
|
||||
shader_set_i("use_rg", _data[ 5]);
|
||||
shader_set_i("mode", _data[ 5]);
|
||||
shader_set_i("iterate", _data[ 6]);
|
||||
shader_set_i("blendMode", _data[11]);
|
||||
shader_set_i("sepAxis", _data[16]);
|
||||
draw_surface_safe(_data[0]);
|
||||
surface_reset_shader();
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ function Node_Gradient_Palette(_x, _y, _group = noone) : Node_Processor(_x, _y,
|
|||
.setVisible(true, true);
|
||||
inputs[| 2].array_depth = 1;
|
||||
|
||||
inputs[| 3] = nodeValue("Blending", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "RGB", "HSV", "Hard" ]);
|
||||
inputs[| 3] = nodeValue("Blending", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1)
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "Hard", "RGB", "HSV", "OKLAB" ]);
|
||||
|
||||
outputs[| 0] = nodeValue("Gradient", self, JUNCTION_CONNECT.output, VALUE_TYPE.gradient, new gradientObject(c_white) )
|
||||
|
||||
|
@ -42,9 +42,10 @@ function Node_Gradient_Palette(_x, _y, _group = noone) : Node_Processor(_x, _y,
|
|||
}
|
||||
|
||||
switch(type) {
|
||||
case 0 : grad.type = GRADIENT_INTER.smooth; break;
|
||||
case 1 : grad.type = GRADIENT_INTER.hue; break;
|
||||
case 2 : grad.type = GRADIENT_INTER.none; break;
|
||||
case 0 : grad.type = GRADIENT_INTER.none; break;
|
||||
case 1 : grad.type = GRADIENT_INTER.smooth; break;
|
||||
case 2 : grad.type = GRADIENT_INTER.hue; break;
|
||||
case 3 : grad.type = GRADIENT_INTER.oklab; break;
|
||||
}
|
||||
|
||||
return grad;
|
||||
|
|
93
scripts/node_quasicrystal/node_quasicrystal.gml
Normal file
|
@ -0,0 +1,93 @@
|
|||
function Node_Quasicrystal(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
name = "Quasicrystal";
|
||||
|
||||
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
|
||||
.setDisplay(VALUE_DISPLAY.vector);
|
||||
|
||||
inputs[| 1] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 16)
|
||||
.setDisplay(VALUE_DISPLAY.slider, { range: [1, 64, 0.1] })
|
||||
.setMappable(6);
|
||||
|
||||
inputs[| 2] = nodeValue("Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.rotation)
|
||||
.setMappable(7);
|
||||
|
||||
inputs[| 3] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 0, 0 ] )
|
||||
.setDisplay(VALUE_DISPLAY.vector)
|
||||
.setUnitRef(function(index) { return getDimension(index); });
|
||||
|
||||
inputs[| 4] = nodeValue("Color 1", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
|
||||
|
||||
inputs[| 5] = nodeValue("Color 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inputs[| 6] = nodeValueMap("Scale map", self);
|
||||
|
||||
inputs[| 7] = nodeValueMap("Angle map", self);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inputs[| 8] = nodeValue("Phase", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
|
||||
.setDisplay(VALUE_DISPLAY.slider)
|
||||
.setMappable(8);
|
||||
|
||||
inputs[| 9] = nodeValueMap("Phasemap", self);
|
||||
|
||||
inputs[| 10] = nodeValue("Angle Range", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 0, 180 ])
|
||||
.setDisplay(VALUE_DISPLAY.rotation_range);
|
||||
|
||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||
|
||||
input_display_list = [
|
||||
["Output", true], 0,
|
||||
["Pattern", false], 1, 6, 2, 7, 8, 9, 10,
|
||||
["Colors", false], 4, 5,
|
||||
];
|
||||
|
||||
attribute_surface_depth();
|
||||
|
||||
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
||||
var pos = getInputData(3);
|
||||
var px = _x + pos[0] * _s;
|
||||
var py = _y + pos[1] * _s;
|
||||
|
||||
var a = inputs[| 3].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); active &= !a;
|
||||
var a = inputs[| 2].drawOverlay(active, px, py, _s, _mx, _my, _snx, _sny); active &= !a;
|
||||
} #endregion
|
||||
|
||||
static step = function() { #region
|
||||
inputs[| 1].mappableStep();
|
||||
inputs[| 2].mappableStep();
|
||||
inputs[| 8].mappableStep();
|
||||
} #endregion
|
||||
|
||||
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
|
||||
var _dim = _data[ 0];
|
||||
var _fre = _data[ 1];
|
||||
var _ang = _data[ 2];
|
||||
var _pos = _data[ 3];
|
||||
var _clr0 = _data[ 4];
|
||||
var _clr1 = _data[ 5];
|
||||
var _aran = _data[10];
|
||||
|
||||
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
|
||||
|
||||
surface_set_shader(_outSurf, sh_quarsicrystal);
|
||||
shader_set_f("dimension", _dim[0], _dim[1]);
|
||||
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
|
||||
shader_set_f("rangleRange", _aran);
|
||||
|
||||
shader_set_f_map("amount", _data[1], _data[6], inputs[| 1]);
|
||||
shader_set_f_map("angle", _data[2], _data[7], inputs[| 2]);
|
||||
shader_set_f_map("phase", _data[8], _data[9], inputs[| 8]);
|
||||
|
||||
shader_set_color("color0", _clr0);
|
||||
shader_set_color("color1", _clr1);
|
||||
|
||||
draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
|
||||
surface_reset_shader();
|
||||
|
||||
return _outSurf;
|
||||
} #endregion
|
||||
}
|
11
scripts/node_quasicrystal/node_quasicrystal.yy
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"resourceType": "GMScript",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "node_quasicrystal",
|
||||
"isCompatibility": false,
|
||||
"isDnD": false,
|
||||
"parent": {
|
||||
"name": "pattern",
|
||||
"path": "folders/nodes/data/generator/pattern.yy",
|
||||
},
|
||||
}
|
|
@ -538,7 +538,7 @@ function __initNodes() {
|
|||
addNodeObject(filter, "Chromatic Aberration", s_node_chromatic_abarration, "Node_Chromatic_Aberration", [1, Node_Chromatic_Aberration],, "Apply chromatic aberration effect to the image.");
|
||||
addNodeObject(filter, "Vignette", s_node_vignette, "Node_Vignette", [1, Node_Vignette],, "Apply vignette effect to the border.").setVersion(11630);
|
||||
addNodeObject(filter, "FXAA", s_node_FXAA, "Node_FXAA", [1, Node_FXAA],, "Apply fast approximate anti-aliasing to the image.");
|
||||
addNodeObject(filter, "Kuwahara", s_node_kuwahara, "Node_Kuwahara", [1, Node_Kuwahara]);
|
||||
addNodeObject(filter, "Kuwahara", s_node_kuwahara, "Node_Kuwahara", [1, Node_Kuwahara]).setVersion(11660);
|
||||
//addNodeObject(filter, "Blend Edge", s_node_FXAA, "Node_Blend_Edge", [1, Node_Blend_Edge]).setVersion(11640);
|
||||
|
||||
ds_list_add(filter, "Colors");
|
||||
|
@ -657,6 +657,7 @@ function __initNodes() {
|
|||
addNodeObject(generator, "Pytagorean Tile", s_node_pytagorean_tile, "Node_Pytagorean_Tile", [1, Node_Pytagorean_Tile],, "Generate Pytagorean tile pattern.").patreonExtra();
|
||||
addNodeObject(generator, "Herringbone Tile", s_node_herringbone_tile, "Node_Herringbone_Tile", [1, Node_Herringbone_Tile],, "Generate Herringbone tile pattern.").patreonExtra();
|
||||
addNodeObject(generator, "Random Tile", s_node_random_tile, "Node_Random_Tile", [1, Node_Random_Tile],, "Generate Random tile pattern.").patreonExtra();
|
||||
addNodeObject(generator, "Quasicrystal", s_node_random_tile, "Node_Quasicrystal", [1, Node_Quasicrystal]).setVersion(11660);
|
||||
|
||||
ds_list_add(generator, "Populate");
|
||||
addNodeObject(generator, "Repeat", s_node_repeat, "Node_Repeat", [1, Node_Repeat],, "Repeat image multiple times linearly, or in grid pattern.").setVersion(1100);
|
||||
|
|
|
@ -478,7 +478,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
|
|||
case 1 : ind = safe_mod(i, _arrLen); break;
|
||||
case 2 : ind = irandom(_arrLen - 1); break;
|
||||
case 3 : ind = array_safe_get(arrId, i, 0); break;
|
||||
case 4 : if(useArrTex) ind = color_get_brightness(surface_get_pixel(arrTex, _x, _y)) * (_arrLen - 1); break;
|
||||
case 4 : if(useArrTex) ind = colorBrightness(surface_get_pixel(arrTex, _x, _y)) * (_arrLen - 1); break;
|
||||
}
|
||||
|
||||
if(arrAnim[0] != 0 || arrAnim[1] != 0) {
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
function rotatorRandom(_onModify) : widget() constructor {
|
||||
onModify = _onModify;
|
||||
|
||||
dragging = false;
|
||||
dragging_index = -1;
|
||||
dragging = false;
|
||||
drag_sv = 0;
|
||||
drag_dat = [ 0, 0, 0, 0, 0 ];
|
||||
|
||||
knob_hovering = noone;
|
||||
|
||||
mode = 0;
|
||||
tb_min_0 = new textBox(TEXTBOX_INPUT.number, function(val) { return onModify(1, val); } ).setSlidable(true, 1);
|
||||
tb_max_0 = new textBox(TEXTBOX_INPUT.number, function(val) { return onModify(2, val); } ).setSlidable(true, 1);
|
||||
|
@ -46,6 +48,8 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
w = _w;
|
||||
h = ui(80);
|
||||
|
||||
var _kHover = dragging_index;
|
||||
|
||||
_x += _w / 2;
|
||||
|
||||
mode = _data[0];
|
||||
|
@ -111,7 +115,7 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
draw_arc_width(knx, kny, _r, 3, _a0, _a1);
|
||||
|
||||
for(var i = 0; i < 2; i++)
|
||||
draw_sprite(THEME.rotator_knob, 0, px[i], py[i]);
|
||||
draw_sprite(THEME.rotator_knob, i == knob_hovering, px[i], py[i]);
|
||||
#endregion
|
||||
|
||||
if(dragging_index > -1) { #region
|
||||
|
@ -139,8 +143,6 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
var curr_val = round(dragging.delta_acc + drag_sv);
|
||||
val = key_mod_press(CTRL)? round(curr_val / 15) * 15 : curr_val;
|
||||
|
||||
draw_sprite(THEME.rotator_knob, 1, px[dragging_index], py[dragging_index]);
|
||||
|
||||
if(_data[dragging_index] != val) {
|
||||
var modi = false;
|
||||
modi |= onModify(1 + dragging_index, val);
|
||||
|
@ -175,7 +177,7 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
|
||||
for(var i = 0; i < 2; i++) {
|
||||
if(point_in_circle(_m[0], _m[1], px[i], py[i], ui(20))) {
|
||||
draw_sprite(THEME.rotator_knob, 1, px[i], py[i]);
|
||||
_kHover = i;
|
||||
|
||||
if(mouse_press(mb_left, active)) {
|
||||
dragging_index = i;
|
||||
|
@ -221,7 +223,7 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
draw_arc_width(knx, kny, _r, 3, _a0, _a1);
|
||||
|
||||
for( var i = 0; i < 3; i++ )
|
||||
draw_sprite(THEME.rotator_knob, 0, px[i], py[i]);
|
||||
draw_sprite(THEME.rotator_knob, i == knob_hovering, px[i], py[i]);
|
||||
#endregion
|
||||
|
||||
if(dragging_index > -1) { #region
|
||||
|
@ -235,15 +237,11 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
real_val[1] = round(dragging.delta_acc + drag_sv[1]);
|
||||
val = key_mod_press(CTRL)? round(real_val[1] / 15) * 15 : real_val[1];
|
||||
|
||||
draw_sprite(THEME.rotator_knob, 1, px[2], py[2]);
|
||||
|
||||
if(onModify(1, val)) UNDO_HOLDING = true;
|
||||
} else {
|
||||
real_val[2] = round(drag_sv[2] + (dragging.delta_acc * (dragging_index? 1 : -1)));
|
||||
val = key_mod_press(CTRL)? round(real_val[2] / 15) * 15 : real_val[2];
|
||||
|
||||
draw_sprite(THEME.rotator_knob, 1, px[dragging_index], py[dragging_index]);
|
||||
|
||||
if(onModify(2, val)) UNDO_HOLDING = true;
|
||||
}
|
||||
|
||||
|
@ -267,7 +265,7 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
} else if(hover) { #region
|
||||
for(var i = 0; i < 3; i++) {
|
||||
if(point_in_circle(_m[0], _m[1], px[i], py[i], ui(20))) {
|
||||
draw_sprite(THEME.rotator_knob, 1, px[i], py[i]);
|
||||
_kHover = i;
|
||||
|
||||
if(mouse_press(mb_left, active)) {
|
||||
dragging_index = i;
|
||||
|
@ -314,7 +312,7 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
draw_arc_width(knx, kny, _r, 3, _a2, _a3);
|
||||
|
||||
for( var i = 0; i < 4; i++ )
|
||||
draw_sprite(THEME.rotator_knob, 0, px[i], py[i]);
|
||||
draw_sprite(THEME.rotator_knob, i == knob_hovering, px[i], py[i]);
|
||||
#endregion
|
||||
|
||||
if(dragging_index > -1) { #region
|
||||
|
@ -328,8 +326,6 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
real_val[ind] = round(drag_sv[ind] + (dragging.delta_acc * (ind? 1 : -1)));
|
||||
val = key_mod_press(CTRL)? round(real_val[ind] / 15) * 15 : real_val[ind];
|
||||
|
||||
draw_sprite(THEME.rotator_knob, 1, px[dragging_index], py[dragging_index]);
|
||||
|
||||
if(onModify(ind, val)) UNDO_HOLDING = true;
|
||||
|
||||
MOUSE_BLOCK = true;
|
||||
|
@ -352,7 +348,7 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
} else if(hover) { #region
|
||||
for(var i = 0; i < 4; i++) {
|
||||
if(point_in_circle(_m[0], _m[1], px[i], py[i], ui(20))) {
|
||||
draw_sprite(THEME.rotator_knob, 1, px[i], py[i]);
|
||||
_kHover = i;
|
||||
|
||||
if(mouse_press(mb_left, active)) {
|
||||
dragging_index = i;
|
||||
|
@ -405,8 +401,8 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
draw_arc_width(knx, kny, _r, 3, _a2, _a3);
|
||||
draw_arc_width(knx, kny, _r, 3, _a4, _a5);
|
||||
|
||||
draw_sprite(THEME.rotator_knob, 0, px[0], py[0]);
|
||||
draw_sprite(THEME.rotator_knob, 0, px[1], py[1]);
|
||||
for( var i = 0; i < 2; i++ )
|
||||
draw_sprite(THEME.rotator_knob, i == knob_hovering, px[i], py[i]);
|
||||
#endregion
|
||||
|
||||
if(dragging_index > -1) { #region
|
||||
|
@ -420,8 +416,6 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
real_val[ind] = round(drag_sv[ind] + (dragging.delta_acc * (ind? 1 : -1)));
|
||||
val = key_mod_press(CTRL)? round(real_val[ind] / 15) * 15 : real_val[ind];
|
||||
|
||||
draw_sprite(THEME.rotator_knob, 1, px[dragging_index], py[dragging_index]);
|
||||
|
||||
if(onModify(ind, val)) UNDO_HOLDING = true;
|
||||
|
||||
MOUSE_BLOCK = true;
|
||||
|
@ -444,7 +438,7 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
} else if(hover) { #region
|
||||
for(var i = 0; i < 2; i++) {
|
||||
if(point_in_circle(_m[0], _m[1], px[i], py[i], ui(20))) {
|
||||
draw_sprite(THEME.rotator_knob, 1, px[i], py[i]);
|
||||
_kHover = i;
|
||||
|
||||
if(mouse_press(mb_left, active)) {
|
||||
dragging_index = i;
|
||||
|
@ -459,6 +453,7 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
break;
|
||||
}
|
||||
|
||||
knob_hovering = _kHover;
|
||||
resetFocus();
|
||||
|
||||
return h;
|
||||
|
|
|
@ -6,6 +6,8 @@ function rotatorRange(_onModify) : widget() constructor {
|
|||
drag_sv = 0;
|
||||
drag_dat = [ 0, 0 ];
|
||||
|
||||
knob_hovering = noone;
|
||||
|
||||
tb_min = new textBox(TEXTBOX_INPUT.number, function(val) { return onModify(0, val); } ).setSlidable();
|
||||
|
||||
tb_max = new textBox(TEXTBOX_INPUT.number, function(val) { return onModify(1, val); } ).setSlidable();
|
||||
|
@ -31,6 +33,7 @@ function rotatorRange(_onModify) : widget() constructor {
|
|||
w = _w;
|
||||
h = ui(64);
|
||||
|
||||
knob_hovering = dragging_index;
|
||||
_x += _w / 2;
|
||||
|
||||
if(!is_real(_data[0])) return;
|
||||
|
@ -73,9 +76,6 @@ function rotatorRange(_onModify) : widget() constructor {
|
|||
draw_arc_forward(_x, knob_y, _r, 3, _data[0], _data[1]);
|
||||
#endregion
|
||||
|
||||
for(var i = 0; i < 2; i++)
|
||||
draw_sprite(THEME.rotator_knob, 0, px[i], py[i]);
|
||||
|
||||
if(dragging_index > -1) { #region
|
||||
var val = point_direction(_x, knob_y, _m[0], _m[1]);
|
||||
if(key_mod_press(CTRL)) val = round(val / 15) * 15;
|
||||
|
@ -100,8 +100,6 @@ function rotatorRange(_onModify) : widget() constructor {
|
|||
real_val = round(dragging.delta_acc + drag_sv);
|
||||
val = key_mod_press(CTRL)? round(real_val / 15) * 15 : real_val;
|
||||
|
||||
draw_sprite(THEME.rotator_knob, 1, px[dragging_index], py[dragging_index]);
|
||||
|
||||
if(_data[dragging_index] != val) {
|
||||
var modi = false;
|
||||
modi |= onModify(dragging_index, val);
|
||||
|
@ -132,10 +130,11 @@ function rotatorRange(_onModify) : widget() constructor {
|
|||
UNDO_HOLDING = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
} else if(hover) { #region
|
||||
for(var i = 0; i < 2; i++) {
|
||||
if(point_in_circle(_m[0], _m[1], px[i], py[i], ui(20))) {
|
||||
draw_sprite(THEME.rotator_knob, 1, px[i], py[i]);
|
||||
knob_hovering = i;
|
||||
|
||||
if(mouse_press(mb_left, active)) {
|
||||
dragging_index = i;
|
||||
|
@ -153,6 +152,9 @@ function rotatorRange(_onModify) : widget() constructor {
|
|||
}
|
||||
} #endregion
|
||||
|
||||
for(var i = 0; i < 2; i++)
|
||||
draw_sprite(THEME.rotator_knob, knob_hovering == i, px[i], py[i]);
|
||||
|
||||
resetFocus();
|
||||
|
||||
return h;
|
||||
|
|
|
@ -1,22 +1,55 @@
|
|||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
#define GRADIENT_LIMIT 128
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
uniform int multiply_alpha;
|
||||
|
||||
uniform vec2 gradient_shift;
|
||||
uniform int gradient_shiftUseSurf;
|
||||
uniform sampler2D gradient_shiftSurf;
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
@ -26,19 +59,19 @@ vec3 rgb2hsv(vec3 c) { #region
|
|||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
} #endregion
|
||||
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float da = fract(a1 - a0);
|
||||
float ds = fract(2. * da) - da;
|
||||
return a0 + ds * t;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 h1 = rgb2hsv(c1);
|
||||
vec3 h2 = rgb2hsv(c2);
|
||||
|
||||
|
@ -48,9 +81,9 @@ vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
|||
h.z = mix(h1.z, h2.z, t);
|
||||
|
||||
return hsv2rgb(h);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
if(gradient_use_map == 1) {
|
||||
vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog);
|
||||
return texture2D( gradient_map, samplePos );
|
||||
|
@ -67,12 +100,16 @@ vec4 gradientEval(in float prog) { #region
|
|||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -83,7 +120,9 @@ vec4 gradientEval(in float prog) { #region
|
|||
}
|
||||
|
||||
return col;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
void main() { #region
|
||||
float shf = gradient_shift.x;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
//
|
||||
// Simple passthrough fragment shader
|
||||
//
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
uniform sampler2D map;
|
||||
uniform sampler2D map2;
|
||||
|
||||
uniform vec2 dimension;
|
||||
uniform vec2 map_dimension;
|
||||
uniform vec2 displace;
|
||||
uniform float middle;
|
||||
uniform int iterate;
|
||||
uniform int use_rg;
|
||||
uniform int mode;
|
||||
uniform int sampleMode;
|
||||
uniform int blendMode;
|
||||
uniform int sepAxis;
|
||||
|
||||
uniform vec2 strength;
|
||||
uniform int strengthUseSurf;
|
||||
|
@ -87,14 +87,31 @@ vec2 shiftMap(in vec2 pos, in float str) { #region
|
|||
vec2 sam_pos;
|
||||
vec2 raw_displace = displace / dimension;
|
||||
float _str;
|
||||
vec2 _disp;
|
||||
|
||||
if(use_rg == 1) {
|
||||
vec2 _disp = vec2(disP.r - middle, disP.g - middle) * vec2((disP.r + disP.g + disP.b) / 3. - middle) * str;
|
||||
if(mode == 1) {
|
||||
if(sepAxis == 0)
|
||||
_disp = vec2(disP.r - middle, disP.g - middle) * vec2((disP.r + disP.g + disP.b) / 3. - middle) * str;
|
||||
else if(sepAxis == 1) {
|
||||
vec4 disP2 = texture2Dintp( map2, pos );
|
||||
|
||||
_disp.x = (bright(disP) - middle) * str;
|
||||
_disp.y = (bright(disP2) - middle) * str;
|
||||
}
|
||||
|
||||
sam_pos = pos + _disp;
|
||||
} else if(use_rg == 2) {
|
||||
float _ang = disP.r * PI * 2.;
|
||||
} else if(mode == 2) {
|
||||
float _ang;
|
||||
|
||||
if(sepAxis == 0) {
|
||||
_ang = disP.r * PI * 2.;
|
||||
_str = (disP.g - middle) * str;
|
||||
} else if(sepAxis == 1) {
|
||||
vec4 disP2 = texture2Dintp( map2, pos );
|
||||
|
||||
_ang = bright(disP) * PI * 2.;
|
||||
_str = (bright(disP2) - middle) * str;
|
||||
}
|
||||
|
||||
sam_pos = pos + _str * vec2(cos(_ang), sin(_ang));
|
||||
} else {
|
||||
|
|
|
@ -3,7 +3,7 @@ varying vec4 v_vColour;
|
|||
|
||||
uniform vec2 dimension;
|
||||
|
||||
#region ////////////////////////////////////////////////////////////////// GRADIENT //////////////////////////////////////////////////////////////////
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform int gradient_blend;
|
||||
|
@ -14,6 +14,37 @@ uniform vec2 dimension;
|
|||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
|
@ -65,15 +96,16 @@ uniform vec2 dimension;
|
|||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(
|
||||
hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t),
|
||||
mix(gradient_color[i - 1].a, gradient_color[i].a, t)
|
||||
);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -85,7 +117,8 @@ uniform vec2 dimension;
|
|||
|
||||
return col;
|
||||
} #endregion
|
||||
#endregion ////////////////////////////////////////////////////////////////// GRADIENT //////////////////////////////////////////////////////////////////
|
||||
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
void main() {
|
||||
vec2 tx = 1. / dimension;
|
||||
|
|
|
@ -29,18 +29,49 @@ uniform int type;
|
|||
uniform int gradient_loop;
|
||||
uniform int uniAsp;
|
||||
|
||||
#region ////////////////////////////////////////// GRADIENT BEGIN //////////////////////////////////////////
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
#define GRADIENT_LIMIT 128
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
vec3 rgb2hsv(vec3 c) {
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
@ -48,21 +79,21 @@ vec3 rgb2hsv(vec3 c) {
|
|||
float d = q.x - min(q.w, q.y);
|
||||
float e = 0.0000000001;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec3 hsv2rgb(vec3 c) {
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
float hueDist(float a0, float a1, float t) {
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float da = fract(a1 - a0);
|
||||
float ds = fract(2. * da) - da;
|
||||
return a0 + ds * t;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) {
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 h1 = rgb2hsv(c1);
|
||||
vec3 h2 = rgb2hsv(c2);
|
||||
|
||||
|
@ -72,50 +103,48 @@ vec3 hsvMix(vec3 c1, vec3 c2, float t) {
|
|||
h.z = mix(h1.z, h2.z, t);
|
||||
|
||||
return hsv2rgb(h);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec4 gradientEval(in float prog) {
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
if(gradient_use_map == 1) {
|
||||
vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog);
|
||||
return texture2D( gradient_map, samplePos );
|
||||
}
|
||||
|
||||
vec4 col = vec4(0.);
|
||||
float _ptime = 0.;
|
||||
|
||||
for(int i = 0; i < GRADIENT_LIMIT; i++) {
|
||||
if(i >= gradient_keys) {
|
||||
col = gradient_color[i - 1];
|
||||
break;
|
||||
}
|
||||
|
||||
float _time = gradient_time[i];
|
||||
|
||||
if(_time == prog) {
|
||||
if(gradient_time[i] == prog) {
|
||||
col = gradient_color[i];
|
||||
break;
|
||||
} else if(_time > prog) {
|
||||
} else if(gradient_time[i] > prog) {
|
||||
if(i == 0)
|
||||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - _ptime) / (_time - _ptime);
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
_ptime = _time;
|
||||
if(i >= gradient_keys - 1) {
|
||||
col = gradient_color[gradient_keys - 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return col;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
#endregion ////////////////////////////////////////// GRADIENT END //////////////////////////////////////////
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
void main() {
|
||||
#region params
|
||||
|
|
|
@ -1,18 +1,48 @@
|
|||
//
|
||||
// Simple passthrough fragment shader
|
||||
//
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
#define TAU 6.283185307179586
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
vec3 rgb2hsv(vec3 c) {
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
@ -20,21 +50,21 @@ vec3 rgb2hsv(vec3 c) {
|
|||
float d = q.x - min(q.w, q.y);
|
||||
float e = 0.0000000001;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec3 hsv2rgb(vec3 c) {
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
float hueDist(float a0, float a1, float t) {
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float da = fract(a1 - a0);
|
||||
float ds = fract(2. * da) - da;
|
||||
return a0 + ds * t;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) {
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 h1 = rgb2hsv(c1);
|
||||
vec3 h2 = rgb2hsv(c2);
|
||||
|
||||
|
@ -44,9 +74,9 @@ vec3 hsvMix(vec3 c1, vec3 c2, float t) {
|
|||
h.z = mix(h1.z, h2.z, t);
|
||||
|
||||
return hsv2rgb(h);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec4 gradientEval(in float prog) {
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
vec4 col = vec4(0.);
|
||||
|
||||
for(int i = 0; i < GRADIENT_LIMIT; i++) {
|
||||
|
@ -58,15 +88,16 @@ vec4 gradientEval(in float prog) {
|
|||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(
|
||||
hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t),
|
||||
mix(gradient_color[i - 1].a, gradient_color[i].a, t)
|
||||
);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -76,7 +107,9 @@ vec4 gradientEval(in float prog) {
|
|||
}
|
||||
|
||||
return col;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
void main() {
|
||||
vec4 col = gradientEval(v_vTexcoord.x);
|
||||
|
|
|
@ -1,18 +1,48 @@
|
|||
//
|
||||
// Simple passthrough fragment shader
|
||||
//
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
#define TAU 6.283185307179586
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
@ -20,21 +50,21 @@ vec3 rgb2hsv(vec3 c) { #region
|
|||
float d = q.x - min(q.w, q.y);
|
||||
float e = 0.0000000001;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float da = fract(a1 - a0);
|
||||
float ds = fract(2. * da) - da;
|
||||
return a0 + ds * t;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 h1 = rgb2hsv(c1);
|
||||
vec3 h2 = rgb2hsv(c2);
|
||||
|
||||
|
@ -44,9 +74,9 @@ vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
|||
h.z = mix(h1.z, h2.z, t);
|
||||
|
||||
return hsv2rgb(h);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
vec4 col = vec4(0.);
|
||||
|
||||
for(int i = 0; i < GRADIENT_LIMIT; i++) {
|
||||
|
@ -58,15 +88,16 @@ vec4 gradientEval(in float prog) { #region
|
|||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(
|
||||
hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t),
|
||||
mix(gradient_color[i - 1].a, gradient_color[i].a, t)
|
||||
);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -76,7 +107,9 @@ vec4 gradientEval(in float prog) { #region
|
|||
}
|
||||
|
||||
return col;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
void main() {
|
||||
float a = gradientEval(v_vTexcoord.x).a;
|
||||
|
|
|
@ -35,7 +35,7 @@ uniform vec2 truchetAngle;
|
|||
|
||||
float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); }
|
||||
|
||||
#region ////////////////////////////////////////////////////////////////// GRADIENT //////////////////////////////////////////////////////////////////
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform int gradient_blend;
|
||||
|
@ -46,6 +46,37 @@ float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.5406
|
|||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
|
@ -97,15 +128,16 @@ float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.5406
|
|||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(
|
||||
hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t),
|
||||
mix(gradient_color[i - 1].a, gradient_color[i].a, t)
|
||||
);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -117,7 +149,8 @@ float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.5406
|
|||
|
||||
return col;
|
||||
} #endregion
|
||||
#endregion ////////////////////////////////////////////////////////////////// GRADIENT //////////////////////////////////////////////////////////////////
|
||||
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
void main() { #region
|
||||
#region params
|
||||
|
|
|
@ -23,13 +23,6 @@ uniform sampler2D thickSurf;
|
|||
|
||||
uniform vec4 gapCol;
|
||||
uniform int gradient_use;
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
uniform int textureTruchet;
|
||||
uniform float truchetSeed;
|
||||
|
@ -40,7 +33,49 @@ uniform vec2 truchetAngle;
|
|||
|
||||
float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); }
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
@ -50,19 +85,19 @@ vec3 rgb2hsv(vec3 c) { #region
|
|||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
} #endregion
|
||||
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float da = fract(a1 - a0);
|
||||
float ds = fract(2. * da) - da;
|
||||
return a0 + ds * t;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 h1 = rgb2hsv(c1);
|
||||
vec3 h2 = rgb2hsv(c2);
|
||||
|
||||
|
@ -72,9 +107,9 @@ vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
|||
h.z = mix(h1.z, h2.z, t);
|
||||
|
||||
return hsv2rgb(h);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
if(gradient_use_map == 1) {
|
||||
vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog);
|
||||
return texture2D( gradient_map, samplePos );
|
||||
|
@ -91,12 +126,16 @@ vec4 gradientEval(in float prog) { #region
|
|||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -107,7 +146,9 @@ vec4 gradientEval(in float prog) { #region
|
|||
}
|
||||
|
||||
return col;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
float HexDist(vec2 p) { #region
|
||||
p = abs(p);
|
||||
|
|
|
@ -3,7 +3,6 @@ varying vec4 v_vColour;
|
|||
|
||||
#define c30 (1.0 / 0.86602540378)
|
||||
#define PI 3.14159265359
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform vec2 position;
|
||||
uniform vec2 dimension;
|
||||
|
@ -25,13 +24,6 @@ uniform sampler2D widthSurf;
|
|||
|
||||
uniform vec4 gapCol;
|
||||
uniform int gradient_use;
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
uniform int textureTruchet;
|
||||
uniform float truchetSeed;
|
||||
|
@ -40,7 +32,49 @@ uniform vec2 truchetAngle;
|
|||
|
||||
float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); }
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
@ -48,21 +82,21 @@ vec3 rgb2hsv(vec3 c) { #region
|
|||
float d = q.x - min(q.w, q.y);
|
||||
float e = 0.0000000001;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float da = fract(a1 - a0);
|
||||
float ds = fract(2. * da) - da;
|
||||
return a0 + ds * t;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 h1 = rgb2hsv(c1);
|
||||
vec3 h2 = rgb2hsv(c2);
|
||||
|
||||
|
@ -72,9 +106,9 @@ vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
|||
h.z = mix(h1.z, h2.z, t);
|
||||
|
||||
return hsv2rgb(h);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
if(gradient_use_map == 1) {
|
||||
vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog);
|
||||
return texture2D( gradient_map, samplePos );
|
||||
|
@ -91,12 +125,16 @@ vec4 gradientEval(in float prog) { #region
|
|||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -107,7 +145,9 @@ vec4 gradientEval(in float prog) { #region
|
|||
}
|
||||
|
||||
return col;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
vec3 triGrid(vec2 p){ #region
|
||||
float _stx = (p.x + c30 / 2.0 * p.y);
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform vec2 dimension;
|
||||
uniform vec2 position;
|
||||
uniform float seed;
|
||||
|
@ -23,13 +21,6 @@ uniform sampler2D thickSurf;
|
|||
|
||||
uniform vec4 gapCol;
|
||||
uniform int gradient_use;
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
uniform int textureTruchet;
|
||||
uniform float truchetSeed;
|
||||
|
@ -43,7 +34,49 @@ uniform float tileLength;
|
|||
|
||||
float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); }
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
@ -53,19 +86,19 @@ vec3 rgb2hsv(vec3 c) { #region
|
|||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
} #endregion
|
||||
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float da = fract(a1 - a0);
|
||||
float ds = fract(2. * da) - da;
|
||||
return a0 + ds * t;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 h1 = rgb2hsv(c1);
|
||||
vec3 h2 = rgb2hsv(c2);
|
||||
|
||||
|
@ -75,9 +108,9 @@ vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
|||
h.z = mix(h1.z, h2.z, t);
|
||||
|
||||
return hsv2rgb(h);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
if(gradient_use_map == 1) {
|
||||
vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog);
|
||||
return texture2D( gradient_map, samplePos );
|
||||
|
@ -94,12 +127,16 @@ vec4 gradientEval(in float prog) { #region
|
|||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -110,7 +147,9 @@ vec4 gradientEval(in float prog) { #region
|
|||
}
|
||||
|
||||
return col;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
float round(float val) { return fract(val) >= 0.5? ceil(val) : floor(val); }
|
||||
|
||||
|
|
|
@ -7,18 +7,50 @@ uniform int mode;
|
|||
uniform vec2 range;
|
||||
uniform float number[BATCH_SIZE];
|
||||
|
||||
#region ////////////////////////////////////////// GRADIENT BEGIN //////////////////////////////////////////
|
||||
|
||||
#define GRADIENT_LIMIT 128
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
vec3 rgb2hsv(vec3 c) {
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
@ -26,21 +58,21 @@ vec3 rgb2hsv(vec3 c) {
|
|||
float d = q.x - min(q.w, q.y);
|
||||
float e = 0.0000000001;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec3 hsv2rgb(vec3 c) {
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
float hueDist(float a0, float a1, float t) {
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float da = fract(a1 - a0);
|
||||
float ds = fract(2. * da) - da;
|
||||
return a0 + ds * t;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) {
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 h1 = rgb2hsv(c1);
|
||||
vec3 h2 = rgb2hsv(c2);
|
||||
|
||||
|
@ -50,9 +82,9 @@ vec3 hsvMix(vec3 c1, vec3 c2, float t) {
|
|||
h.z = mix(h1.z, h2.z, t);
|
||||
|
||||
return hsv2rgb(h);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec4 gradientEval(in float prog) {
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
if(gradient_use_map == 1) {
|
||||
vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog);
|
||||
return texture2D( gradient_map, samplePos );
|
||||
|
@ -69,12 +101,16 @@ vec4 gradientEval(in float prog) {
|
|||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -85,9 +121,10 @@ vec4 gradientEval(in float prog) {
|
|||
}
|
||||
|
||||
return col;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
#endregion ////////////////////////////////////////// GRADIENT END //////////////////////////////////////////
|
||||
|
||||
void main() {
|
||||
vec2 px = v_vTexcoord;
|
||||
|
|
|
@ -1,37 +1,24 @@
|
|||
//
|
||||
// Simple passthrough fragment shader
|
||||
//
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform float seed;
|
||||
uniform float strength;
|
||||
uniform float dist;
|
||||
uniform int useMap;
|
||||
uniform sampler2D strengthMap;
|
||||
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
uniform float alpha_curve[64];
|
||||
uniform int curve_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 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) { #region
|
||||
return _y0 * pow(1. - prog, 3.) +
|
||||
ay0 * 3. * pow(1. - prog, 2.) * prog +
|
||||
by1 * 3. * (1. - prog) * pow(prog, 2.) +
|
||||
_y1 * pow(prog, 3.);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
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 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) { #region
|
||||
float st = 0.;
|
||||
float ed = 1.;
|
||||
float _prec = 0.0001;
|
||||
|
@ -76,9 +63,9 @@ float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx
|
|||
|
||||
_xt = clamp(_xt, 0., 1.);
|
||||
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
float curveEval(in float _x) {
|
||||
float curveEval(in float _x) { #region
|
||||
_x = clamp(_x, 0., 1.);
|
||||
int segments = curve_amount / 6 - 1;
|
||||
|
||||
|
@ -105,9 +92,51 @@ float curveEval(in float _x) {
|
|||
}
|
||||
|
||||
return alpha_curve[0];
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) {
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
@ -115,21 +144,21 @@ vec3 rgb2hsv(vec3 c) {
|
|||
float d = q.x - min(q.w, q.y);
|
||||
float e = 0.0000000001;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec3 hsv2rgb(vec3 c) {
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
float hueDist(float a0, float a1, float t) {
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float da = fract(a1 - a0);
|
||||
float ds = fract(2. * da) - da;
|
||||
return a0 + ds * t;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) {
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 h1 = rgb2hsv(c1);
|
||||
vec3 h2 = rgb2hsv(c2);
|
||||
|
||||
|
@ -139,9 +168,9 @@ vec3 hsvMix(vec3 c1, vec3 c2, float t) {
|
|||
h.z = mix(h1.z, h2.z, t);
|
||||
|
||||
return hsv2rgb(h);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec4 gradientEval(in float prog) {
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
if(gradient_use_map == 1) {
|
||||
vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog);
|
||||
return texture2D( gradient_map, samplePos );
|
||||
|
@ -158,12 +187,16 @@ vec4 gradientEval(in float prog) {
|
|||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -174,18 +207,20 @@ vec4 gradientEval(in float prog) {
|
|||
}
|
||||
|
||||
return col;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
float frandom (in vec2 st, in float _seed) {
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
float frandom (in vec2 st, in float _seed) { #region
|
||||
float f = fract(sin(dot(st.xy, vec2(12.9898, 78.233)) * mod(15.15 + seed, 32.156 + _seed) * 12.588) * 43758.5453123);
|
||||
return mix(-1., 1., f);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
vec2 vrandom (in vec2 st) {
|
||||
vec2 vrandom (in vec2 st) { #region
|
||||
return vec2(frandom(st, 165.874), frandom(st, 98.601));
|
||||
}
|
||||
} #endregion
|
||||
|
||||
void main() {
|
||||
void main() { #region
|
||||
vec2 _pos = v_vTexcoord;
|
||||
float str = strength;
|
||||
|
||||
|
@ -211,5 +246,4 @@ void main() {
|
|||
}
|
||||
|
||||
gl_FragColor = _col;
|
||||
}
|
||||
|
||||
} #endregion
|
|
@ -1,11 +1,6 @@
|
|||
// Pytagorean tiling
|
||||
// gelami Pythagorean Square Tiling 2
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform vec2 dimension;
|
||||
uniform vec2 position;
|
||||
uniform float seed;
|
||||
|
@ -24,16 +19,6 @@ uniform vec2 thick;
|
|||
uniform int thickUseSurf;
|
||||
uniform sampler2D thickSurf;
|
||||
|
||||
uniform vec4 gapCol;
|
||||
uniform int gradient_use;
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
uniform int textureTruchet;
|
||||
uniform float truchetSeed;
|
||||
uniform float truchetThres;
|
||||
|
@ -41,12 +26,55 @@ uniform vec2 truchetAngle;
|
|||
|
||||
uniform float phase;
|
||||
|
||||
uniform vec4 gapCol;
|
||||
uniform int gradient_use;
|
||||
|
||||
#define PI 3.14159265359
|
||||
#define TAU 6.28318530718
|
||||
|
||||
float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); }
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
@ -56,19 +84,19 @@ vec3 rgb2hsv(vec3 c) { #region
|
|||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
} #endregion
|
||||
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float da = fract(a1 - a0);
|
||||
float ds = fract(2. * da) - da;
|
||||
return a0 + ds * t;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 h1 = rgb2hsv(c1);
|
||||
vec3 h2 = rgb2hsv(c2);
|
||||
|
||||
|
@ -78,9 +106,9 @@ vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
|||
h.z = mix(h1.z, h2.z, t);
|
||||
|
||||
return hsv2rgb(h);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
if(gradient_use_map == 1) {
|
||||
vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog);
|
||||
return texture2D( gradient_map, samplePos );
|
||||
|
@ -97,12 +125,16 @@ vec4 gradientEval(in float prog) { #region
|
|||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -113,7 +145,11 @@ vec4 gradientEval(in float prog) { #region
|
|||
}
|
||||
|
||||
return col;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); }
|
||||
|
||||
float HexDist(vec2 p) { #region
|
||||
p = abs(p);
|
||||
|
|
66
shaders/sh_quarsicrystal/sh_quarsicrystal.fsh
Normal file
|
@ -0,0 +1,66 @@
|
|||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
#define PI 3.14159265359
|
||||
|
||||
uniform vec2 dimension;
|
||||
uniform vec2 position;
|
||||
|
||||
uniform vec2 amount;
|
||||
uniform int amountUseSurf;
|
||||
uniform sampler2D amountSurf;
|
||||
|
||||
uniform vec2 angle;
|
||||
uniform int angleUseSurf;
|
||||
uniform sampler2D angleSurf;
|
||||
|
||||
uniform vec2 phase;
|
||||
uniform int phaseUseSurf;
|
||||
uniform sampler2D phaseSurf;
|
||||
|
||||
uniform vec2 rangleRange;
|
||||
|
||||
uniform vec4 color0;
|
||||
uniform vec4 color1;
|
||||
|
||||
void main() { #region
|
||||
#region params
|
||||
float amo = amount.x;
|
||||
if(amountUseSurf == 1) {
|
||||
vec4 _vMap = texture2D( amountSurf, v_vTexcoord );
|
||||
amo = mix(amount.x, amount.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
|
||||
}
|
||||
|
||||
float ang = angle.x;
|
||||
if(angleUseSurf == 1) {
|
||||
vec4 _vMap = texture2D( angleSurf, v_vTexcoord );
|
||||
ang = mix(angle.x, angle.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
|
||||
}
|
||||
ang = radians(ang);
|
||||
|
||||
float pha = phase.x;
|
||||
if(phaseUseSurf == 1) {
|
||||
vec4 _vMap = texture2D( phaseSurf, v_vTexcoord );
|
||||
pha = mix(phase.x, phase.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
vec2 pos = (v_vTexcoord - position) * mat2(cos(ang), -sin(ang), sin(ang), cos(ang)) * amo;
|
||||
|
||||
float value = 0.0;
|
||||
int num = 4;
|
||||
|
||||
float as = radians(rangleRange.x);
|
||||
float an = radians(rangleRange.y);
|
||||
|
||||
for(int i = 0; i < num; i++) {
|
||||
float a = mix(as, an, float(i) / float(num));
|
||||
float w = pos.x * sin(a) + pos.y * cos(a);
|
||||
|
||||
value += sin(w + pha * PI * 2.);
|
||||
}
|
||||
|
||||
float _s = 1. + sin(value * PI / 2.0);
|
||||
gl_FragColor = mix(color0, color1, _s);
|
||||
} #endregion
|
19
shaders/sh_quarsicrystal/sh_quarsicrystal.vsh
Normal 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;
|
||||
}
|
10
shaders/sh_quarsicrystal/sh_quarsicrystal.yy
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"resourceType": "GMShader",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "sh_quarsicrystal",
|
||||
"parent": {
|
||||
"name": "generator",
|
||||
"path": "folders/shader/generator.yy",
|
||||
},
|
||||
"type": 1,
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform vec2 dimension;
|
||||
uniform vec2 position;
|
||||
uniform float seed;
|
||||
|
@ -23,13 +21,6 @@ uniform sampler2D thickSurf;
|
|||
|
||||
uniform vec4 gapCol;
|
||||
uniform int gradient_use;
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
uniform int textureTruchet;
|
||||
uniform float truchetSeed;
|
||||
|
@ -41,7 +32,49 @@ uniform vec2 truchetAngle;
|
|||
|
||||
float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); }
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
@ -51,19 +84,19 @@ vec3 rgb2hsv(vec3 c) { #region
|
|||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
} #endregion
|
||||
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float da = fract(a1 - a0);
|
||||
float ds = fract(2. * da) - da;
|
||||
return a0 + ds * t;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 h1 = rgb2hsv(c1);
|
||||
vec3 h2 = rgb2hsv(c2);
|
||||
|
||||
|
@ -73,9 +106,9 @@ vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
|||
h.z = mix(h1.z, h2.z, t);
|
||||
|
||||
return hsv2rgb(h);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
if(gradient_use_map == 1) {
|
||||
vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog);
|
||||
return texture2D( gradient_map, samplePos );
|
||||
|
@ -92,12 +125,16 @@ vec4 gradientEval(in float prog) { #region
|
|||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -108,7 +145,9 @@ vec4 gradientEval(in float prog) { #region
|
|||
}
|
||||
|
||||
return col;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
float round(float val) { return fract(val) >= 0.5? ceil(val) : floor(val); }
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Simple passthrough fragment shader
|
||||
//
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
|
@ -28,18 +25,51 @@ uniform sampler2D ratioSurf;
|
|||
|
||||
uniform vec4 color0;
|
||||
uniform vec4 color1;
|
||||
|
||||
#define GRADIENT_LIMIT 128
|
||||
uniform int gradient_use;
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
#region //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
#define GRADIENT_LIMIT 128
|
||||
|
||||
uniform int gradient_blend;
|
||||
uniform vec4 gradient_color[GRADIENT_LIMIT];
|
||||
uniform float gradient_time[GRADIENT_LIMIT];
|
||||
uniform int gradient_keys;
|
||||
uniform int gradient_use_map;
|
||||
uniform vec4 gradient_map_range;
|
||||
uniform sampler2D gradient_map;
|
||||
|
||||
vec3 rgb2oklab(vec3 c) { #region
|
||||
const mat3 kCONEtoLMS = mat3(
|
||||
0.4121656120, 0.2118591070, 0.0883097947,
|
||||
0.5362752080, 0.6807189584, 0.2818474174,
|
||||
0.0514575653, 0.1074065790, 0.6302613616);
|
||||
|
||||
c = pow(c, vec3(2.2));
|
||||
c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) );
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklab2rgb(vec3 c) { #region
|
||||
const mat3 kLMStoCONE = mat3(
|
||||
4.0767245293, -1.2681437731, -0.0041119885,
|
||||
-3.3072168827, 2.6093323231, -0.7034763098,
|
||||
0.2307590544, -0.3411344290, 1.7068625689);
|
||||
|
||||
c = kLMStoCONE * (c * c * c);
|
||||
c = pow(c, vec3(1. / 2.2));
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
|
||||
vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 k1 = rgb2oklab(c1);
|
||||
vec3 k2 = rgb2oklab(c2);
|
||||
|
||||
return oklab2rgb(mix(k1, k2, t));
|
||||
} #endregion
|
||||
|
||||
vec3 rgb2hsv(vec3 c) { #region
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
@ -47,21 +77,21 @@ vec3 rgb2hsv(vec3 c) { #region
|
|||
float d = q.x - min(q.w, q.y);
|
||||
float e = 0.0000000001;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec3 hsv2rgb(vec3 c) { #region
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float hueDist(float a0, float a1, float t) { #region
|
||||
float da = fract(a1 - a0);
|
||||
float ds = fract(2. * da) - da;
|
||||
return a0 + ds * t;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
||||
vec3 h1 = rgb2hsv(c1);
|
||||
vec3 h2 = rgb2hsv(c2);
|
||||
|
||||
|
@ -71,9 +101,9 @@ vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region
|
|||
h.z = mix(h1.z, h2.z, t);
|
||||
|
||||
return hsv2rgb(h);
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
vec4 gradientEval(in float prog) { #region
|
||||
if(gradient_use_map == 1) {
|
||||
vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog);
|
||||
return texture2D( gradient_map, samplePos );
|
||||
|
@ -90,12 +120,16 @@ vec4 gradientEval(in float prog) { #region
|
|||
col = gradient_color[i];
|
||||
else {
|
||||
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
|
||||
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
|
||||
|
||||
if(gradient_blend == 0)
|
||||
col = mix(gradient_color[i - 1], gradient_color[i], t);
|
||||
else if(gradient_blend == 1)
|
||||
col = gradient_color[i - 1];
|
||||
else if(gradient_blend == 2)
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.);
|
||||
col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
else if(gradient_blend == 3)
|
||||
col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -106,7 +140,9 @@ vec4 gradientEval(in float prog) { #region
|
|||
}
|
||||
|
||||
return col;
|
||||
} #endregion
|
||||
} #endregion
|
||||
|
||||
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
|
||||
|
||||
float random (in vec2 st) { return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); }
|
||||
|
||||
|
|
BIN
sprites/s_node_kuwahara/8a406345-89b9-471e-9af6-1f2bcc937fd9.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.2 KiB |
|
@ -13,14 +13,14 @@
|
|||
"edgeFiltering": false,
|
||||
"For3D": false,
|
||||
"frames": [
|
||||
{"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"d32dffb4-8395-4ac5-800e-6d35f00f9167",},
|
||||
{"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"8a406345-89b9-471e-9af6-1f2bcc937fd9",},
|
||||
],
|
||||
"gridX": 0,
|
||||
"gridY": 0,
|
||||
"height": 64,
|
||||
"HTile": false,
|
||||
"layers": [
|
||||
{"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"7f08cf06-022b-4f31-ad2e-39f9ebdaa522","blendMode":0,"displayName":"default","isLocked":false,"opacity":100.0,"visible":true,},
|
||||
{"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"f8c4784e-d1f2-4f62-bfea-b59001ce1031","blendMode":0,"displayName":"default","isLocked":false,"opacity":100.0,"visible":true,},
|
||||
],
|
||||
"nineSlice": null,
|
||||
"origin": 4,
|
||||
|
@ -54,7 +54,7 @@
|
|||
"timeUnits": 1,
|
||||
"tracks": [
|
||||
{"resourceType":"GMSpriteFramesTrack","resourceVersion":"1.0","name":"frames","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"1.0","Keyframes":[
|
||||
{"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"1.0","Channels":{"0":{"resourceType":"SpriteFrameKeyframe","resourceVersion":"1.0","Id":{"name":"d32dffb4-8395-4ac5-800e-6d35f00f9167","path":"sprites/s_node_kuwahara/s_node_kuwahara.yy",},},},"Disabled":false,"id":"e7a17aeb-e2e6-4c0b-a6aa-ec494d2715ae","IsCreationKey":false,"Key":0.0,"Length":1.0,"Stretch":false,},
|
||||
{"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"1.0","Channels":{"0":{"resourceType":"SpriteFrameKeyframe","resourceVersion":"1.0","Id":{"name":"8a406345-89b9-471e-9af6-1f2bcc937fd9","path":"sprites/s_node_kuwahara/s_node_kuwahara.yy",},},},"Disabled":false,"id":"9fa76e34-7a1b-4483-803f-cabf9e9eddc1","IsCreationKey":false,"Key":0.0,"Length":1.0,"Stretch":false,},
|
||||
],},"modifiers":[],"spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
|
||||
],
|
||||
"visibleRange": null,
|
||||
|
|