This commit is contained in:
Tanasart 2023-11-28 15:42:22 +07:00
parent 68cc32252c
commit 5c1c92ce03
14 changed files with 214 additions and 244 deletions

View file

@ -39,10 +39,10 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"CRUD","folderPath":"folders/_extensions/FireBase/Firebase Firestore/Testing/CRUD.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"Query","folderPath":"folders/_extensions/FireBase/Firebase Firestore/Testing/Query.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"Firebase Utils","folderPath":"folders/_extensions/FireBase/Firebase Utils.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"WinMan","folderPath":"folders/_extensions/WinMan.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"GMD3D11","folderPath":"folders/_extensions/GMD3D11.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"MAC","folderPath":"folders/_extensions/MAC.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"patreon","folderPath":"folders/_extensions/patreon.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"WinMan","folderPath":"folders/_extensions/WinMan.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"addons","folderPath":"folders/addons.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"custom","folderPath":"folders/addons/custom.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"key displayer","folderPath":"folders/addons/key displayer.yy",},

View file

@ -242,7 +242,7 @@ function loadGradient(path) { #region
globalvar GRADIENTS;
GRADIENTS = [];
function __initGradient() {
function __initGradient() { #region
GRADIENTS = [];
var path = DIRECTORY + "Gradients/"
@ -256,4 +256,4 @@ function __initGradient() {
file = file_find_next();
}
file_find_close();
}
} #endregion

View file

@ -23,9 +23,11 @@ function Node_3D_Material(_x, _y, _group = noone) : Node_3D(_x, _y, _group) cons
inputs[| 7] = nodeValue("Roughness", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1 )
.setDisplay(VALUE_DISPLAY.slider);
inputs[| 8] = nodeValue("Anti aliasing", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
outputs[| 0] = nodeValue("Material", self, JUNCTION_CONNECT.output, VALUE_TYPE.d3Material, noone);
input_display_list = [ 0,
input_display_list = [ 0, 8,
["Properties", false], 1, 2, 3, 4, 7,
["Normal", false], 5, 6,
];
@ -39,6 +41,7 @@ function Node_3D_Material(_x, _y, _group = noone) : Node_3D(_x, _y, _group) cons
var _nor = _data[5];
var _norS = _data[6];
var _roug = _data[7];
var _aa = _data[8];
if(!is_surface(_surf)) {
solid_surf = surface_verify(solid_surf, 1, 1);
@ -50,6 +53,7 @@ function Node_3D_Material(_x, _y, _group = noone) : Node_3D(_x, _y, _group) cons
_mat.specular = _spec;
_mat.shine = _shin;
_mat.metalic = _metl;
_mat.texFilter = _aa;
_mat.normal = _nor;
_mat.normalStr = _norS;

View file

@ -1,5 +1,6 @@
function Node_Combine_RGB(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "RGB Combine";
dimension_index = -1;
inputs[| 0] = nodeValue("Red", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| 1] = nodeValue("Green", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
@ -29,6 +30,13 @@ function Node_Combine_RGB(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
var _mode = _data[4];
var _base = _data[5];
var _baseS = _r;
if(!is_surface(_baseS)) _baseS = _g;
if(!is_surface(_baseS)) _baseS = _b;
if(!is_surface(_baseS)) return _outSurf;
_outSurf = surface_verify(_outSurf, surface_get_width_safe(_baseS), surface_get_height_safe(_baseS));
surface_set_shader(_outSurf, sh_combine_rgb);
shader_set_surface("samplerR", _r);
shader_set_surface("samplerG", _g);

View file

@ -1,23 +1,6 @@
function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Grid";
shader = sh_grid;
uniform_pos = shader_get_uniform(shader, "position");
uniform_dim = shader_get_uniform(shader, "dimension");
uniform_sca = shader_get_uniform(shader, "scale");
uniform_wid = shader_get_uniform(shader, "width");
uniform_ang = shader_get_uniform(shader, "angle");
uniform_shf = shader_get_uniform(shader, "shift");
uniform_shx = shader_get_uniform(shader, "shiftAxis");
uniform_mod = shader_get_uniform(shader, "mode");
uniform_sed = shader_get_uniform(shader, "seed");
uniform_grad_blend = shader_get_uniform(shader, "gradient_blend");
uniform_grad = shader_get_uniform(shader, "gradient_color");
uniform_grad_time = shader_get_uniform(shader, "gradient_time");
uniform_grad_key = shader_get_uniform(shader, "gradient_keys");
uniform_col_gap = shader_get_uniform(shader, "gapCol");
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
.setDisplay(VALUE_DISPLAY.vector);
@ -51,10 +34,12 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
inputs[| 11] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, irandom_range(10000, 99999));
inputs[| 12] = nodeValue("Anti aliasing", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
input_display_list = [
["Output", false], 0,
["Pattern", false], 1, 4, 2, 3, 9, 8,
["Render", false], 10, 11, 5, 6, 7
["Render", false], 10, 11, 5, 6, 7, 12,
];
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
@ -76,6 +61,7 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _shx = _data[9];
var _mode = _data[10];
var _sed = _data[11];
var _aa = _data[12];
var _col_gap = _data[6];
var _gra = _data[5];
@ -90,32 +76,24 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_target(_outSurf);
DRAW_CLEAR
shader_set(shader);
shader_set_uniform_f(uniform_pos, _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_uniform_f(uniform_dim, _dim[0], _dim[1]);
shader_set_uniform_f_array_safe(uniform_sca, _sca);
shader_set_uniform_f(uniform_wid, _wid);
shader_set_uniform_f(uniform_ang, degtorad(_ang));
shader_set_uniform_f(uniform_shf, _shx? _shf / _sca[1] : _shf / _sca[0]);
shader_set_uniform_f(uniform_sed, _sed);
shader_set_uniform_i(uniform_shx, _shx);
shader_set_uniform_i(uniform_mod, _mode);
surface_set_shader(_outSurf, sh_grid);
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_f("dimension", _dim[0], _dim[1]);
shader_set_f("scale", _sca);
shader_set_f("width", _wid);
shader_set_f("angle", degtorad(_ang));
shader_set_f("shift", _shx? _shf / _sca[1] : _shf / _sca[0]);
shader_set_f("seed", _sed);
shader_set_i("shiftAxis", _shx);
shader_set_i("mode", _mode);
shader_set_i("aa", _aa);
shader_set_color("gapCol", _col_gap);
shader_set_uniform_f_array_safe(uniform_col_gap, colToVec4(_col_gap));
_gra.shader_submit();
shader_set_uniform_i(uniform_grad_blend, _gra.type);
shader_set_uniform_f_array_safe(uniform_grad, _grad_color);
shader_set_uniform_f_array_safe(uniform_grad_time, _grad_time);
shader_set_uniform_i(uniform_grad_key, array_length(_gra.keys));
if(is_surface(_sam))
draw_surface_stretched_safe(_sam, 0, 0, _dim[0], _dim[1]);
else
draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
shader_reset();
surface_reset_target();
if(is_surface(_sam)) draw_surface_stretched_safe(_sam, 0, 0, _dim[0], _dim[1]);
else draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
surface_reset_shader();
return _outSurf;
}

View file

@ -1,21 +1,6 @@
function Node_Grid_Hex(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Hexagonal Grid";
shader = sh_grid_hex;
uniform_dim = shader_get_uniform(shader, "dimension");
uniform_pos = shader_get_uniform(shader, "position");
uniform_sca = shader_get_uniform(shader, "scale");
uniform_rot = shader_get_uniform(shader, "angle");
uniform_thk = shader_get_uniform(shader, "thick");
uniform_mod = shader_get_uniform(shader, "mode");
uniform_sed = shader_get_uniform(shader, "seed");
uniform_grad_blend = shader_get_uniform(shader, "gradient_blend");
uniform_grad = shader_get_uniform(shader, "gradient_color");
uniform_grad_time = shader_get_uniform(shader, "gradient_time");
uniform_grad_key = shader_get_uniform(shader, "gradient_keys");
uniform_col_gap = shader_get_uniform(shader, "gapCol");
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
.setDisplay(VALUE_DISPLAY.vector);
@ -43,10 +28,12 @@ function Node_Grid_Hex(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
inputs[| 9] = nodeValue("Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| 10] = nodeValue("Anti aliasing", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
input_display_list = [
["Output", false], 0,
["Pattern", false], 1, 3, 2, 4,
["Render", false], 7, 8, 5, 6, 9,
["Render", false], 7, 8, 5, 6, 9, 10,
];
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
@ -66,6 +53,7 @@ function Node_Grid_Hex(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var _mode = _data[7];
var _sed = _data[8];
var _sam = _data[9];
var _aa = _data[10];
var _col_gap = _data[6];
var _gra = _data[5];
@ -80,30 +68,22 @@ function Node_Grid_Hex(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_target(_outSurf);
DRAW_CLEAR
shader_set(shader);
shader_set_uniform_f(uniform_dim, _dim[0], _dim[1]);
shader_set_uniform_f(uniform_pos, _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_uniform_f(uniform_sca, _sca[0], _sca[1]);
shader_set_uniform_f(uniform_rot, degtorad(_rot));
shader_set_uniform_f(uniform_thk, _thk);
shader_set_uniform_f(uniform_sed, _sed);
shader_set_uniform_i(uniform_mod, _mode);
surface_set_shader(_outSurf, sh_grid_hex);
shader_set_f("dimension", _dim[0], _dim[1]);
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_f("scale", _sca[0], _sca[1]);
shader_set_f("angle", degtorad(_rot));
shader_set_f("thick", _thk);
shader_set_f("seed", _sed);
shader_set_i("mode", _mode);
shader_set_i("aa", _aa);
shader_set_color("gapCol",_col_gap);
shader_set_uniform_f_array_safe(uniform_col_gap, colToVec4(_col_gap));
_gra.shader_submit();
shader_set_uniform_i(uniform_grad_blend, _gra.type);
shader_set_uniform_f_array_safe(uniform_grad, _grad_color);
shader_set_uniform_f_array_safe(uniform_grad_time, _grad_time);
shader_set_uniform_i(uniform_grad_key, array_length(_gra.keys));
if(is_surface(_sam))
draw_surface_stretched_safe(_sam, 0, 0, _dim[0], _dim[1]);
else
draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
shader_reset();
surface_reset_target();
if(is_surface(_sam)) draw_surface_stretched_safe(_sam, 0, 0, _dim[0], _dim[1]);
else draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
surface_reset_shader();
return _outSurf;
}

View file

@ -1,21 +1,6 @@
function Node_Grid_Tri(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Triangle Grid";
shader = sh_grid_tri;
uniform_pos = shader_get_uniform(shader, "position");
uniform_dim = shader_get_uniform(shader, "dimension");
uniform_sca = shader_get_uniform(shader, "scale");
uniform_wid = shader_get_uniform(shader, "width");
uniform_ang = shader_get_uniform(shader, "angle");
uniform_mod = shader_get_uniform(shader, "mode");
uniform_sed = shader_get_uniform(shader, "seed");
uniform_grad_blend = shader_get_uniform(shader, "gradient_blend");
uniform_grad = shader_get_uniform(shader, "gradient_color");
uniform_grad_time = shader_get_uniform(shader, "gradient_time");
uniform_grad_key = shader_get_uniform(shader, "gradient_keys");
uniform_col_gap = shader_get_uniform(shader, "gapCol");
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
.setDisplay(VALUE_DISPLAY.vector);
@ -43,10 +28,12 @@ function Node_Grid_Tri(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
inputs[| 9] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, irandom_range(10000, 99999));
inputs[| 10] = nodeValue("Anti aliasing", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
input_display_list = [
["Output", false], 0,
["Pattern", false], 1, 4, 2, 3,
["Render", false], 8, 9, 5, 6, 7
["Render", false], 8, 9, 5, 6, 7, 10,
];
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
@ -66,6 +53,7 @@ function Node_Grid_Tri(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var _sam = _data[7];
var _mode = _data[8];
var _sed = _data[9];
var _aa = _data[10];
var _col_gap = _data[6];
var _gra = _data[5];
@ -80,30 +68,22 @@ function Node_Grid_Tri(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_target(_outSurf);
DRAW_CLEAR
shader_set(shader);
shader_set_uniform_f(uniform_pos, _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_uniform_f(uniform_dim, _dim[0], _dim[1]);
shader_set_uniform_f_array_safe(uniform_sca, _sca);
shader_set_uniform_f(uniform_wid, _wid);
shader_set_uniform_f(uniform_ang, degtorad(_ang));
shader_set_uniform_f(uniform_sed, _sed);
shader_set_uniform_i(uniform_mod, _mode);
surface_set_shader(_outSurf, sh_grid_tri);
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_f("dimension", _dim[0], _dim[1]);
shader_set_f("scale", _sca);
shader_set_f("width", _wid);
shader_set_f("angle", degtorad(_ang));
shader_set_f("seed", _sed);
shader_set_i("mode", _mode);
shader_set_i("aa", _aa);
shader_set_color("gapCol",_col_gap);
shader_set_uniform_f_array_safe(uniform_col_gap, colToVec4(_col_gap));
_gra.shader_submit();
shader_set_uniform_i(uniform_grad_blend, _gra.type);
shader_set_uniform_f_array_safe(uniform_grad, _grad_color);
shader_set_uniform_f_array_safe(uniform_grad_time, _grad_time);
shader_set_uniform_i(uniform_grad_key, array_length(_gra.keys));
if(is_surface(_sam))
draw_surface_stretched_safe(_sam, 0, 0, _dim[0], _dim[1]);
else
draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
shader_reset();
surface_reset_target();
if(is_surface(_sam)) draw_surface_stretched_safe(_sam, 0, 0, _dim[0], _dim[1]);
else draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
surface_reset_shader();
return _outSurf;
}

View file

@ -1722,26 +1722,17 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
function doBlend() { #region
if(array_length(nodes_selecting) != 2) return;
var cx = nodes_selecting[0].x;
var cy = 0;
for(var i = 0; i < array_length(nodes_selecting); i++) {
var _node = nodes_selecting[i];
cx = max(cx, _node.x);
cy += _node.y;
}
cx = cx + 160;
cy = round(cy / array_length(nodes_selecting) / 32) * 32;
var _n0 = nodes_selecting[0].y < nodes_selecting[1].y? nodes_selecting[0] : nodes_selecting[1];
var _n1 = nodes_selecting[0].y < nodes_selecting[1].y? nodes_selecting[1] : nodes_selecting[0];
if(_n0.outputs[| 0].type != VALUE_TYPE.surface || _n1.outputs[| 0].type != VALUE_TYPE.surface) return;
var cx = max(_n0.x, _n1.x) + 160;
var cy = round((_n0.y + _n1.y) / 2 / 32) * 32;
var _blend = new Node_Blend(cx, cy, getCurrentContext());
var index = 0;
for( var i = 0; i < array_length(nodes_selecting); i++ ) {
var _node = nodes_selecting[i];
if(ds_list_size(_node.outputs) == 0) continue;
if(_node.outputs[| 0].type == VALUE_TYPE.surface) {
_blend.inputs[| index].setFrom(_node.outputs[| 0]);
index++;
}
}
_blend.inputs[| 0].setFrom(_n0.outputs[| 0]);
_blend.inputs[| 1].setFrom(_n1.outputs[| 0]);
nodes_selecting = [];
} #endregion
@ -1751,26 +1742,34 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
var cx = nodes_selecting[0].x;
var cy = 0;
var pr = ds_priority_create();
var amo = array_length(nodes_selecting);
var len = 0;
for(var i = 0; i < array_length(nodes_selecting); i++) {
for(var i = 0; i < amo; i++) {
var _node = nodes_selecting[i];
if(ds_list_size(_node.outputs) == 0) continue;
if(_node.outputs[| 0].type != VALUE_TYPE.surface) continue;
cx = max(cx, _node.x);
cy += _node.y;
ds_priority_add(pr, _node, _node.y);
len++;
}
cx = cx + 160;
cy = round(cy / array_length(nodes_selecting) / 32) * 32;
cy = round(cy / len / 32) * 32;
var _compose = nodeBuild("Node_Composite", cx, cy);
for( var i = 0; i < array_length(nodes_selecting); i++ ) {
var _node = nodes_selecting[i];
if(ds_list_size(_node.outputs) == 0) continue;
if(_node.outputs[| 0].type == VALUE_TYPE.surface) {
_compose.addInput(_node.outputs[| 0]);
}
repeat(len) {
var _node = ds_priority_delete_min(pr);
_compose.addInput(_node.outputs[| 0]);
}
nodes_selecting = [];
ds_priority_destroy(pr);
} #endregion
function doArray() { #region

View file

@ -223,6 +223,7 @@
window_set_position(display_get_width() / 2 - ww / 2, display_get_height() / 2 - hh / 2);
window_set_size(ww, hh);
gameframe_set_shadow(true);
}
}

View file

@ -136,7 +136,7 @@ function winManStep() { #region
if(window_drag_hold == 0 && window_is_maximized) {
if(point_distance(mx, my, _mx, _my) > 8)
window_drag_hold = 1;
} else if(window_drag_hold == 1) {
} else {
if(window_is_maximized) {
winMan_Unmaximize();
window_drag_sw = window_minimize_size[0];

View file

@ -17,7 +17,7 @@ uniform int useB;
uniform int useA;
float sample(vec4 col, int ch) {
if(mode == 0) return (col[0] + col[1] + col[2]) / 3.;
if(mode == 0) return (col[0] + col[1] + col[2]) / 3. * col[3];
return col[ch];
}

View file

@ -13,20 +13,20 @@ uniform float angle;
uniform float width;
uniform float shift;
uniform float seed;
uniform int shiftAxis;
uniform int shiftAxis;
uniform int mode;
uniform int aa;
uniform int mode;
uniform vec4 gapCol;
uniform int gradient_use;
uniform int gradient_blend;
uniform vec4 gradient_color[GRADIENT_LIMIT];
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_keys;
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) {
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));
@ -34,21 +34,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);
@ -58,9 +58,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++) {
@ -88,9 +88,9 @@ vec4 gradientEval(in float prog) {
}
return col;
}
} #endregion
void main() {
void main() { #region
vec2 pos = v_vTexcoord - position, _pos;
float ratio = dimension.x / dimension.y;
_pos.x = pos.x * ratio * cos(angle) - pos.y * sin(angle);
@ -108,22 +108,28 @@ void main() {
_pos.y += shiftY;
}
vec2 sqSt = floor(_pos * scale) / scale;
vec2 dist = _pos - sqSt;
float ww = width / 2.;
bool isGap = dist != clamp(dist, vec2(ww), vec2(1. / scale - ww));
vec2 sqSt = floor(_pos * scale) / scale;
vec2 _dist = _pos - sqSt;
vec2 nPos = abs(_dist * scale - vec2(0.5)) * 2.; //distance in x, y axis
float dist = 1. - max(nPos.x, nPos.y);
vec4 colr;
if(mode == 1) {
gl_FragColor = vec4(vec3(dist), 1.);
return;
}
if(mode == 0) {
gl_FragColor = isGap? gapCol : vec4(gradientEval(random(sqSt)).rgb, 1.);
} else if(mode == 1) {
vec2 nPos = abs(dist * scale - vec2(0.5)) * 2.; //distance in x, y axis
float d = 1. - max(nPos.x, nPos.y);
gl_FragColor = vec4(vec3(d), 1.);
colr = vec4(gradientEval(random(sqSt)).rgb, 1.);
} else if(mode == 2) {
vec2 uv = fract(_pos * scale);
gl_FragColor = isGap? gapCol : texture2D( gm_BaseTexture, uv );
colr = texture2D( gm_BaseTexture, uv );
} else if(mode == 3) {
vec2 uv = fract(sqSt);
gl_FragColor = isGap? gapCol : texture2D( gm_BaseTexture, uv );
colr = texture2D( gm_BaseTexture, uv );
}
}
float _aa = 4. / max(dimension.x, dimension.y);
gl_FragColor = mix(gapCol, colr, aa == 1? smoothstep(width - _aa, width, dist) : step(width, dist));
} #endregion

View file

@ -9,21 +9,21 @@ uniform vec2 scale;
uniform float angle;
uniform float thick;
uniform float seed;
uniform int mode;
uniform int aa;
uniform int mode;
uniform vec4 gapCol;
uniform int gradient_use;
uniform int gradient_blend;
uniform vec4 gradient_color[GRADIENT_LIMIT];
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_keys;
#define PI 3.14159265359
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) {
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));
@ -31,21 +31,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);
@ -55,9 +55,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++) {
@ -85,18 +85,18 @@ vec4 gradientEval(in float prog) {
}
return col;
}
} #endregion
float HexDist(vec2 p) {
float HexDist(vec2 p) { #region
p = abs(p);
float c = dot(p, normalize(vec2(1, 1.73)));
c = max(c, p.x);
return c;
}
} #endregion
vec4 HexCoords(vec2 uv) {
vec4 HexCoords(vec2 uv) { #region
vec2 r = vec2(1, sqrt(3.));
vec2 h = r * .5;
@ -109,16 +109,21 @@ vec4 HexCoords(vec2 uv) {
float y = max(0., .5 - HexDist(gv));
vec2 id = uv - gv;
return vec4(x, y, id.x, id.y);
}
} #endregion
void main() {
void main() { #region
vec2 pos = (v_vTexcoord - position) * scale, _pos;
float ratio = dimension.x / dimension.y;
_pos.x = pos.x * ratio * cos(angle) - pos.y * sin(angle);
_pos.y = pos.x * ratio * sin(angle) + pos.y * cos(angle);
vec4 hc = HexCoords(_pos);
bool isGap = hc.y < thick;
vec4 colr;
if(mode == 1) {
gl_FragColor = vec4(vec3(hc.y), 1.0);
return;
}
if(mode == 0) {
vec2 uv = abs(hc.zw) / scale;
@ -128,15 +133,17 @@ void main() {
float tileY = floor(scale.y * 4. / 3.);
uv.y = mod(floor(uv.y * (tileY + 1.)), tileY) / tileY;
gl_FragColor = isGap? gapCol : vec4(gradientEval(random(uv)).rgb, 1.);
} else if(mode == 1) {
gl_FragColor = vec4(vec3(hc.y), 1.0);
colr = vec4(gradientEval(random(uv)).rgb, 1.);
} else if(mode == 2) {
vec2 uv = hc.xy;
uv.x = (uv.x + PI / 2.) / PI;
gl_FragColor = isGap? gapCol : texture2D( gm_BaseTexture, uv );
colr = texture2D( gm_BaseTexture, uv );
} else if(mode == 3) {
vec2 uv = clamp(abs(hc.zw) / scale, 0., 1.);
gl_FragColor = isGap? gapCol : texture2D( gm_BaseTexture, uv );
colr = texture2D( gm_BaseTexture, uv );
}
}
float _aa = 3. / max(dimension.x, dimension.y);
gl_FragColor = mix(gapCol, colr, aa == 1? smoothstep(thick - _aa, thick, hc.y) : step(thick, hc.y));
} #endregion

View file

@ -14,19 +14,20 @@ uniform vec2 scale;
uniform float angle;
uniform float width;
uniform float seed;
uniform int aa;
uniform int mode;
uniform vec4 gapCol;
uniform int gradient_use;
uniform int gradient_blend;
uniform vec4 gradient_color[GRADIENT_LIMIT];
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_keys;
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) {
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));
@ -34,21 +35,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);
@ -58,9 +59,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++) {
@ -88,9 +89,9 @@ vec4 gradientEval(in float prog) {
}
return col;
}
} #endregion
vec3 triGrid(vec2 p){
vec3 triGrid(vec2 p){ #region
float _stx = (p.x + c30 / 2.0 * p.y);
float stx = abs(fract(_stx) - 0.5);
@ -105,9 +106,9 @@ vec3 triGrid(vec2 p){
n = (n - .16) / (.35 - .16);
return vec3((floor(_stx) + floor(_sty) + 1.) / 2., floor(p.y * c30), n);
}
} #endregion
void main() {
void main() { #region
vec2 pos = (v_vTexcoord - position) * scale, _pos;
float ratio = dimension.x / dimension.y;
_pos.x = pos.x * ratio * cos(angle) - pos.y * sin(angle);
@ -115,18 +116,24 @@ void main() {
vec3 tri = triGrid(_pos);
float dist = max(0., tri.z);
bool isGap = dist < width * 2.;
vec4 colr;
if(mode == 1) {
gl_FragColor = vec4(vec3(dist), 1.);
return;
}
if(mode == 0) {
vec2 uv = fract(tri.xy / scale);
gl_FragColor = isGap? gapCol : vec4(gradientEval(random(uv)).rgb, 1.);
} else if(mode == 1) {
gl_FragColor = vec4(vec3(dist), 1.);
colr = vec4(gradientEval(random(uv)).rgb, 1.);
} else if(mode == 2) {
vec2 uv = fract((_pos * vec2(1., c30) - tri.xy) + vec2(0.5, 0.));
gl_FragColor = isGap? gapCol : texture2D( gm_BaseTexture, uv );
colr = texture2D( gm_BaseTexture, uv );
} else if(mode == 3) {
vec2 uv = clamp(tri.xy / scale, 0., 1.);
gl_FragColor = isGap? gapCol : texture2D( gm_BaseTexture, uv );
colr = texture2D( gm_BaseTexture, uv );
}
}
float _aa = 3. / max(dimension.x, dimension.y);
gl_FragColor = mix(gapCol, colr, aa == 1? smoothstep(width * 2. - _aa, width * 2., dist) : step(width * 2., dist));
} #endregion