- [Slider Range] Fix slider stucking at 1 when dragging.

This commit is contained in:
Tanasart 2024-06-10 10:53:25 +07:00
parent 4567c6d89a
commit ff8b4af9bb
26 changed files with 418 additions and 62 deletions

View file

@ -1063,6 +1063,7 @@
{"name":"node_unicode","order":1,"path":"scripts/node_unicode/node_unicode.yy",},
{"name":"node_value_base","order":17,"path":"scripts/node_value_base/node_value_base.yy",},
{"name":"node_value_types","order":18,"path":"scripts/node_value_types/node_value_types.yy",},
{"name":"node_value_validators","order":19,"path":"scripts/node_value_validators/node_value_validators.yy",},
{"name":"node_value","order":5,"path":"scripts/node_value/node_value.yy",},
{"name":"node_vector_cross_2D","order":11,"path":"scripts/node_vector_cross_2D/node_vector_cross_2D.yy",},
{"name":"node_vector_cross_3D","order":10,"path":"scripts/node_vector_cross_3D/node_vector_cross_3D.yy",},
@ -1478,6 +1479,7 @@
{"name":"sh_perlin_tiled","order":15,"path":"shaders/sh_perlin_tiled/sh_perlin_tiled.yy",},
{"name":"sh_perlin","order":12,"path":"shaders/sh_perlin/sh_perlin.yy",},
{"name":"sh_pixel_cloud","order":4,"path":"shaders/sh_pixel_cloud/sh_pixel_cloud.yy",},
{"name":"sh_pixel_sample","order":27,"path":"shaders/sh_pixel_sample/sh_pixel_sample.yy",},
{"name":"sh_pixel_sort","order":20,"path":"shaders/sh_pixel_sort/sh_pixel_sort.yy",},
{"name":"sh_polar","order":1,"path":"shaders/sh_polar/sh_polar.yy",},
{"name":"sh_posterize_palette","order":5,"path":"shaders/sh_posterize_palette/sh_posterize_palette.yy",},

View file

@ -1520,6 +1520,7 @@
{"id":{"name":"node_unicode","path":"scripts/node_unicode/node_unicode.yy",},},
{"id":{"name":"node_value_base","path":"scripts/node_value_base/node_value_base.yy",},},
{"id":{"name":"node_value_types","path":"scripts/node_value_types/node_value_types.yy",},},
{"id":{"name":"node_value_validators","path":"scripts/node_value_validators/node_value_validators.yy",},},
{"id":{"name":"node_value","path":"scripts/node_value/node_value.yy",},},
{"id":{"name":"node_VCT","path":"scripts/node_VCT/node_VCT.yy",},},
{"id":{"name":"node_vector_cross_2D","path":"scripts/node_vector_cross_2D/node_vector_cross_2D.yy",},},
@ -2009,6 +2010,7 @@
{"id":{"name":"sh_perlin_tiled","path":"shaders/sh_perlin_tiled/sh_perlin_tiled.yy",},},
{"id":{"name":"sh_perlin","path":"shaders/sh_perlin/sh_perlin.yy",},},
{"id":{"name":"sh_pixel_cloud","path":"shaders/sh_pixel_cloud/sh_pixel_cloud.yy",},},
{"id":{"name":"sh_pixel_sample","path":"shaders/sh_pixel_sample/sh_pixel_sample.yy",},},
{"id":{"name":"sh_pixel_sort","path":"shaders/sh_pixel_sort/sh_pixel_sort.yy",},},
{"id":{"name":"sh_polar","path":"shaders/sh_polar/sh_polar.yy",},},
{"id":{"name":"sh_posterize_palette","path":"shaders/sh_posterize_palette/sh_posterize_palette.yy",},},

View file

@ -3,7 +3,8 @@ function Node_3D_Mesh_Cone(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group
object_class = __3dCone;
inputs[| in_mesh + 0] = nodeValue("Side", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8 );
inputs[| in_mesh + 0] = nodeValue("Side", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8 )
.setValidator(VV_min(3));
inputs[| in_mesh + 1] = nodeValue("Material Bottom", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Material, new __d3dMaterial() )
.setVisible(true, true);

View file

@ -3,7 +3,8 @@ function Node_3D_Mesh_Cylinder(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _g
object_class = __3dCylinder;
inputs[| in_mesh + 0] = nodeValue("Side", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8 );
inputs[| in_mesh + 0] = nodeValue("Side", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8 )
.setValidator(VV_min(3));
inputs[| in_mesh + 1] = nodeValue("Material Top", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Material, new __d3dMaterial() )
.setVisible(true, true);

View file

@ -3,7 +3,8 @@ function Node_3D_Mesh_Sphere_Ico(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y,
object_class = __3dICOSphere;
inputs[| in_mesh + 0] = nodeValue("Subdivision", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1 );
inputs[| in_mesh + 0] = nodeValue("Subdivision", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1 )
.setValidator(VV_min(0));
inputs[| in_mesh + 1] = nodeValue("Material", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Material, new __d3dMaterial() )
.setVisible(true, true);

View file

@ -3,9 +3,11 @@ function Node_3D_Mesh_Sphere_UV(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _
object_class = __3dUVSphere;
inputs[| in_mesh + 0] = nodeValue("Horizontal Slices", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8 );
inputs[| in_mesh + 0] = nodeValue("Horizontal Slices", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8 )
.setValidator(VV_min(2));
inputs[| in_mesh + 1] = nodeValue("Vertical Slices", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 16 );
inputs[| in_mesh + 1] = nodeValue("Vertical Slices", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 16 )
.setValidator(VV_min(3));
inputs[| in_mesh + 2] = nodeValue("Material", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Material, new __d3dMaterial() )
.setVisible(true, true);

View file

@ -5,7 +5,8 @@ function Node_Blobify(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
inputs[| 1] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
inputs[| 2] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 3);
inputs[| 2] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 3)
.setValidator(VV_min(0));
inputs[| 3] = nodeValue("Threshold", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.5)
.setDisplay(VALUE_DISPLAY.slider);

View file

@ -4,6 +4,7 @@ function Node_Erode(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| 1] = nodeValue("Width", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1)
.setValidator(VV_min(0))
.setMappable(10);
inputs[| 2] = nodeValue("Preserve border",self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);

View file

@ -15,7 +15,7 @@ function Node_Flow_Noise(_x, _y, _group = noone) : Node_Shader_Generator(_x, _y,
addShaderProp(SHADER_UNIFORM.float, "progress");
inputs[| 4] = nodeValue("Detail", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 1, 8 ])
.setDisplay(VALUE_DISPLAY.slider_range, { range: [ 1, 16, 0.1 ] });
.setDisplay(VALUE_DISPLAY.slider_range, { range: [ 1, 16, 1 ] });
addShaderProp(SHADER_UNIFORM.float, "detail");
inputs[| 5] = nodeValue("Rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)

View file

@ -7,6 +7,7 @@ function Node_Image_Grid(_x, _y, _group = noone) : Node(_x, _y, _group) construc
.rejectArray();
inputs[| 1] = nodeValue("Column", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 4)
.setValidator(VV_min(1))
.rejectArray();
inputs[| 2] = nodeValue("Spacing", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 0, 0 ])

View file

@ -2,7 +2,7 @@ function Node_IsoSurf(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
name = "IsoSurf";
inputs[| 0] = nodeValue("Direction", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 4)
.setRange(1, undefined);
.setValidator(VV_min(1));
inputs[| 1] = nodeValue("Surfaces", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone)
.setVisible(true, true)

View file

@ -6,11 +6,13 @@ function Node_JPEG(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
inputs[| 1] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 1;
inputs[| 2] = nodeValue("Patch Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8);
inputs[| 2] = nodeValue("Patch Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8)
.setValidator(VV_min(1));
inputs[| 3] = nodeValue("Compression", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 10);
inputs[| 4] = nodeValue("Reconstruction", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8);
inputs[| 4] = nodeValue("Reconstruction", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8)
.setValidator(VV_min(0));
inputs[| 5] = nodeValue("Mask", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
@ -30,11 +32,13 @@ function Node_JPEG(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
inputs[| 12] = nodeValue("Deconstruct Only", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false)
inputs[| 13] = nodeValue("Reconstruct All", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false)
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [ 1,
["Surface", false], 0, 5, 6, 7,
["Effects", false], 2, 3, 4, 10, 11, 12,
["Effects", false], 2, 3, 13, 4, 10, 11, 12,
];
temp_surface = array_create(2);
@ -43,6 +47,10 @@ function Node_JPEG(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
static step = function() { #region
__step_mask_modifier();
var _reall = getSingleValue(13);
inputs[| 4].setVisible(!_reall);
} #endregion
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
@ -53,6 +61,7 @@ function Node_JPEG(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _tran = _data[10];
var _phas = _data[11];
var _recon = _data[12];
var _reall = _data[13];
var _dim = surface_get_dimension(_surf);
@ -73,7 +82,7 @@ function Node_JPEG(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
surface_set_shader(temp_surface[1], sh_jpeg_recons);
shader_set_f("dimension", _dim);
shader_set_i("patch", _patc);
shader_set_i("reconstruct", _recn);
shader_set_i("reconstruct", _reall? _patc : _recn);
shader_set_f("phase", degtorad(_phas));
shader_set_i("transform", _tran);

View file

@ -6,7 +6,8 @@ function Node_Kuwahara(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
inputs[| 1] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 1;
inputs[| 2] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 2);
inputs[| 2] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 2)
.setValidator(VV_min(1));
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);

View file

@ -15,6 +15,7 @@ function Node_Outline(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
inputs[| 1] = nodeValue("Width", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY._default, { front_button : filter_button })
.setValidator(VV_min(0))
.setMappable(15);
inputs[| 2] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
@ -105,6 +106,7 @@ function Node_Outline(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
shader_set_color("borderColor", cl);
shader_set_i("side", side);
shader_set_i("highRes", 0);
shader_set_i("is_aa", aa);
shader_set_i("outline_only", _output_index);
shader_set_i("is_blend", blend);

View file

@ -3,55 +3,113 @@ function Node_Pixel_Sampler(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
inputs[| 0] = nodeValue("Base Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| 1] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, cola(c_white));
inputs[| 1] = nodeValue("Sample Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 )
.setDisplay(VALUE_DISPLAY.enum_button, [ "Keep Size", "Expand" ]);
inputs[| 2] = nodeValue("Empty", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
inputs[| 2] = nodeValue("Match Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 )
.setDisplay(VALUE_DISPLAY.enum_button, [ "Brightness", "RGB Match", "Hue Match" ]);
inputs[| 3] = nodeValue("Surfaces", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, [ noone ] )
.setArrayDepth(1);
inputs[| 3] = nodeValue("Mask", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| 4] = nodeValue("Gradient", self, JUNCTION_CONNECT.input, VALUE_TYPE.gradient, new gradientObject([ c_black, c_white ]) )
.setMappable(5);
inputs[| 5] = nodeValueMap("Gradient map", self);
inputs[| 4] = nodeValue("Use mask dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
inputs[| 6] = nodeValueGradientRange("Gradient map range", self, inputs[| 4]);
inputs[| 7] = nodeValue("Color Blending", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 )
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "None", "Multiply" ]);
inputs[| 8] = nodeValue("Blending Intensity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1 )
.setDisplay(VALUE_DISPLAY.slider);
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [
["Surfaces", false], 0, 3, 4,
["Solid", false], 1, 2,
["Base Texture", false], 0, 1, 2,
["Surface", false], 3, 4, 5,
["Render", false], 7, 8,
];
attribute_surface_depth();
temp_surface = [ noone ];
static step = function() {
inputs[| 4].mappableStep();
}
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _dim = _data[0];
var _col = _data[1];
var _emp = _data[2];
var _msk = _data[3];
var _msd = _data[4];
var _base = _data[0];
var _samp = _data[1];
var _mach = _data[2];
var _maskUse = is_surface(_msk);
var _surf = _data[3];
var _colr = _data[4];
inputs[| 4].setVisible(_maskUse);
if(_maskUse && _msd) _dim = [ surface_get_width_safe(_msk), surface_get_height_safe(_msk) ];
var _blnd = _data[7];
var _bint = _data[8];
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
var _inps = array_length(_surf);
if(_emp) {
surface_set_target(_outSurf);
DRAW_CLEAR
surface_reset_target();
return _outSurf;
if(!is_surface(_base)) return _outSurf;
if(_inps == 0) return _outSurf;
var _dim = surface_get_dimension(_base);
var _tdim = surface_get_dimension(_surf[0]);
temp_surface[0] = surface_verify(temp_surface[0], 8192, 8192);
var _tcol = floor(8192 / _tdim[0]);
surface_set_shader(temp_surface[0], noone);
for(var i = 0; i < _inps; i++) {
var _tex_s = _surf[i];
var _col = i % _tcol;
var _row = floor(i / _tcol);
var _tx = _col * _tdim[0];
var _ty = _row * _tdim[1];
draw_surface_safe(_tex_s, _tx, _ty);
}
surface_reset_shader();
var _ww = _dim[0];
var _hh = _dim[1];
switch(_samp) {
case 0 :
_ww = _dim[0];
_hh = _dim[1];
break;
case 1 :
_ww = _dim[0] * _tdim[0];
_hh = _dim[1] * _tdim[1];
break;
}
if(_maskUse) {
surface_set_shader(_outSurf, sh_solid);
draw_surface_stretched_ext(_msk, 0, 0, _dim[0], _dim[1], _col, _color_get_alpha(_col));
surface_reset_shader();
_outSurf = surface_verify(_outSurf, _ww, _hh);
return _outSurf;
}
surface_set_target(_outSurf);
draw_clear(_col);
surface_reset_target();
surface_set_shader(_outSurf, sh_pixel_sample);
shader_set_f("dimension", [ _ww, _hh ]);
shader_set_f("samplerDimension", _tdim);
shader_set_f("samplerColumn", _tcol);
shader_set_surface("samplers", temp_surface[0]);
shader_set_i("amount", _inps);
shader_set_i("sampleMode", _samp);
shader_set_i("matchMode", _mach);
shader_set_gradient(_data[4], _data[5], _data[6], inputs[| 4]);
shader_set_i("blendMode", _blnd);
shader_set_f("blendIntensity", _bint);
draw_surface_stretched(_base, 0, 0, _ww, _hh);
surface_reset_shader();
return _outSurf;
}

View file

@ -4,7 +4,8 @@ function Node_Rate_Remap(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
inputs[| 0] = nodeValue("Surface", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| 1] = nodeValue("Framerate", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 10);
inputs[| 1] = nodeValue("Framerate", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 10)
.setValidator(VV_min(1));
inputs[| 2] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 2;

View file

@ -737,6 +737,7 @@ function __initNodes() {
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_quasicircle, "Node_Quasicrystal", [1, Node_Quasicrystal]).setVersion(11660);
addNodeObject(generator, "Pixel Sampler", s_node_quasicircle, "Node_Pixel_Sampler", [1, Node_Pixel_Sampler]).setVersion(11730);
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);

View file

@ -16,7 +16,8 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
inputs[| 1] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 2] = nodeValue("Amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8);
inputs[| 2] = nodeValue("Amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8)
.setValidator(VV_min(0));
inputs[| 3] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1, 1, 1 ] )
.setDisplay(VALUE_DISPLAY.vector_range, { linked : true });

View file

@ -126,8 +126,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
__curr_get_val = [ 0, 0 ];
value_range_min = undefined;
value_range_max = undefined;
validator = noone;
#endregion
#region ---- draw ----
@ -312,12 +311,11 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return self;
} #endregion
static setRange = function(_min, _max) { #region
value_range_min = _min;
value_range_max = _max;
static setValidator = function(val) {
validator = val;
return self;
} #endregion
}
static rejectArray = function() { #region
accept_array = false;
@ -1064,8 +1062,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
value[i] = clamp(value[i], 0, 8192);
}
if(value_range_min != undefined) value = max(value, value_range_min);
if(value_range_max != undefined) value = min(value, value_range_max);
if(validator != noone)
value = validator.validate(value);
return value;
} #endregion

View file

@ -0,0 +1,22 @@
function ValueValidator() constructor {
static validate = function(val) { return val; }
}
function VV_min(minimum) { return new __VV_min(minimum); };
function __VV_min(minimum) : ValueValidator() constructor {
self.minimum = minimum;
static validate = function(val) { return max(minimum, val); }
}
function VV_max(maximum) { return new __VV_max(maximum); };
function __VV_max(maximum) : ValueValidator() constructor {
self.maximum = maximum;
static validate = function(val) { return min(maximum, val); }
}
function VV_clamp(minimum, maximum) { return new __VV_clamp(minimum, maximum); };
function __VV_clamp(minimum, maximum) : ValueValidator() constructor {
self.minimum = minimum;
self.maximum = maximum;
static validate = function(val) { return clamp(val, minimum, maximum); }
}

View file

@ -0,0 +1,13 @@
{
"$GMScript":"",
"%Name":"node_value_validators",
"isCompatibility":false,
"isDnD":false,
"name":"node_value_validators",
"parent":{
"name":"__base__",
"path":"folders/nodes/data/__base__.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",
}

View file

@ -72,9 +72,15 @@ function sliderRange(_step, _int, _range, _onModify) : widget() constructor {
draw_sprite_stretched_ext(THEME.textbox, 0, _x, _y, _w, _h, c_white, 0.5 + 0.5 * interactable);
}
tb_value_min.curr_range[0] = curr_range[0];
tb_value_min.curr_range[1] = curr_range[1];
tb_value_min.setFocusHover(active, hover);
tb_value_min.draw(_x, _y, tb_w, _h, _data[0], _m);
tb_value_max.curr_range[0] = curr_range[0];
tb_value_max.curr_range[1] = curr_range[1];
tb_value_max.setFocusHover(active, hover);
tb_value_max.draw(_x + tb_w, _y, tb_w, _h, _data[1], _m);

View file

@ -26,14 +26,15 @@ uniform sampler2D blend_alphaSurf;
uniform int sampleMode;
uniform int outline_only;
uniform int highRes;
vec2 round(in vec2 v) { #region
vec2 round(in vec2 v) {
v.x = fract(v.x) > 0.5? ceil(v.x) : floor(v.x);
v.y = fract(v.y) > 0.5? ceil(v.y) : floor(v.y);
return v;
} #endregion
}
vec4 sampleTexture(vec2 pos) { #region
vec4 sampleTexture(vec2 pos) {
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
return texture2D(gm_BaseTexture, pos);
@ -50,7 +51,7 @@ vec4 sampleTexture(vec2 pos) { #region
return vec4(vec3(0.), 1.);
return vec4(0.);
} #endregion
}
vec4 blendColor(vec4 base, vec4 colr, float alpha) {
@ -80,7 +81,7 @@ bool angleFiltered(float angle) {
return filter[_ind] == 0;
}
void main() { #region
void main() {
#region params
float bStr = borderStart.x;
if(borderStartUseSurf == 1) {
@ -123,12 +124,15 @@ void main() { #region
#endregion
if(bSiz + bStr > 0.) {
for(float i = 1.; i <= 32.; i++) {
if(i > bStr + bSiz + float(is_aa)) break;
float itr = bStr + bSiz + float(is_aa);
float atr = highRes == 1? 256. : 64.;
for(float i = 1.; i <= itr; i++) {
// if(i > bStr + bSiz + float(is_aa)) break;
float base = 1.;
float top = 0.;
for(float j = 0.; j <= 64.; j++) {
for(float j = 0.; j <= atr; j++) {
float ang = top / base * TAU;
top += 2.;
if(top >= base) {
@ -197,4 +201,4 @@ void main() { #region
}
gl_FragColor = col;
} #endregion
}

View file

@ -0,0 +1,197 @@
#define PALETTE_LIMIT 128
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 dimension;
uniform vec2 samplerDimension;
uniform sampler2D samplers;
uniform float samplerColumn;
uniform int amount;
uniform int sampleMode;
uniform int matchMode;
uniform int blendMode;
uniform float blendIntensity;
#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 linearToGamma(vec3 c) { return pow(c, vec3( 2.2)); }
vec3 gammaToLinear(vec3 c) { return pow(c, vec3(1. / 2.2)); }
vec3 rgbMix(vec3 c1, vec3 c2, float t) { #region
vec3 k1 = linearToGamma(c1);
vec3 k2 = linearToGamma(c2);
return gammaToLinear(mix(k1, k2, t));
} #endregion
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));
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) { #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) { #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) { #region
vec3 h1 = rgb2hsv(c1);
vec3 h2 = rgb2hsv(c2);
vec3 h = vec3(0.);
h.x = h.x + hueDist(h1.x, h2.x, t);
h.y = mix(h1.y, h2.y, t);
h.z = mix(h1.z, h2.z, t);
return hsv2rgb(h);
} #endregion
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.);
for(int i = 0; i < GRADIENT_LIMIT; i++) {
if(gradient_time[i] == prog) {
col = gradient_color[i];
break;
} else if(gradient_time[i] > prog) {
if(i == 0)
col = gradient_color[i];
else {
float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]);
vec3 c0 = gradient_color[i - 1].rgb;
vec3 c1 = gradient_color[i].rgb;
float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t);
if(gradient_blend == 0)
col = vec4(mix(c0, c1, t), a);
else if(gradient_blend == 1)
col = gradient_color[i - 1];
else if(gradient_blend == 2)
col = vec4(hsvMix(c0, c1, t), a);
else if(gradient_blend == 3)
col = vec4(oklabMax(c0, c1, t), a);
else if(gradient_blend == 4)
col = vec4(rgbMix(c0, c1, t), a);
}
break;
}
if(i >= gradient_keys - 1) {
col = gradient_color[gradient_keys - 1];
break;
}
}
return col;
} #endregion
#endregion //////////////////////////////////// GRADIENT ////////////////////////////////////
float bright(vec4 c) { return dot(c.rgb, vec3(0.2126, 0.7152, 0.0722)); }
float colorCompare(vec4 c1, vec4 c2) {
if(matchMode == 0) return abs(bright(c1) - bright(c2));
else if(matchMode == 1) return distance(c1.rgb, c2.rgb);
else if(matchMode == 2) return abs(rgb2hsv(c1.rgb)[0] - rgb2hsv(c2.rgb)[0]);
return 0.;
}
void main() {
vec2 tx = v_vTexcoord * dimension;
vec2 ftx = mod(tx, samplerDimension);
vec2 stx = tx - ftx;
vec4 base = texture2D( gm_BaseTexture, stx / dimension);
// gl_FragColor = vec4(ftx / samplerDimension, 0., 1.); return;
int matchIndex = 0;
float minDiff = 9999.;
for(int i = 0; i < amount; i++) {
vec4 clr = gradientEval(float(i) / (float(amount) - 1.));
float dif = colorCompare(base, clr);
if(dif < minDiff) {
minDiff = dif;
matchIndex = i;
}
}
float row = floor(float(matchIndex) / samplerColumn);
float col = float(matchIndex) - row * samplerColumn;
float tsx = col * samplerDimension.x;
float tsy = row * samplerDimension.y;
vec2 tpos = vec2(tsx, tsy) + ftx;
vec4 samp = texture2D( samplers, tpos / 8192.);
vec4 smpb = samp;
if(blendMode == 1) smpb = samp * base;
gl_FragColor = mix(samp, smpb, blendIntensity);
}

View 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;
}

View file

@ -0,0 +1,12 @@
{
"$GMShader":"",
"%Name":"sh_pixel_sample",
"name":"sh_pixel_sample",
"parent":{
"name":"generator",
"path":"folders/shader/generator.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"type":1,
}