- [Repeat] Add additive and maximum blend mode.

This commit is contained in:
Tanasart 2024-07-19 14:35:01 +07:00
parent 2f6e7d2abb
commit 74224e323a
9 changed files with 205 additions and 157 deletions

View file

@ -30,10 +30,15 @@ function Node_Color_replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
__init_mask_modifier(7); // inputs 11, 12 __init_mask_modifier(7); // inputs 11, 12
input_display_list = [ 9, 10, inputs[| 13] = nodeValue("Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Closet", "Random" ]);
inputs[| 14] = nodeValueSeed(self, VALUE_TYPE.float);
input_display_list = [ 9, 10, 14,
["Surfaces", true], 0, 7, 8, 11, 12, ["Surfaces", true], 0, 7, 8, 11, 12,
["Palette", false], 1, 2, ["Palette", false], 1, 2,
["Comparison", false], 3, 5, ["Comparison", false], 13, 3, 5,
["Render", false], 4, 6 ["Render", false], 4, 6
]; ];
@ -41,11 +46,11 @@ function Node_Color_replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
attribute_surface_depth(); attribute_surface_depth();
static step = function() { #region static step = function() {
__step_mask_modifier(); __step_mask_modifier();
} #endregion }
static processData = function(_outSurf, _data, _output_index, _array_index) { #region static processData = function(_outSurf, _data, _output_index, _array_index) {
var fr = _data[ 1]; var fr = _data[ 1];
var to = _data[ 2]; var to = _data[ 2];
var tr = _data[ 3]; var tr = _data[ 3];
@ -53,6 +58,8 @@ function Node_Color_replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
var alp = _data[ 5]; var alp = _data[ 5];
var hrd = _data[ 6]; var hrd = _data[ 6];
var msk = _data[ 7]; var msk = _data[ 7];
var mde = _data[13];
var sed = _data[14];
var _colorFrom = paletteToArray(fr); var _colorFrom = paletteToArray(fr);
var _colorTo = paletteToArray(to); var _colorTo = paletteToArray(to);
@ -63,6 +70,8 @@ function Node_Color_replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
shader_set_f("colorTo", _colorTo); shader_set_f("colorTo", _colorTo);
shader_set_i("colorTo_amo", array_length(to)); shader_set_i("colorTo_amo", array_length(to));
shader_set_f("seed", sed);
shader_set_i("mode", mde);
shader_set_i("alphacmp", alp); shader_set_i("alphacmp", alp);
shader_set_i("hardReplace", hrd); shader_set_i("hardReplace", hrd);
shader_set_f("treshold", tr); shader_set_f("treshold", tr);
@ -79,5 +88,5 @@ function Node_Color_replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
_outSurf = channel_apply(_data[0], _outSurf, _data[10]); _outSurf = channel_apply(_data[0], _outSurf, _data[10]);
return _outSurf; return _outSurf;
} #endregion }
} }

View file

@ -133,6 +133,7 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
if(_tex_dim) _dim = surface_get_dimension(_sam); if(_tex_dim) _dim = surface_get_dimension(_sam);
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth()); _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_shader(_outSurf, sh_grid); surface_set_shader(_outSurf, sh_grid);
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]); shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_f("dimension", _dim[0], _dim[1]); shader_set_f("dimension", _dim[0], _dim[1]);

View file

@ -116,6 +116,12 @@ function Node_Repeat(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
inputs[| 32] = nodeValue("Start rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) inputs[| 32] = nodeValue("Start rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.rotation); .setDisplay(VALUE_DISPLAY.rotation);
inputs[| 33] = nodeValue("Rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.rotation);
inputs[| 34] = nodeValue("Blend Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Normal", "Additive", "Maximum" ]);
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [ input_display_list = [
@ -123,15 +129,16 @@ function Node_Repeat(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
["Pattern", false], 3, 9, 32, 2, 18, 7, 8, ["Pattern", false], 3, 9, 32, 2, 18, 7, 8,
["Path", true], 11, 12, 13, ["Path", true], 11, 12, 13,
["Position", false], 4, 26, 19, ["Position", false], 4, 26, 19,
["Rotation", false], 5, ["Rotation", false], 33, 5,
["Scale", false], 6, 10, ["Scale", false], 6, 10,
["Render", false], 14, 30, ["Render", false], 34, 14, 30,
["Animator", true, 29], 20, 21, 25, 22, 23, 24, 27, ["Animator", true, 29], 20, 21, 25, 22, 23, 24, 27,
]; ];
attribute_surface_depth(); attribute_surface_depth();
attribute_interpolation();
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
PROCESSOR_OVERLAY_CHECK PROCESSOR_OVERLAY_CHECK
var _hov = false; var _hov = false;
@ -149,9 +156,9 @@ function Node_Repeat(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
var hv = inputs[| 31].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, current_data[1]); active &= !hv; _hov |= hv; var hv = inputs[| 31].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, current_data[1]); active &= !hv; _hov |= hv;
return _hov; return _hov;
} #endregion }
static preGetInputs = function() { #region static preGetInputs = function() {
var _arr = getSingleValue(16); var _arr = getSingleValue(16);
var _pat = getSingleValue(3); var _pat = getSingleValue(3);
@ -166,9 +173,9 @@ function Node_Repeat(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
inputs[| 32].setVisible( _pat == 2); inputs[| 32].setVisible( _pat == 2);
inputs[| 14].mappableStep(); inputs[| 14].mappableStep();
} #endregion }
static processData = function(_outSurf, _data, _output_index, _array_index) { #region static processData = function(_outSurf, _data, _output_index, _array_index) {
var _iSrf = _data[ 0]; var _iSrf = _data[ 0];
var _dim = _data[ 1]; var _dim = _data[ 1];
@ -181,6 +188,7 @@ function Node_Repeat(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
var _rpos = _data[ 4]; var _rpos = _data[ 4];
var _rsta = _data[26]; var _rsta = _data[26];
var _rrot = _data[ 5]; var _rrot = _data[ 5];
var _rots = _data[33];
var _rsca = _data[ 6]; var _rsca = _data[ 6];
var _msca = _data[10]; var _msca = _data[10];
@ -213,12 +221,17 @@ function Node_Repeat(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
var _an_bld = _data[27]; var _an_bld = _data[27];
var _an_alp = _color_get_alpha(_an_bld); var _an_alp = _color_get_alpha(_an_bld);
var _bld_md = _data[34];
var _surf, runx, runy, posx, posy, scax, scay, rot; var _surf, runx, runy, posx, posy, scax, scay, rot;
random_set_seed(_sed); random_set_seed(_sed);
surface_set_target(_outSurf); surface_set_shader(_outSurf);
DRAW_CLEAR if(_bld_md == 0) BLEND_ALPHA_MULP
else if(_bld_md == 1) BLEND_ADD
else if(_bld_md == 2) { BLEND_ALPHA_MULP gpu_set_blendequation(bm_eq_max); }
runx = 0; runx = 0;
runy = 0; runy = 0;
@ -254,7 +267,7 @@ function Node_Repeat(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
scax = eval_curve_x(_msca, i / (_amo - 1)) * _rsca; scax = eval_curve_x(_msca, i / (_amo - 1)) * _rsca;
scay = scax; scay = scax;
rot = _rrot[0] + (_rrot[1] - _rrot[0]) * i / _amo; rot = _rots + _rrot[0] + (_rrot[1] - _rrot[0]) * i / _amo;
var _an_dist = abs(i - _an_mid * (_amo - 1)); var _an_dist = abs(i - _an_mid * (_amo - 1));
var _inf = 0; var _inf = 0;
@ -306,13 +319,17 @@ function Node_Repeat(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
aa += _an_alp * _inf; aa += _an_alp * _inf;
} }
shader_set_interpolation(_surf);
draw_surface_ext_safe(_surf, posx + pos[0], posy + pos[1], scax, scay, rot, cc, aa); draw_surface_ext_safe(_surf, posx + pos[0], posy + pos[1], scax, scay, rot, cc, aa);
if(_rsta == 1) runx += _sw / 2; if(_rsta == 1) runx += _sw / 2;
if(_rsta == 2) runy += _sh / 2; if(_rsta == 2) runy += _sh / 2;
} }
surface_reset_target();
BLEND_NORMAL
gpu_set_blendequation(bm_eq_add);
surface_reset_shader();
return _outSurf; return _outSurf;
} #endregion }
} }

View file

@ -59,9 +59,11 @@ function Node_Stripe(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
inputs[| 18] = nodeValue("Colors", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, [ c_black, c_white ] ) inputs[| 18] = nodeValue("Colors", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, [ c_black, c_white ] )
.setDisplay(VALUE_DISPLAY.palette); .setDisplay(VALUE_DISPLAY.palette);
inputs[| 19] = nodeValueSeed(self, VALUE_TYPE.float);
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [ input_display_list = [ 19,
["Output", true], 0, ["Output", true], 0,
["Pattern", false], 1, 11, 10, 14, 2, 12, 4, 5, 13, 17, ["Pattern", false], 1, 11, 10, 14, 2, 12, 4, 5, 13, 17,
["Render", false], 3, 6, 7, 15, 8, 9, 18, ["Render", false], 3, 6, 7, 15, 8, 9, 18,
@ -107,12 +109,14 @@ function Node_Stripe(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
var _clr1 = _data[9]; var _clr1 = _data[9];
var _prg = _data[17]; var _prg = _data[17];
var _pal = _data[18]; var _pal = _data[18];
var _seed = _data[19];
var _color = _data[6]; var _color = _data[6];
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth()); _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_shader(_outSurf, sh_stripe); surface_set_shader(_outSurf, sh_stripe);
shader_set_f("seed", _seed);
shader_set_f("dimension", _dim[0], _dim[1]); shader_set_f("dimension", _dim[0], _dim[1]);
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]); shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_i("blend", _bnd); shader_set_i("blend", _bnd);

View file

@ -1,6 +1,14 @@
function nodeValue(_name, _node, _connect, _type, _value, _tooltip = "") { return new NodeValue(_name, _node, _connect, _type, _value, _tooltip); } function nodeValue(_name, _node, _connect, _type, _value, _tooltip = "") { return new NodeValue(_name, _node, _connect, _type, _value, _tooltip); }
function nodeValueMap(_name, _node, _junc = noone) { return new NodeValue(_name, _node, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone).setVisible(false, false).setMapped(_junc); } function nodeValueMap(_name, _node, _junc = noone) { return new NodeValue(_name, _node, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone).setVisible(false, false).setMapped(_junc); }
function nodeValueGradientRange(_name, _node, _junc = noone) { return new NodeValue(_name, _node, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 1, 0 ]).setDisplay(VALUE_DISPLAY.gradient_range).setVisible(false, false).setMapped(_junc); } function nodeValueGradientRange(_name, _node, _junc = noone) { return new NodeValue(_name, _node, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 1, 0 ])
.setDisplay(VALUE_DISPLAY.gradient_range).setVisible(false, false).setMapped(_junc); }
function nodeValueSeed(_node, _type) {
var _val = new NodeValue("Seed", _node, JUNCTION_CONNECT.input, _type, seed_random(6), "");
__node_seed_input_value = _val;
_val.setDisplay(VALUE_DISPLAY._default, { side_button : button(function() /*=>*/ { randomize(); __node_seed_input_value.setValue(seed_random(6)); }).setIcon(THEME.icon_random, 0, COLORS._main_icon) });
return _val;
}
function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constructor { function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constructor {
static DISPLAY_DATA_KEYS = [ "linked", "angle_display", "bone_id", "unit", "atlas_crop" ]; static DISPLAY_DATA_KEYS = [ "linked", "angle_display", "bone_id", "unit", "atlas_crop" ];

View file

@ -1,4 +1,4 @@
function shader_set_i(uniform, value) { #region function shader_set_i(uniform, value) {
INLINE INLINE
var shader = shader_current(); var shader = shader_current();
@ -19,13 +19,13 @@ function shader_set_i(uniform, value) { #region
array[i - 1] = argument[i]; array[i - 1] = argument[i];
shader_set_i_array(shader, uniform, array) shader_set_i_array(shader, uniform, array)
} }
} #endregion }
function shader_set_i_array(shader, uniform, array) { #region function shader_set_i_array(shader, uniform, array) {
INLINE INLINE
shader_set_uniform_i_array(shader_get_uniform(shader, uniform), array); shader_set_uniform_i_array(shader_get_uniform(shader, uniform), array);
} #endregion }
function shader_set_2(uniform, v) { INLINE var shader = shader_current(); shader_set_uniform_f(shader_get_uniform(shader, uniform), aGetF(v, 0), aGetF(v, 1)); } function shader_set_2(uniform, v) { INLINE var shader = shader_current(); shader_set_uniform_f(shader_get_uniform(shader, uniform), aGetF(v, 0), aGetF(v, 1)); }
function shader_set_3(uniform, v) { INLINE var shader = shader_current(); shader_set_uniform_f(shader_get_uniform(shader, uniform), aGetF(v, 0), aGetF(v, 1), aGetF(v, 2)); } function shader_set_3(uniform, v) { INLINE var shader = shader_current(); shader_set_uniform_f(shader_get_uniform(shader, uniform), aGetF(v, 0), aGetF(v, 1), aGetF(v, 2)); }
@ -39,7 +39,7 @@ function shader_set_f_array(uniform, value, max_length = 128) {
shader_set_uniform_f_array_safe(shader_get_uniform(shader, uniform), value, max_length); shader_set_uniform_f_array_safe(shader_get_uniform(shader, uniform), value, max_length);
} }
function shader_set_f(uniform, value) { #region function shader_set_f(uniform, value) {
INLINE INLINE
var shader = shader_current(); var shader = shader_current();
@ -75,9 +75,9 @@ function shader_set_f(uniform, value) { #region
array[i - 1] = argument[i]; array[i - 1] = argument[i];
shader_set_uniform_f_array(shader_get_uniform(shader, uniform), array); shader_set_uniform_f_array(shader_get_uniform(shader, uniform), array);
} }
} #endregion }
function shader_set_f_map(uniform, value, surface = noone, junc = noone) { #region function shader_set_f_map(uniform, value, surface = noone, junc = noone) {
INLINE INLINE
shader_set_f(uniform, is_array(value)? value : [ value, value ]); shader_set_f(uniform, is_array(value)? value : [ value, value ]);
@ -88,16 +88,16 @@ function shader_set_f_map(uniform, value, surface = noone, junc = noone) { #regi
shader_set_i( uniform + "UseSurf", junc.attributes.mapped && is_surface(surface)); shader_set_i( uniform + "UseSurf", junc.attributes.mapped && is_surface(surface));
shader_set_surface(uniform + "Surf", surface); shader_set_surface(uniform + "Surf", surface);
} }
} #endregion }
function shader_set_f_map_s(uniform, value, surface, junc) { #region function shader_set_f_map_s(uniform, value, surface, junc) {
INLINE INLINE
shader_set_f(uniform, is_array(value)? value : [ value, value ]); shader_set_f(uniform, is_array(value)? value : [ value, value ]);
shader_set_i(uniform + "UseSurf", junc.attributes.mapped && is_surface(surface)); shader_set_i(uniform + "UseSurf", junc.attributes.mapped && is_surface(surface));
} #endregion }
function shader_set_uniform_f_array_safe(uniform, array, max_length = 128) { #region function shader_set_uniform_f_array_safe(uniform, array, max_length = 128) {
INLINE INLINE
if(!is_array(array)) return; if(!is_array(array)) return;
@ -107,9 +107,9 @@ function shader_set_uniform_f_array_safe(uniform, array, max_length = 128) { #re
if(_len > max_length) array_resize(array, max_length) if(_len > max_length) array_resize(array, max_length)
shader_set_uniform_f_array(uniform, array); shader_set_uniform_f_array(uniform, array);
} #endregion }
function shader_set_surface(sampler, surface, linear = false, _repeat = false) { #region function shader_set_surface(sampler, surface, linear = false, _repeat = false) {
INLINE INLINE
var shader = shader_current(); var shader = shader_current();
@ -126,9 +126,9 @@ function shader_set_surface(sampler, surface, linear = false, _repeat = false) {
gpu_set_tex_repeat_ext(t, _repeat); gpu_set_tex_repeat_ext(t, _repeat);
return t; return t;
} #endregion }
function shader_set_surface_dimension(uniform, surface) { #region function shader_set_surface_dimension(uniform, surface) {
INLINE INLINE
var shader = shader_current(); var shader = shader_current();
@ -143,22 +143,22 @@ function shader_set_surface_dimension(uniform, surface) { #region
th = 2048; th = 2048;
shader_set_uniform_f(shader_get_uniform(shader, uniform), tw, th); shader_set_uniform_f(shader_get_uniform(shader, uniform), tw, th);
} #endregion }
function shader_set_dim(uniform = "dimension", surf = noone) { #region function shader_set_dim(uniform = "dimension", surf = noone) {
INLINE INLINE
if(!is_surface(surf)) return; if(!is_surface(surf)) return;
shader_set_f(uniform, surface_get_width_safe(surf), surface_get_height_safe(surf)); shader_set_f(uniform, surface_get_width_safe(surf), surface_get_height_safe(surf));
} #endregion }
function shader_set_color(uniform, col, alpha = 1) { #region function shader_set_color(uniform, col, alpha = 1) {
INLINE INLINE
shader_set_f(uniform, colToVec4(col, alpha)); shader_set_f(uniform, colToVec4(col, alpha));
} #endregion }
function shader_set_palette(pal, pal_uni = "palette", amo_uni = "paletteAmount", max_length = 128) { #region function shader_set_palette(pal, pal_uni = "palette", amo_uni = "paletteAmount", max_length = 128) {
INLINE INLINE
shader_set_i(amo_uni, min(max_length, array_length(pal))); shader_set_i(amo_uni, min(max_length, array_length(pal)));
@ -169,7 +169,7 @@ function shader_set_palette(pal, pal_uni = "palette", amo_uni = "paletteAmount",
if(array_length(_pal)) if(array_length(_pal))
shader_set_f(pal_uni, _pal); shader_set_f(pal_uni, _pal);
} #endregion }
#region prebuild #region prebuild
enum BLEND { enum BLEND {

View file

@ -12,12 +12,17 @@ uniform int colorFrom_amo;
uniform vec4 colorTo[32]; uniform vec4 colorTo[32];
uniform int colorTo_amo; uniform int colorTo_amo;
uniform float seed;
uniform int mode;
uniform int inverted; uniform int inverted;
uniform int alphacmp; uniform int alphacmp;
uniform int hardReplace; uniform int hardReplace;
uniform float treshold; uniform float treshold;
vec3 rgb2xyz( vec3 c ) { #region #region color spaces
vec3 rgb2xyz( vec3 c ) {
vec3 tmp; vec3 tmp;
tmp.x = ( c.r > 0.04045 ) ? pow( ( c.r + 0.055 ) / 1.055, 2.4 ) : c.r / 12.92; tmp.x = ( c.r > 0.04045 ) ? pow( ( c.r + 0.055 ) / 1.055, 2.4 ) : c.r / 12.92;
tmp.y = ( c.g > 0.04045 ) ? pow( ( c.g + 0.055 ) / 1.055, 2.4 ) : c.g / 12.92, tmp.y = ( c.g > 0.04045 ) ? pow( ( c.g + 0.055 ) / 1.055, 2.4 ) : c.g / 12.92,
@ -26,23 +31,23 @@ vec3 rgb2xyz( vec3 c ) { #region
mat3( 0.4124, 0.3576, 0.1805, mat3( 0.4124, 0.3576, 0.1805,
0.2126, 0.7152, 0.0722, 0.2126, 0.7152, 0.0722,
0.0193, 0.1192, 0.9505 ); 0.0193, 0.1192, 0.9505 );
} #endregion }
vec3 xyz2lab( vec3 c ) { #region vec3 xyz2lab( vec3 c ) {
vec3 n = c / vec3( 95.047, 100, 108.883 ); vec3 n = c / vec3( 95.047, 100, 108.883 );
vec3 v; vec3 v;
v.x = ( n.x > 0.008856 ) ? pow( n.x, 1.0 / 3.0 ) : ( 7.787 * n.x ) + ( 16.0 / 116.0 ); v.x = ( n.x > 0.008856 ) ? pow( n.x, 1.0 / 3.0 ) : ( 7.787 * n.x ) + ( 16.0 / 116.0 );
v.y = ( n.y > 0.008856 ) ? pow( n.y, 1.0 / 3.0 ) : ( 7.787 * n.y ) + ( 16.0 / 116.0 ); v.y = ( n.y > 0.008856 ) ? pow( n.y, 1.0 / 3.0 ) : ( 7.787 * n.y ) + ( 16.0 / 116.0 );
v.z = ( n.z > 0.008856 ) ? pow( n.z, 1.0 / 3.0 ) : ( 7.787 * n.z ) + ( 16.0 / 116.0 ); v.z = ( n.z > 0.008856 ) ? pow( n.z, 1.0 / 3.0 ) : ( 7.787 * n.z ) + ( 16.0 / 116.0 );
return vec3(( 116.0 * v.y ) - 16.0, 500.0 * ( v.x - v.y ), 200.0 * ( v.y - v.z )); return vec3(( 116.0 * v.y ) - 16.0, 500.0 * ( v.x - v.y ), 200.0 * ( v.y - v.z ));
} #endregion }
vec3 rgb2lab(vec3 c) { #region vec3 rgb2lab(vec3 c) {
vec3 lab = xyz2lab( rgb2xyz( c ) ); vec3 lab = xyz2lab( rgb2xyz( c ) );
return vec3( lab.x / 100.0, 0.5 + 0.5 * ( lab.y / 127.0 ), 0.5 + 0.5 * ( lab.z / 127.0 )); return vec3( lab.x / 100.0, 0.5 + 0.5 * ( lab.y / 127.0 ), 0.5 + 0.5 * ( lab.z / 127.0 ));
} #endregion }
vec3 rgb2hsv(vec3 c) { #region vec3 rgb2hsv(vec3 c) {
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); 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 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)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
@ -50,14 +55,17 @@ vec3 rgb2hsv(vec3 c) { #region
float d = q.x - min(q.w, q.y); float d = q.x - min(q.w, q.y);
float e = 0.0000000001; float e = 0.0000000001;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); 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) {
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); 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); 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); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
} #endregion }
#endregion
float random(in float st) { return fract(sin(st * 12.9898) * (seed + 43758.5453123)); }
float round(float val) { return fract(val) >= 0.5? ceil(val) : floor(val); } float round(float val) { return fract(val) >= 0.5? ceil(val) : floor(val); }
void main() { void main() {
@ -93,7 +101,10 @@ void main() {
} }
} }
vec4 clr = colorTo[int(round(float(min_index) / float(colorFrom_amo - 1) * float(colorTo_amo - 1)))]; vec4 clr = vec4(0.);
if(mode == 0) clr = colorTo[int(round(float(min_index) / float(colorFrom_amo - 1) * float(colorTo_amo - 1)))];
else if(mode == 1) clr = colorTo[int(round(random(float(min_index)) * float(colorTo_amo - 1)))];
if(min_df < treshold) { if(min_df < treshold) {
if(hardReplace == 0) { if(hardReplace == 0) {

View file

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

View file

@ -4,6 +4,7 @@ varying vec4 v_vColour;
#define PI 3.14159265359 #define PI 3.14159265359
#define PALETTE_LIMIT 128 #define PALETTE_LIMIT 128
uniform float seed;
uniform vec2 dimension; uniform vec2 dimension;
uniform vec2 position; uniform vec2 position;
uniform int blend; uniform int blend;
@ -167,7 +168,7 @@ uniform int paletteAmount;
#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// #endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
float random (in vec2 st) { return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); } float random (in vec2 st) { return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * (seed + 43758.5453123)); }
void main() { #region void main() { #region
#region params #region params