- [Inspector Panel] Value in pixel unit now rounded when sliding.

This commit is contained in:
Tanasart 2024-07-11 10:28:15 +07:00
parent cda5f42f7f
commit 9966fdfdb7
13 changed files with 279 additions and 172 deletions

View file

@ -70,17 +70,19 @@ function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr
static postProcess = function() { refreshPreview(); } static postProcess = function() { refreshPreview(); }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover = false, _focus = false) { #region static getGraphPreviewSurface = function() { return mesh_prev_surface; }
if(!is_surface(mesh_prev_surface)) return;
if(!previewable) return; // static onDrawNode = function(xx, yy, _mx, _my, _s, _hover = false, _focus = false) { #region
// if(!is_surface(mesh_prev_surface)) return;
// if(!previewable) return;
var bbox = drawGetBbox(xx, yy, _s); // var bbox = drawGetBbox(xx, yy, _s);
var aa = 0.5 + 0.5 * renderActive; // var aa = 0.5 + 0.5 * renderActive;
if(!isHighlightingInGraph()) aa *= 0.25; // if(!isHighlightingInGraph()) aa *= 0.25;
draw_surface_bbox(mesh_prev_surface, bbox,, aa); // draw_surface_bbox(mesh_prev_surface, bbox,, aa);
onDrawNodeOver(xx, yy, _mx, _my, _s, _hover, _focus); // onDrawNodeOver(xx, yy, _mx, _my, _s, _hover, _focus);
} #endregion // } #endregion
static onDrawNodeOver = function(xx, yy, _mx, _my, _s, _hover = false, _focus = false) { } static onDrawNodeOver = function(xx, yy, _mx, _my, _s, _hover = false, _focus = false) { }
} }

View file

@ -7,6 +7,8 @@ function __3dPathExtrude(radius = 0.5, sides = 8, smooth = false) : __3dObject()
self.sides = sides; self.sides = sides;
self.smooth = smooth; self.smooth = smooth;
invert = false;
loop = false;
endCap = true; endCap = true;
points = []; points = [];
uvProg = []; uvProg = [];
@ -31,8 +33,9 @@ function __3dPathExtrude(radius = 0.5, sides = 8, smooth = false) : __3dObject()
var _in0 = 0; var _in0 = 0;
var _in1 = 0; var _in1 = 0;
var _u0 = new __vec3(0, 1, 0); var _ux = new __vec3(1, 0, 0);
var _u1 = new __vec3(0, 0, 1); var _uy = new __vec3(0, 1, 0);
var _uz = new __vec3(0, 0, 1);
if(_subd < 2) return; if(_subd < 2) return;
@ -43,6 +46,8 @@ function __3dPathExtrude(radius = 0.5, sides = 8, smooth = false) : __3dObject()
var _us = uvScale[0]; var _us = uvScale[0];
var _vs = uvScale[1]; var _vs = uvScale[1];
var firstLoop = array_create(sides * 3);
for(var i = 1; i < _subd; i++) { for(var i = 1; i < _subd; i++) {
n.x = points[i * 3 + 0]; n.x = points[i * 3 + 0];
n.y = points[i * 3 + 1]; n.y = points[i * 3 + 1];
@ -52,10 +57,18 @@ function __3dPathExtrude(radius = 0.5, sides = 8, smooth = false) : __3dObject()
v.x = n.x - o.x; v.x = n.x - o.x;
v.y = n.y - o.y; v.y = n.y - o.y;
v.z = n.z - o.z; v.z = n.z - o.z;
if(loop) {
v.x = n.x - points[(_subd - 2) * 3 + 0];
v.y = n.y - points[(_subd - 2) * 3 + 1];
v.z = n.z - points[(_subd - 2) * 3 + 2];
}
v._normalize(); v._normalize();
if(v.z == v.z) u = v.cross(_u0); if(v.equal(_ux)) u = v.cross(_uz);
else u = v.cross(_u1); else if(v.equal(_uz)) u = v.cross(_uy);
else u = v.cross(_uz);
u._normalize(); u._normalize();
w = v.cross(u); w = v.cross(u);
@ -95,92 +108,106 @@ function __3dPathExtrude(radius = 0.5, sides = 8, smooth = false) : __3dObject()
v0[_in0++] = new __vertex(cx0, cy0, cz0).setNormal(-v.x, -v.y, -v.z).setUV(__u0, __v0); v0[_in0++] = new __vertex(cx0, cy0, cz0).setNormal(-v.x, -v.y, -v.z).setUV(__u0, __v0);
v0[_in0++] = new __vertex(cx1, cy1, cz1).setNormal(-v.x, -v.y, -v.z).setUV(__u1, __v1); v0[_in0++] = new __vertex(cx1, cy1, cz1).setNormal(-v.x, -v.y, -v.z).setUV(__u1, __v1);
} }
}
if(i) {
if(i < _subd - 1) {
v.x = points[(i + 1) * 3 + 0] - o.x;
v.y = points[(i + 1) * 3 + 1] - o.y;
v.z = points[(i + 1) * 3 + 2] - o.z;
} else {
v.x = n.x - o.x;
v.y = n.y - o.y;
v.z = n.z - o.z;
}
v._normalize();
if(v.z == v.z) u = v.cross(_u0);
else u = v.cross(_u1);
u._normalize();
w = v.cross(u);
var _rr = radius * radiusOverPath[i];
var __v0 = 1. - uvProg[i-1];
var __v1 = 1. - uvProg[i ];
// print($"{i}: {__v0} - {__v1}")
for(var j = 0; j <= sides; j++) {
var a0 = j / sides * 360;
var _u = u.multiply(dcos(a0));
var _w = w.multiply(dsin(a0));
var _pp = _u.add(_w);
prevn[j * 3 + 0] = n.x + _pp.x * _rr;
prevn[j * 3 + 1] = n.y + _pp.y * _rr;
prevn[j * 3 + 2] = n.z + _pp.z * _rr;
if(j) {
var x0 = prevp[(j - 1) * 3 + 0];
var y0 = prevp[(j - 1) * 3 + 1];
var z0 = prevp[(j - 1) * 3 + 2];
var x1 = prevp[j * 3 + 0];
var y1 = prevp[j * 3 + 1];
var z1 = prevp[j * 3 + 2];
var x2 = prevn[(j - 1) * 3 + 0];
var y2 = prevn[(j - 1) * 3 + 1];
var z2 = prevn[(j - 1) * 3 + 2];
var x3 = prevn[j * 3 + 0];
var y3 = prevn[j * 3 + 1];
var z3 = prevn[j * 3 + 2];
var _n0, _n1, _n2, _n3;
if(smooth) {
_n0 = new __vec3(x0 - o.x, y0 - o.y, z0 - o.z).normalize();
_n1 = new __vec3(x1 - o.x, y1 - o.y, z1 - o.z).normalize();
_n2 = new __vec3(x2 - n.x, y2 - n.y, z2 - n.z).normalize();
_n3 = new __vec3(x3 - n.x, y3 - n.y, z3 - n.z).normalize();
} else {
_n0 = _pp.normalize();
_n1 = _n0;
_n2 = _n0;
_n3 = _n0;
}
var __u0 = (j-1) / sides;
var __u1 = (j ) / sides;
vs[_ind++] = new __vertex(x0, y0, z0).setNormal(_n0.x, _n0.y, _n0.z).setUV(__u0 * _us, __v0 * _vs);
vs[_ind++] = new __vertex(x2, y2, z2).setNormal(_n2.x, _n2.y, _n2.z).setUV(__u0 * _us, __v1 * _vs);
vs[_ind++] = new __vertex(x1, y1, z1).setNormal(_n1.x, _n1.y, _n1.z).setUV(__u1 * _us, __v0 * _vs);
vs[_ind++] = new __vertex(x1, y1, z1).setNormal(_n1.x, _n1.y, _n1.z).setUV(__u1 * _us, __v0 * _vs);
vs[_ind++] = new __vertex(x2, y2, z2).setNormal(_n2.x, _n2.y, _n2.z).setUV(__u0 * _us, __v1 * _vs);
vs[_ind++] = new __vertex(x3, y3, z3).setNormal(_n3.x, _n3.y, _n3.z).setUV(__u1 * _us, __v1 * _vs);
}
}
for (var j = 0, m = array_length(prevn); j < m; j++) for (var j = 0, m = array_length(prevn); j < m; j++)
prevp[j] = prevn[j]; firstLoop[j] = prevp[j];
} }
if(i < _subd - 1) {
v.x = points[(i + 1) * 3 + 0] - o.x;
v.y = points[(i + 1) * 3 + 1] - o.y;
v.z = points[(i + 1) * 3 + 2] - o.z;
} else {
v.x = n.x - o.x;
v.y = n.y - o.y;
v.z = n.z - o.z;
}
v._normalize();
if(v.equal(_ux)) u = v.cross(_ux);
else if(v.equal(_uz)) u = v.cross(_uy);
else u = v.cross(_uz);
u._normalize();
w = v.cross(u);
var _rr = radius * radiusOverPath[i];
var __v0 = 1. - uvProg[i-1];
var __v1 = 1. - uvProg[i ];
for(var j = 0; j <= sides; j++) {
var a0 = j / sides * 360;
var _u = u.multiply(dcos(a0));
var _w = w.multiply(dsin(a0));
var _pp = _u.add(_w);
prevn[j * 3 + 0] = n.x + _pp.x * _rr;
prevn[j * 3 + 1] = n.y + _pp.y * _rr;
prevn[j * 3 + 2] = n.z + _pp.z * _rr;
var prenn = loop && i == _subd - 1? firstLoop : prevn;
if(j) {
var x0 = prevp[ (j - 1) * 3 + 0 ];
var y0 = prevp[ (j - 1) * 3 + 1 ];
var z0 = prevp[ (j - 1) * 3 + 2 ];
var x1 = prevp[ (j ) * 3 + 0 ];
var y1 = prevp[ (j ) * 3 + 1 ];
var z1 = prevp[ (j ) * 3 + 2 ];
var x2 = prenn[ (j - 1) * 3 + 0 ];
var y2 = prenn[ (j - 1) * 3 + 1 ];
var z2 = prenn[ (j - 1) * 3 + 2 ];
var x3 = prenn[ (j ) * 3 + 0 ];
var y3 = prenn[ (j ) * 3 + 1 ];
var z3 = prenn[ (j ) * 3 + 2 ];
var _n0, _n1, _n2, _n3;
if(smooth) {
_n0 = new __vec3(x0 - o.x, y0 - o.y, z0 - o.z).normalize();
_n1 = new __vec3(x1 - o.x, y1 - o.y, z1 - o.z).normalize();
_n2 = new __vec3(x2 - n.x, y2 - n.y, z2 - n.z).normalize();
_n3 = new __vec3(x3 - n.x, y3 - n.y, z3 - n.z).normalize();
} else {
_n0 = _pp.normalize();
_n1 = _n0;
_n2 = _n0;
_n3 = _n0;
}
var __u0 = (j-1) / sides;
var __u1 = (j ) / sides;
if(invert) {
vs[_ind++] = new __vertex(x0, y0, z0).setNormal(_n0.x, _n0.y, _n0.z).setUV(__v0 * _vs, 1 - __u0 * _us);
vs[_ind++] = new __vertex(x1, y1, z1).setNormal(_n1.x, _n1.y, _n1.z).setUV(__v0 * _vs, 1 - __u1 * _us);
vs[_ind++] = new __vertex(x2, y2, z2).setNormal(_n2.x, _n2.y, _n2.z).setUV(__v1 * _vs, 1 - __u0 * _us);
vs[_ind++] = new __vertex(x1, y1, z1).setNormal(_n1.x, _n1.y, _n1.z).setUV(__v0 * _vs, 1 - __u1 * _us);
vs[_ind++] = new __vertex(x3, y3, z3).setNormal(_n3.x, _n3.y, _n3.z).setUV(__v1 * _vs, 1 - __u1 * _us);
vs[_ind++] = new __vertex(x2, y2, z2).setNormal(_n2.x, _n2.y, _n2.z).setUV(__v1 * _vs, 1 - __u0 * _us);
} else {
vs[_ind++] = new __vertex(x0, y0, z0).setNormal(_n0.x, _n0.y, _n0.z).setUV(__v0 * _vs, 1 - __u0 * _us);
vs[_ind++] = new __vertex(x2, y2, z2).setNormal(_n2.x, _n2.y, _n2.z).setUV(__v1 * _vs, 1 - __u0 * _us);
vs[_ind++] = new __vertex(x1, y1, z1).setNormal(_n1.x, _n1.y, _n1.z).setUV(__v0 * _vs, 1 - __u1 * _us);
vs[_ind++] = new __vertex(x1, y1, z1).setNormal(_n1.x, _n1.y, _n1.z).setUV(__v0 * _vs, 1 - __u1 * _us);
vs[_ind++] = new __vertex(x2, y2, z2).setNormal(_n2.x, _n2.y, _n2.z).setUV(__v1 * _vs, 1 - __u0 * _us);
vs[_ind++] = new __vertex(x3, y3, z3).setNormal(_n3.x, _n3.y, _n3.z).setUV(__v1 * _vs, 1 - __u1 * _us);
}
}
}
for (var j = 0, m = array_length(prevn); j < m; j++)
prevp[j] = prevn[j];
if(i == _subd - 1) { if(i == _subd - 1) {
for(var j = 0; j < sides; j++) { for(var j = 0; j < sides; j++) {
var cx0 = prevp[j * 3 + 0]; var cx0 = prevp[j * 3 + 0];
@ -200,8 +227,8 @@ function __3dPathExtrude(radius = 0.5, sides = 8, smooth = false) : __3dObject()
var __v1 = 0.5 + lengthdir_y(0.5, a1); var __v1 = 0.5 + lengthdir_y(0.5, a1);
v1[_in1++] = new __vertex(n.x, n.y, n.z).setNormal(-v.x, -v.y, -v.z).setUV(0.5, 0.5); v1[_in1++] = new __vertex(n.x, n.y, n.z).setNormal(-v.x, -v.y, -v.z).setUV(0.5, 0.5);
v1[_in1++] = new __vertex(cx0, cy0, cz0).setNormal(-v.x, -v.y, -v.z).setUV(__u0, __v0);
v1[_in1++] = new __vertex(cx1, cy1, cz1).setNormal(-v.x, -v.y, -v.z).setUV(__u1, __v1); v1[_in1++] = new __vertex(cx1, cy1, cz1).setNormal(-v.x, -v.y, -v.z).setUV(__u1, __v1);
v1[_in1++] = new __vertex(cx0, cy0, cz0).setNormal(-v.x, -v.y, -v.z).setUV(__u0, __v0);
} }
} }
@ -210,7 +237,7 @@ function __3dPathExtrude(radius = 0.5, sides = 8, smooth = false) : __3dObject()
o.z = n.z; o.z = n.z;
} }
vertex = endCap? [ vs, v0, v1 ] : [ vs ]; vertex = endCap && !loop? [ vs, v0, v1 ] : [ vs ];
object_counts = array_length(vertex); object_counts = array_length(vertex);
VB = build(); VB = build();
} initModel(); } initModel();

View file

@ -38,7 +38,7 @@
LATEST_VERSION = 11700; LATEST_VERSION = 11700;
VERSION = 11761; VERSION = 11761;
SAVE_VERSION = 11700; SAVE_VERSION = 11700;
VERSION_STRING = "1.17.7.004"; VERSION_STRING = "1.17.7.005";
BUILD_NUMBER = 11761; BUILD_NUMBER = 11761;
globalvar HOTKEYS, HOTKEY_CONTEXT; globalvar HOTKEYS, HOTKEY_CONTEXT;

View file

@ -30,10 +30,15 @@ function Node_3D_Mesh_Path_Extrude(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y
inputs[| in_mesh + 9] = nodeValue("Texture Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1 ] ) inputs[| in_mesh + 9] = nodeValue("Texture Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1 ] )
.setDisplay(VALUE_DISPLAY.vector); .setDisplay(VALUE_DISPLAY.vector);
inputs[| in_mesh + 10] = nodeValue("Loop", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
inputs[| in_mesh + 11] = nodeValue("Inverted", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
input_display_list = [ input_display_list = [
__d3d_input_list_mesh, in_mesh + 0, in_mesh + 6, in_mesh + 1, in_mesh + 7, in_mesh + 8, in_mesh + 5, ["Path", false], in_mesh + 0, in_mesh + 10,
__d3d_input_list_mesh, in_mesh + 6, in_mesh + 1, in_mesh + 7, in_mesh + 8, in_mesh + 5, in_mesh + 11,
__d3d_input_list_transform, __d3d_input_list_transform,
["Material", false], in_mesh + 4, in_mesh + 2, in_mesh + 3, in_mesh + 9, ["Material", false], in_mesh + 4, in_mesh + 2, in_mesh + 3, in_mesh + 9,
] ]
static step = function() { static step = function() {
@ -43,16 +48,18 @@ function Node_3D_Mesh_Path_Extrude(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y
} }
static processData = function(_output, _data, _output_index, _array_index = 0) { static processData = function(_output, _data, _output_index, _array_index = 0) {
var _path = _data[in_mesh + 0]; var _path = _data[in_mesh + 0];
var _sides = _data[in_mesh + 1]; var _sides = _data[in_mesh + 1];
var _mat_sid = _data[in_mesh + 2]; var _mat_sid = _data[in_mesh + 2];
var _mat_cap = _data[in_mesh + 3]; var _mat_cap = _data[in_mesh + 3];
var _smt = _data[in_mesh + 4]; var _smt = _data[in_mesh + 4];
var _caps = _data[in_mesh + 5]; var _caps = _data[in_mesh + 5];
var _samp = _data[in_mesh + 6]; var _samp = _data[in_mesh + 6] + 1;
var _rad = _data[in_mesh + 7]; var _rad = _data[in_mesh + 7];
var _radOv = _data[in_mesh + 8]; var _radOv = _data[in_mesh + 8];
var _uvScale = _data[in_mesh + 9]; var _uvScale = _data[in_mesh + 9];
var _loop = _data[in_mesh + 10];
var _invert = _data[in_mesh + 11];
if(_path == noone) return noone; if(_path == noone) return noone;
@ -94,6 +101,8 @@ function Node_3D_Mesh_Path_Extrude(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y
points : _points, points : _points,
radius : _rad, radius : _rad,
radiusOverPath: _radPath, radiusOverPath: _radPath,
loop : _loop,
invert : _invert,
uvProg : _uvProg, uvProg : _uvProg,
uvScale : _uvScale, uvScale : _uvScale,

View file

@ -638,10 +638,12 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
_ho = name_height; _ho = name_height;
} }
var _prev_surf = previewable && preview_draw && var _ss = getGraphPreviewSurface();
( is_surface(getGraphPreviewSurface()) || var _ps = is_surface(_ss);
(preview_channel >= 0 && preview_channel < ds_list_size(outputs) && outputs[| preview_channel].type == VALUE_TYPE.surface) var _ou = preview_channel >= 0 && preview_channel < ds_list_size(outputs) && outputs[| preview_channel].type == VALUE_TYPE.surface;
);
// print($"{previewable} && {preview_draw} && ([{_ss}] {_ps} || {_ou})");
var _prev_surf = previewable && preview_draw && (_ps || _ou);
var _p = previewable; var _p = previewable;
for( var i = 0; i < ds_list_size(inputs); i++ ) { for( var i = 0; i < ds_list_size(inputs); i++ ) {

View file

@ -67,9 +67,20 @@ function Node_Grain(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inputs[| 22] = nodeValue("Blend mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Additive", "Multiply", "Screen", "Overlay" ])
inputs[| 23] = nodeValue("Blend mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Additive", "Multiply", "Screen" ])
inputs[| 24] = nodeValue("Blend mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Additive", "Multiply", "Screen" ])
input_display_list = [ 3, 4, 9, input_display_list = [ 3, 4, 9,
["Surfaces", true], 0, 1, 2, 5, 6, ["Surfaces", true], 0, 1, 2, 5, 6,
["Grain", false], 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, ["Brightness", false], 22, /**/ 7, 8,
["RGB", false], 23, /**/ 10, 11, 12, 13, 14, 15,
["HSV", false], 24, /**/ 16, 17, 18, 19, 20, 21,
] ]
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);
@ -95,6 +106,10 @@ function Node_Grain(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
shader_set_f_map("sat", _data[18], _data[19], inputs[| 18]); shader_set_f_map("sat", _data[18], _data[19], inputs[| 18]);
shader_set_f_map("val", _data[20], _data[21], inputs[| 20]); shader_set_f_map("val", _data[20], _data[21], inputs[| 20]);
shader_set_i("bmBright", _data[22]);
shader_set_i("bmRGB", _data[23]);
shader_set_i("bmHSV", _data[24]);
draw_surface_safe(_data[0]); draw_surface_safe(_data[0]);
surface_reset_shader(); surface_reset_shader();

View file

@ -302,8 +302,12 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static setUnitRef = function(ref, mode = VALUE_UNIT.constant) { #region static setUnitRef = function(ref, mode = VALUE_UNIT.constant) { #region
express_edit.side_button = unit.triggerButton; express_edit.side_button = unit.triggerButton;
if(is_instanceof(editWidget, textBox)) if(editWidget) {
editWidget.side_button = unit.triggerButton; editWidget.unit = unit;
if(is_instanceof(editWidget, textBox))
editWidget.side_button = unit.triggerButton;
}
unit.reference = ref; unit.reference = ref;
unit.mode = mode; unit.mode = mode;

View file

@ -80,7 +80,7 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
onModify(value); onModify(value);
} #endregion } #endregion
static setSlidable = function(slideStep = slide_speed, _slide_int = false, _slide_range = noone) { #region static setSlidable = function(slideStep = slide_speed, _slide_int = false, _slide_range = noone) {
slidable = true; slidable = true;
slide_speed = is_array(slideStep)? slideStep[0] : slideStep; slide_speed = is_array(slideStep)? slideStep[0] : slideStep;
slide_snap = is_array(slideStep)? slideStep[1] : 0; slide_snap = is_array(slideStep)? slideStep[1] : 0;
@ -88,7 +88,7 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
slide_range = _slide_range; slide_range = _slide_range;
return self; return self;
} #endregion }
static setRange = function(_rng_min, _rng_max) { #region static setRange = function(_rng_min, _rng_max) { #region
use_range = true; use_range = true;

View file

@ -8,8 +8,8 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
onModify = _onModify; onModify = _onModify;
unit = _unit; unit = _unit;
linkable = true; linkable = true;
per_line = false; per_line = false;
current_value = []; current_value = [];
linked = false; linked = false;
side_button = noone; side_button = noone;
@ -48,25 +48,25 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
tb[i].slidable = true; tb[i].slidable = true;
} }
static apply = function() { #region static apply = function() {
for( var i = 0; i < size; i++ ) { for( var i = 0; i < size; i++ ) {
tb[i].apply(); tb[i].apply();
current_value[i] = toNumber(tb[i]._input_text); current_value[i] = toNumber(tb[i]._input_text);
} }
} #endregion }
static setLinkInactiveColor = function(color) { #region static setLinkInactiveColor = function(color) {
link_inactive_color = color; link_inactive_color = color;
return self; return self;
} #endregion }
static setSlideSpeed = function(speed) { #region static setSlideSpeed = function(speed) {
for(var i = 0; i < size; i++) for(var i = 0; i < size; i++)
tb[i].setSlidable(speed); tb[i].setSlidable(speed);
return self; return self;
} #endregion }
static setInteract = function(interactable) { #region static setInteract = function(interactable) {
self.interactable = interactable; self.interactable = interactable;
if(side_button) if(side_button)
@ -74,9 +74,9 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
for( var i = 0; i < size; i++ ) for( var i = 0; i < size; i++ )
tb[i].interactable = interactable; tb[i].interactable = interactable;
} #endregion }
static register = function(parent = noone) { #region static register = function(parent = noone) {
for( var i = 0; i < size; i++ ) for( var i = 0; i < size; i++ )
tb[i].register(parent); tb[i].register(parent);
@ -85,21 +85,21 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
if(unit != noone && unit.reference != noone) if(unit != noone && unit.reference != noone)
unit.triggerButton.register(parent); unit.triggerButton.register(parent);
} #endregion }
static isHovering = function() { #region static isHovering = function() {
for( var i = 0, n = array_length(tb); i < n; i++ ) if(tb[i].isHovering()) return true; for( var i = 0, n = array_length(tb); i < n; i++ ) if(tb[i].isHovering()) return true;
return false; return false;
} #endregion }
static drawParam = function(params) { #region static drawParam = function(params) {
setParam(params); setParam(params);
for(var i = 0; i < 4; i++) tb[i].setParam(params); for(var i = 0; i < 4; i++) tb[i].setParam(params);
return draw(params.x, params.y, params.w, params.h, params.data, params.display_data, params.m); return draw(params.x, params.y, params.w, params.h, params.data, params.display_data, params.m);
} #endregion }
static draw = function(_x, _y, _w, _h, _data, _display_data, _m) { #region static draw = function(_x, _y, _w, _h, _data, _display_data, _m) {
x = _x; x = _x;
y = _y; y = _y;
w = _w; w = _w;
@ -118,6 +118,8 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
var sz = min(size, array_length(_data)); var sz = min(size, array_length(_data));
var _bs = min(_h, ui(32)); var _bs = min(_h, ui(32));
if(unit) for(var i = 0; i < sz; i++) tb[i].slide_int = unit.mode == VALUE_UNIT.constant? true : false;
if((_w - _bs) / sz > ui(48)) { if((_w - _bs) / sz > ui(48)) {
if(side_button) { if(side_button) {
side_button.setFocusHover(active, hover); side_button.setFocusHover(active, hover);
@ -174,14 +176,14 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
resetFocus(); resetFocus();
return h; return h;
} #endregion }
static clone = function() { #region static clone = function() {
var cln = new vectorBox(size, onModify, unit); var cln = new vectorBox(size, onModify, unit);
cln.linkable = linkable; cln.linkable = linkable;
cln.per_line = per_line; cln.per_line = per_line;
return cln; return cln;
} #endregion }
} }

View file

@ -1,5 +1,5 @@
{ {
"$GMScript":"v1", "$GMScript":"",
"%Name":"vectorBox", "%Name":"vectorBox",
"isCompatibility":false, "isCompatibility":false,
"isDnD":false, "isDnD":false,

View file

@ -20,6 +20,7 @@ function widget() constructor {
font = f_p0; font = f_p0;
sep_axis = false; sep_axis = false;
unit = noone;
x = 0; x = 0;
y = 0; y = 0;

View file

@ -1,5 +1,5 @@
{ {
"$GMScript":"v1", "$GMScript":"",
"%Name":"widget", "%Name":"widget",
"isCompatibility":false, "isCompatibility":false,
"isDnD":false, "isDnD":false,

View file

@ -3,6 +3,10 @@ varying vec4 v_vColour;
uniform float seed; uniform float seed;
uniform int bmBright;
uniform int bmRGB;
uniform int bmHSV;
uniform vec2 brightness; uniform vec2 brightness;
uniform int brightnessUseSurf; uniform int brightnessUseSurf;
uniform sampler2D brightnessSurf; uniform sampler2D brightnessSurf;
@ -31,8 +35,28 @@ uniform vec2 val;
uniform int valUseSurf; uniform int valUseSurf;
uniform sampler2D valSurf; uniform sampler2D valSurf;
float random (in vec2 st) { return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); } vec3 channel_mix(vec3 a, vec3 b, vec3 w) { return vec3(mix(a.r, b.r, w.r), mix(a.g, b.g, w.g), mix(a.b, b.b, w.b)); }
vec2 random2 (in vec2 st) { float a = random(st); return vec2(cos(a), sin(a)); } vec3 screen( vec3 a, vec3 b, float w) { return mix(a, vec3(1.0) - (vec3(1.0) - a) * (vec3(1.0) - b), w); }
vec3 soft_light( vec3 a, vec3 b, float w) { return mix(a, pow(a, pow(vec3(2.0), 2.0 * (vec3(0.5) - b))), w); }
float screen( float a, float b, float w) { return mix(a, 1. - (1. - a) * (1. - b), w); }
vec3 overlay(vec3 a, vec3 b, float w) {
return mix(a, channel_mix(
2.0 * a * b,
vec3(1.0) - 2.0 * (vec3(1.0) - a) * (vec3(1.0) - b),
step(vec3(0.5), a)
), w);
}
// float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(seed / 1000., 0.), vec2(12.9898, 78.233))) * 43758.5453123); }
float gaussian( float z, float u, float o) { return (1.0 / (o * sqrt(2.0 * 3.1415))) * exp(-(((z - u) * (z - u)) / (2.0 * (o * o)))); }
float grandom (in vec2 st) {
float n = fract(sin(dot(st, vec2(12.9898, 78.233))) * 43758.5453 + seed);
float r = gaussian(n, 0., .5 * .5);
return r;
}
#region =========================================== COLORS SPACES =========================================== #region =========================================== COLORS SPACES ===========================================
vec3 rgb2hsv(vec3 c) { vec3 rgb2hsv(vec3 c) {
@ -123,58 +147,79 @@ vec2 random2 (in vec2 st) { float a = random(st); return vec2(cos(a), sin(a));
void main() { void main() {
vec4 c = texture2D( gm_BaseTexture, v_vTexcoord ); vec4 c = texture2D( gm_BaseTexture, v_vTexcoord );
float bri = brightness.x; float bri = brightness.x; if(brightnessUseSurf == 1) {
if(brightnessUseSurf == 1) {
vec4 _vMap = texture2D( brightnessSurf, v_vTexcoord ); vec4 _vMap = texture2D( brightnessSurf, v_vTexcoord );
bri = mix(brightness.x, brightness.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); bri = mix(brightness.x, brightness.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
} } bri *= bri;
float r = red.x; float r = red.x; if(redUseSurf == 1) {
if(redUseSurf == 1) {
vec4 _vMap = texture2D( redSurf, v_vTexcoord ); vec4 _vMap = texture2D( redSurf, v_vTexcoord );
r = mix(red.x, red.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); r = mix(red.x, red.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
} } r *= r;
float g = green.x; float g = green.x; if(greenUseSurf == 1) {
if(greenUseSurf == 1) {
vec4 _vMap = texture2D( greenSurf, v_vTexcoord ); vec4 _vMap = texture2D( greenSurf, v_vTexcoord );
g = mix(green.x, green.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); g = mix(green.x, green.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
} } g *= g;
float b = blue.x; float b = blue.x; if(blueUseSurf == 1) {
if(blueUseSurf == 1) {
vec4 _vMap = texture2D( blueSurf, v_vTexcoord ); vec4 _vMap = texture2D( blueSurf, v_vTexcoord );
b = mix(blue.x, blue.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); b = mix(blue.x, blue.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
} } b *= b;
float h = hue.x; float h = hue.x; if(hueUseSurf == 1) {
if(hueUseSurf == 1) {
vec4 _vMap = texture2D( hueSurf, v_vTexcoord ); vec4 _vMap = texture2D( hueSurf, v_vTexcoord );
h = mix(hue.x, hue.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); h = mix(hue.x, hue.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
} } h *= h;
float s = sat.x; float s = sat.x; if(satUseSurf == 1) {
if(satUseSurf == 1) {
vec4 _vMap = texture2D( satSurf, v_vTexcoord ); vec4 _vMap = texture2D( satSurf, v_vTexcoord );
s = mix(sat.x, sat.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); s = mix(sat.x, sat.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
} } s *= s;
float v = val.x; float v = val.x; if(valUseSurf == 1) {
if(valUseSurf == 1) {
vec4 _vMap = texture2D( valSurf, v_vTexcoord ); vec4 _vMap = texture2D( valSurf, v_vTexcoord );
v = mix(val.x, val.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); v = mix(val.x, val.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
} } v *= v;
c.rgb *= 1. + bri * bri * (random(v_vTexcoord + vec2(0.156 + seed / 1000., 0.6169)) * 2. - 1.); float nBri = grandom(v_vTexcoord + vec2(0.156, 0.6169));
c.r += r * r * (random(v_vTexcoord + vec2(0.985 + seed / 1000., 0.3642)) * 2. - 1.); vec3 grain = vec3(nBri);
c.g += g * g * (random(v_vTexcoord + vec2(0.653 + seed / 1000., 0.4954)) * 2. - 1.); if(bmBright == 0) c.rgb += nBri * bri;
c.b += b * b * (random(v_vTexcoord + vec2(0.382 + seed / 1000., 0.2967)) * 2. - 1.); else if(bmBright == 1) c.rgb *= 1. + nBri * bri;
else if(bmBright == 2) c.rgb = screen( c.rgb, grain, bri);
else if(bmBright == 3) c.rgb = overlay(c.rgb, grain, bri);
float nr = grandom(v_vTexcoord + vec2(0.985, 0.3642));
if(bmRGB == 0) c.r += nr * r;
else if(bmRGB == 1) c.r *= 1. + nr * r;
else if(bmRGB == 2) c.r = screen( c.r, nr, r);
float ng = grandom(v_vTexcoord + vec2(0.653, 0.4954));
if(bmRGB == 0) c.g += ng * g;
else if(bmRGB == 1) c.g *= 1. + ng * g;
else if(bmRGB == 2) c.g = screen( c.g, ng, g);
float nb = grandom(v_vTexcoord + vec2(0.382, 0.2967));
if(bmRGB == 0) c.b += nb * b;
else if(bmRGB == 1) c.b *= 1. + nb * b;
else if(bmRGB == 2) c.b = screen( c.b, nb, b);
vec3 hsv = rgb2hsv(c.rgb); vec3 hsv = rgb2hsv(c.rgb);
hsv.r += h * h * (random(v_vTexcoord + vec2(0.685 + seed / 1000., 0.5672)) * 2. - 1.); float nh = grandom(v_vTexcoord + vec2(0.685, 0.5672));
hsv.g += s * s * (random(v_vTexcoord + vec2(0.134 + seed / 1000., 0.8632)) * 2. - 1.); if(bmHSV == 0) hsv.r += nh * r;
hsv.b += v * v * (random(v_vTexcoord + vec2(0.268 + seed / 1000., 0.1264)) * 2. - 1.); else if(bmHSV == 1) hsv.r *= 1. + nh * r;
else if(bmHSV == 2) hsv.r = screen( hsv.r, nh, r);
float ns = grandom(v_vTexcoord + vec2(0.134, 0.8632));
if(bmHSV == 0) hsv.g += ns * g;
else if(bmHSV == 1) hsv.g *= 1. + ns * g;
else if(bmHSV == 2) hsv.g = screen( hsv.g, ns, g);
float nv = grandom(v_vTexcoord + vec2(0.268, 0.1264));
if(bmHSV == 0) hsv.b += nv * b;
else if(bmHSV == 1) hsv.b *= 1. + nv * b;
else if(bmHSV == 2) hsv.b = screen( hsv.b, nv, b);
c.rgb = hsv2rgb(hsv); c.rgb = hsv2rgb(hsv);