diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 210c3c4d8..e719c1ede 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -677,6 +677,7 @@ {"name":"draw_sprite_ext_override","order":9,"path":"scripts/draw_sprite_ext_override/draw_sprite_ext_override.yy",}, {"name":"node_array_add","order":9,"path":"scripts/node_array_add/node_array_add.yy",}, {"name":"o_dialog_textbox_function_guide","order":7,"path":"objects/o_dialog_textbox_function_guide/o_dialog_textbox_function_guide.yy",}, + {"name":"node_3d_material","order":16,"path":"scripts/node_3d_material/node_3d_material.yy",}, {"name":"pcx_server","order":2,"path":"scripts/pcx_server/pcx_server.yy",}, {"name":"s_node_array_set","order":9,"path":"sprites/s_node_array_set/s_node_array_set.yy",}, {"name":"node_dust","order":21,"path":"scripts/node_dust/node_dust.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 84d0dc316..e67df909a 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -1266,6 +1266,7 @@ {"id":{"name":"draw_sprite_ext_override","path":"scripts/draw_sprite_ext_override/draw_sprite_ext_override.yy",},}, {"id":{"name":"node_array_add","path":"scripts/node_array_add/node_array_add.yy",},}, {"id":{"name":"o_dialog_textbox_function_guide","path":"objects/o_dialog_textbox_function_guide/o_dialog_textbox_function_guide.yy",},}, + {"id":{"name":"node_3d_material","path":"scripts/node_3d_material/node_3d_material.yy",},}, {"id":{"name":"pcx_server","path":"scripts/pcx_server/pcx_server.yy",},}, {"id":{"name":"s_node_array_set","path":"sprites/s_node_array_set/s_node_array_set.yy",},}, {"id":{"name":"node_dust","path":"scripts/node_dust/node_dust.yy",},}, diff --git a/datafiles/data/themes/default.zip b/datafiles/data/themes/default.zip index 8edc166d4..6b0973623 100644 Binary files a/datafiles/data/themes/default.zip and b/datafiles/data/themes/default.zip differ diff --git a/scripts/areaBox/areaBox.gml b/scripts/areaBox/areaBox.gml index 7606a6213..87fc20ceb 100644 --- a/scripts/areaBox/areaBox.gml +++ b/scripts/areaBox/areaBox.gml @@ -21,12 +21,12 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { unit = _unit; onSurfaceSize = -1; - link_value = false; + link_value = false; current_data = [ 0, 0, 0, 0 ]; adjust_shape = true; - mode = AREA_MODE.area; + mode = AREA_MODE.area; - onModifySingle[0] = function(val) { + onModifySingle[0] = function(val) { #region var v = toNumber(val); if(mode == AREA_MODE.area) { @@ -37,9 +37,8 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { } else if(mode == AREA_MODE.two_point) { return onModify(0, v); } - } - - onModifySingle[1] = function(val) { + } #endregion + onModifySingle[1] = function(val) { #region var v = toNumber(val); if(mode == AREA_MODE.area) { @@ -50,9 +49,8 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { } else if(mode == AREA_MODE.two_point) { return onModify(1, v); } - } - - onModifySingle[2] = function(val) { + } #endregion + onModifySingle[2] = function(val) { #region var v = toNumber(val); if(mode == AREA_MODE.area) { @@ -63,9 +61,8 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { } else if(mode == AREA_MODE.two_point) { return onModify(2, v); } - } - - onModifySingle[3] = function(val) { + } #endregion + onModifySingle[3] = function(val) { #region var v = toNumber(val); if(mode == AREA_MODE.area) { @@ -76,25 +73,25 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { } else if(mode == AREA_MODE.two_point) { return onModify(3, v); } - } + } #endregion - for(var i = 0; i < 4; i++) { + for(var i = 0; i < 4; i++) { #region tb[i] = new textBox(TEXTBOX_INPUT.number, onModifySingle[i]); tb[i].slidable = true; - } + } #endregion - static setSlideSpeed = function(speed) { + static setSlideSpeed = function(speed) { #region for(var i = 0; i < 4; i++) tb[i].slide_speed = speed; - } + } #endregion - static setInteract = function(interactable = noone) { + static setInteract = function(interactable = noone) { #region self.interactable = interactable; for(var i = 0; i < 4; i++) tb[i].interactable = interactable; - } + } #endregion - static register = function(parent = noone) { + static register = function(parent = noone) { #region switch(mode) { case AREA_MODE.two_point : case AREA_MODE.area : @@ -111,11 +108,11 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { if(unit != noone && unit.reference != noone) unit.triggerButton.register(parent); - } + } #endregion - static drawParam = function(params) { + static drawParam = function(params) { #region return draw(params.x + params.w / 2, params.y + ui(40), params.data, params.extra_data, params.m); - } + } #endregion static draw = function(_x, _y, _data, _extra_data, _m) { x = _x; @@ -124,17 +121,26 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { h = ui(204); mode = _extra_data.area_type; - if(buttonInstant(THEME.button_hide, _x - ui(48), _y + ui(64 - 48), ui(96), ui(96), _m, adjust_shape && active, adjust_shape && hover, - "", THEME.inspector_area, array_safe_get(_data, 4), c_white) == 2) { - - if(mouse_press(mb_left, active)) { - var val = (array_safe_get(_data, 4) + 1) % 2; - onModify(4, val); - } + var _bx = _x - ui(48); + var _by = _y + ui(64 - 48); + var _bs = ui(96); + var _bact = adjust_shape && active; + var _bhov = adjust_shape && hover; + var _bind = array_safe_get(_data, 4); + + if(!is_array(_bind)) + if(buttonInstant(THEME.button_hide, _bx, _by, _bs, _bs, _m, _bact, _bhov,, THEME.inspector_area, _bind, c_white) == 2) { + var val = (array_safe_get(_data, 4) + 1) % 2; + onModify(4, val); } if(onSurfaceSize != -1) { - if(buttonInstant(THEME.button_hide, _x - ui(76), _y + ui(28 - 12), ui(24), ui(24), _m, active, hover, __txtx("widget_area_fill_surface", "Full surface"), THEME.fill, 0, c_white) == 2) { + var _bx = _x - ui(76); + var _by = _y + ui(28 - 12); + var _bs = ui(24); + var _btxt = __txtx("widget_area_fill_surface", "Full surface"); + + if(buttonInstant(THEME.button_hide, _bx, _by, _bs, _bs, _m, active, hover, _btxt, THEME.fill, 0, c_white) == 2) { #region switch(mode) { case AREA_MODE.area : var ss = onSurfaceSize(); @@ -158,7 +164,7 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { onModify(3, ss[1]); break; } - } + } #endregion var txt = ""; switch(mode) { @@ -167,7 +173,11 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { case AREA_MODE.two_point : txt = __txtx("widget_area_two_points", "Two points"); break; } - if(buttonInstant(THEME.button_hide, _x + ui(76 - 24), _y + ui(28 - 12), ui(24), ui(24), _m, active, hover, txt, THEME.inspector_area_type, mode, c_white) == 2) { + var _bx = _x + ui(76 - 24); + var _by = _y + ui(28 - 12); + var _bs = ui(24); + + if(buttonInstant(THEME.button_hide, _bx, _by, _bs, _bs, _m, active, hover, txt, THEME.inspector_area_type, mode, c_white) == 2) { #region switch(mode) { case AREA_MODE.area : //area to padding var cx = array_safe_get(_data, 0); @@ -209,14 +219,19 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { } _extra_data.area_type = (mode + 1) % 3; - } - } + } #endregion + } - if(mode == AREA_MODE.padding) { - var cc = link_value? COLORS._main_accent : COLORS._main_icon; - if(buttonInstant(THEME.button_hide, _x - ui(76), _y + ui(88), ui(24), ui(24), _m, active, hover, __txt("Link values"), THEME.value_link, link_value, cc) == 2) + if(mode == AREA_MODE.padding) { #region + var cc = link_value? COLORS._main_accent : COLORS._main_icon; + var _bx = _x - ui(76); + var _by = _y + ui(88); + var _bs = ui(24); + var _btxt = __txt("Link values"); + + if(buttonInstant(THEME.button_hide, _bx, _by, _bs, _bs, _m, active, hover, _btxt, THEME.value_link, link_value, cc) == 2) link_value = !link_value; - } + } #endregion for(var i = 0; i < 4; i++) { tb[i].setFocusHover(active, hover); @@ -225,7 +240,7 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { current_data = _data; - if(mode == AREA_MODE.area) { + if(mode == AREA_MODE.area) { #region var tb_x0 = _x + ui(6) - ui(64) - ui(48); var tb_x1 = _x + ui(6) + ui(64) - ui(48); var tb_y0 = _y - ui(28); @@ -244,7 +259,8 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { tb[2].draw(tb_x0, tb_y1, ui(96), TEXTBOX_HEIGHT, array_safe_get(_data, 2), _m); tb[3].draw(tb_x1, tb_y1, ui(96), TEXTBOX_HEIGHT, array_safe_get(_data, 3), _m); - } else if(mode == AREA_MODE.padding) { + #endregion + } else if(mode == AREA_MODE.padding) { #region var tb_rx = _x + ui(56); var tb_ry = _y + ui(48); @@ -262,7 +278,8 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { tb[2].draw(tb_lx, tb_ly, ui(96), TEXTBOX_HEIGHT, array_safe_get(_data, 2), _m); tb[3].draw(tb_bx, tb_by, ui(96), TEXTBOX_HEIGHT, array_safe_get(_data, 3), _m); - } else if(mode == AREA_MODE.two_point) { + #endregion + } else if(mode == AREA_MODE.two_point) { #region var tb_x0 = _x + ui(6) - ui(64) - ui(48); var tb_x1 = _x + ui(6) + ui(64) - ui(48); var tb_y0 = _y - ui(28); @@ -281,6 +298,7 @@ function areaBox(_onModify, _unit = noone) : widget() constructor { tb[2].draw(tb_x0, tb_y1, ui(96), TEXTBOX_HEIGHT, array_safe_get(_data, 2), _m); tb[3].draw(tb_x1, tb_y1, ui(96), TEXTBOX_HEIGHT, array_safe_get(_data, 3), _m); + #endregion } if(unit != noone && unit.reference != noone) { diff --git a/scripts/buttonColor/buttonColor.gml b/scripts/buttonColor/buttonColor.gml index 7463c524f..5a35bf1ae 100644 --- a/scripts/buttonColor/buttonColor.gml +++ b/scripts/buttonColor/buttonColor.gml @@ -61,7 +61,7 @@ function buttonColor(_onApply, dialog = noone) : widget() constructor { y = _y; w = _w; h = _h; - current_color = toNumber(_color); + current_color = _color; var _cw = _w; @@ -110,7 +110,10 @@ function buttonColor(_onApply, dialog = noone) : widget() constructor { if(mouse_press(mb_left)) deactivate(); } - draw_sprite_stretched_ext(THEME.button_color_overlay, 0, _x + ui(4), _y + ui(4), _cw - ui(8), _h - ui(8), current_color, 1); + if(is_array(current_color)) + drawPalette(current_color, _x + ui(6), _y + ui(6), _cw - ui(12), _h - ui(12)); + else + draw_sprite_stretched_ext(THEME.button_color_overlay, 0, _x + ui(4), _y + ui(4), _cw - ui(8), _h - ui(8), current_color, 1); if(WIDGET_CURRENT == self) draw_sprite_stretched_ext(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), _h + ui(6), COLORS._main_accent, 1); diff --git a/scripts/buttonGradient/buttonGradient.gml b/scripts/buttonGradient/buttonGradient.gml index ce862a882..0412cf398 100644 --- a/scripts/buttonGradient/buttonGradient.gml +++ b/scripts/buttonGradient/buttonGradient.gml @@ -27,35 +27,57 @@ function buttonGradient(_onApply, dialog = noone) : widget() constructor { x = _x; y = _y; w = _w; - h = _h; - if(!is_instanceof(_gradient, gradientObject)) return; + + var _gw = _w - ui(12); + var _gh = _h - ui(12); current_gradient = _gradient; + if(is_array(_gradient)) { + if(array_length(_gradient) == 0) return 0; + + h = ui(12) + array_length(_gradient) * _gh; + current_gradient = _gradient[0]; + } else { + h = _h; + } + + if(!is_instanceof(current_gradient, gradientObject)) + return 0; + var click = false; - var hoverRect = point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h); + var hoverRect = point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + h); if(ihover && hoverRect) { - draw_sprite_stretched(THEME.button, 1, _x, _y, _w, _h); + draw_sprite_stretched(THEME.button, 1, _x, _y, _w, h); if(mouse_press(mb_left, iactive)) { trigger(); click = true; } if(mouse_click(mb_left, iactive)) { - draw_sprite_stretched(THEME.button, 2, _x, _y, _w, _h); - draw_sprite_stretched_ext(THEME.button, 3, _x, _y, _w, _h, COLORS._main_accent, 1); + draw_sprite_stretched(THEME.button, 2, _x, _y, _w, h); + draw_sprite_stretched_ext(THEME.button, 3, _x, _y, _w, h, COLORS._main_accent, 1); } } else { - draw_sprite_stretched(THEME.button, 0, _x, _y, _w, _h); + draw_sprite_stretched(THEME.button, 0, _x, _y, _w, h); if(mouse_press(mb_left)) deactivate(); } - _gradient.draw(_x + ui(6), _y + ui(6), _w - ui(12), _h - ui(12)); + if(!is_array(_gradient)) _gradient = [ _gradient ]; + + for( var i = 0, n = array_length(_gradient); i < n; i++ ) { + var _grad = _gradient[i]; + var _gx = _x + ui(6); + var _gy = _y + ui(6) + i * _gh; + + if(is_instanceof(_grad, gradientObject)) + _grad.draw(_gx, _gy, _gw, _gh); + } if(WIDGET_CURRENT == self) - draw_sprite_stretched_ext(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), _h + ui(6), COLORS._main_accent, 1); + draw_sprite_stretched_ext(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), h + ui(6), COLORS._main_accent, 1); if(DRAGGING && DRAGGING.type == "Gradient" && hover && hoverRect) { - draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, _y, _w, _h, COLORS._main_value_positive, 1); + draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, _y, _w, h, COLORS._main_value_positive, 1); if(mouse_release(mb_left)) onApply(DRAGGING.data); } diff --git a/scripts/buttonGroup/buttonGroup.gml b/scripts/buttonGroup/buttonGroup.gml index 5b5ac7dac..a11d006ae 100644 --- a/scripts/buttonGroup/buttonGroup.gml +++ b/scripts/buttonGroup/buttonGroup.gml @@ -45,6 +45,8 @@ function buttonGroup(_data, _onClick) : widget() constructor { w = _w; h = _h; current_selecting = _selecting; + while(is_array(current_selecting)) + current_selecting = array_safe_get(current_selecting, 0); var amo = array_length(data); var ww = _w / amo; diff --git a/scripts/buttonPalette/buttonPalette.gml b/scripts/buttonPalette/buttonPalette.gml index ef93a8e72..233ce2e64 100644 --- a/scripts/buttonPalette/buttonPalette.gml +++ b/scripts/buttonPalette/buttonPalette.gml @@ -27,37 +27,62 @@ function buttonPalette(_onApply, dialog = noone) : widget() constructor { y = _y; w = _w; h = _h; + + var _pw = _w - ui(12); + var _ph = _h - ui(12); + current_palette = _color; - var hoverRect = point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h); + if(array_length(_color) > 0 && is_array(_color[0])) { + if(array_length(_color[0]) == 0) return 0; + + h = ui(12) + array_length(_color) * _ph; + current_palette = _color[0]; + } else { + h = _h; + } + + if(!is_array(current_palette) || is_array(current_palette[0])) + return 0; + + var hoverRect = point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + h); if(ihover && hoverRect) { - draw_sprite_stretched(THEME.button, 1, _x, _y, _w, _h); + draw_sprite_stretched(THEME.button, 1, _x, _y, _w, h); if(mouse_press(mb_left, iactive)) trigger(); if(mouse_click(mb_left, iactive)) { - draw_sprite_stretched(THEME.button, 2, _x, _y, _w, _h); - draw_sprite_stretched_ext(THEME.button, 3, _x, _y, _w, _h, COLORS._main_accent, 1); + draw_sprite_stretched(THEME.button, 2, _x, _y, _w, h); + draw_sprite_stretched_ext(THEME.button, 3, _x, _y, _w, h, COLORS._main_accent, 1); } } else { - draw_sprite_stretched(THEME.button, 0, _x, _y, _w, _h); + draw_sprite_stretched(THEME.button, 0, _x, _y, _w, h); if(mouse_press(mb_left)) deactivate(); } - drawPalette(_color, _x + ui(6), _y + ui(6), _w - ui(12), _h - ui(12)); + if(!is_array(_color[0])) _color = [ _color ]; + + for( var i = 0, n = array_length(_color); i < n; i++ ) { + var _pal = _color[i]; + var _px = _x + ui(6); + var _py = _y + ui(6) + i * _ph; + + if(is_array(_pal)) + drawPalette(_pal, _px, _py, _pw, _ph); + } if(WIDGET_CURRENT == self) - draw_sprite_stretched_ext(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), _h + ui(6), COLORS._main_accent, 1); + draw_sprite_stretched_ext(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), h + ui(6), COLORS._main_accent, 1); if(DRAGGING && DRAGGING.type == "Palette" && hover && hoverRect) { - draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, _y, _w, _h, COLORS._main_value_positive, 1); + draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, _y, _w, h, COLORS._main_value_positive, 1); if(mouse_release(mb_left)) onApply(DRAGGING.data); } resetFocus(); - return _h; + return h; } } diff --git a/scripts/controlPointBox/controlPointBox.gml b/scripts/controlPointBox/controlPointBox.gml index 2aadc9479..d7066c4d9 100644 --- a/scripts/controlPointBox/controlPointBox.gml +++ b/scripts/controlPointBox/controlPointBox.gml @@ -59,12 +59,22 @@ function controlPointBox(_onModify) : widget() constructor { x = _x; y = _y; + var _mode = array_safe_get(_data, PUPPET_CONTROL.mode); + var _cx = array_safe_get(_data, PUPPET_CONTROL.cx); + var _cy = array_safe_get(_data, PUPPET_CONTROL.cy); + var _fx = array_safe_get(_data, PUPPET_CONTROL.fx); + var _fy = array_safe_get(_data, PUPPET_CONTROL.fy); + var _wid = array_safe_get(_data, PUPPET_CONTROL.width); + + if(is_array(_mode) || is_array(_cx) || is_array(_cy) || is_array(_fx) || is_array(_fy) || is_array(_wid)) + return 0; + for( var i = 0, n = array_length(widgets); i < n; i++ ) widgets[i].setFocusHover(active, hover); var yy = _y; - scMode.draw(_x, yy, _w, TEXTBOX_HEIGHT, sMode[_data[PUPPET_CONTROL.mode]], _m, _rx, _ry); + scMode.draw(_x, yy, _w, TEXTBOX_HEIGHT, sMode[_mode], _m, _rx, _ry); yy += TEXTBOX_HEIGHT + ui(8); var lw = ui(80); @@ -73,36 +83,36 @@ function controlPointBox(_onModify) : widget() constructor { draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text); draw_text(_x, yy + ui(17), "cx"); draw_text(_x + _w / 2 + ui(10), yy + ui(17), "cy"); - tbCx.draw(_x + lw, yy, w, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.cx], _m); - tbCy.draw(_x + _w / 2 + lw, yy, w, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.cy], _m); + tbCx.draw(_x + lw, yy, w, TEXTBOX_HEIGHT, _cx, _m); + tbCy.draw(_x + _w / 2 + lw, yy, w, TEXTBOX_HEIGHT, _cy, _m); yy += TEXTBOX_HEIGHT + ui(8); - switch(_data[PUPPET_CONTROL.mode]) { + switch(_mode) { case PUPPET_FORCE_MODE.move: draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text); draw_text(_x, yy + ui(17), "fx"); draw_text(_x + _w / 2 + ui(10), yy + ui(17), "fy"); - tbFx.draw(_x + lw, yy, w, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.fx], _m); - tbFy.draw(_x + _w / 2 + lw, yy, w, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.fy], _m); + tbFx.draw(_x + lw, yy, w, TEXTBOX_HEIGHT, _fx, _m); + tbFy.draw(_x + _w / 2 + lw, yy, w, TEXTBOX_HEIGHT, _fy, _m); yy += TEXTBOX_HEIGHT + ui(8); draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text); draw_text(_x, yy + ui(17), "radius"); - sW.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.width], _m); + sW.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _wid, _m); yy += TEXTBOX_HEIGHT + ui(8); break; case PUPPET_FORCE_MODE.wind: draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text); draw_text(_x, yy + ui(17), "strength"); - tbFx.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.fx], _m); + tbFx.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _fx, _m); yy += TEXTBOX_HEIGHT + ui(8); draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text); draw_text(_x, yy + ui(17), "width"); - tbW.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.width], _m); + tbW.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _wid, _m); yy += TEXTBOX_HEIGHT + ui(8); - rot.draw(_x + _w / 2, yy, _data[PUPPET_CONTROL.fy], _m); + rot.draw(_x + _w / 2, yy, _fy, _m); yy += ui(94 + 8); break; } diff --git a/scripts/curveBox/curveBox.gml b/scripts/curveBox/curveBox.gml index 8e8f1a535..eb80aaf90 100644 --- a/scripts/curveBox/curveBox.gml +++ b/scripts/curveBox/curveBox.gml @@ -17,14 +17,21 @@ function curveBox(_onModify) : widget() constructor { } static draw = function(_x, _y, _w, _h, _data, _m) { - x = _x; y = _y; - w = _w; h = _h; + x = _x; + y = _y; + w = _w; + h = _h; + + if(!is_array(_data) || array_length(_data) == 0) + return 0; + var _is_array = is_array(_data[0]); + var points = array_length(_data) / 6; + + if(!_is_array) return 0; curve_surface = surface_verify(curve_surface, _w, _h); - var points = array_length(_data) / 6; - - if(node_dragging != -1) { + if(node_dragging != -1) { #region editing if(node_drag_typ == 0) { var node_point = (node_dragging - 2) / 6; if(node_point > 0 && node_point < points - 1) { @@ -96,7 +103,7 @@ function curveBox(_onModify) : widget() constructor { UNDO_HOLDING = false; } - } + } #endregion var node_hovering = -1; var node_hover_typ = -1; @@ -106,88 +113,92 @@ function curveBox(_onModify) : widget() constructor { var msx = _m[0] - _x; var msy = _m[1] - _y; - surface_set_target(curve_surface); - DRAW_CLEAR - draw_set_color(COLORS.widget_curve_line); - draw_set_alpha(0.75); - var y0 = _h - _h * (0 - miny) / (maxy - miny); - draw_line(0, y0, _w, y0); - var y1 = _h - _h * (1 - miny) / (maxy - miny); - draw_line(0, y1, _w, y1); - draw_set_alpha(1); - - for( var i = 0; i < points; i++ ) { - var ind = i * 6; - var _x0 = _data[ind + 2]; - var _y0 = _data[ind + 3]; - var bx0 = _x0 + _data[ind + 0]; - var by0 = _y0 + _data[ind + 1]; - var ax0 = _x0 + _data[ind + 4]; - var ay0 = _y0 + _data[ind + 5]; - - bx0 = get_x(bx0, 0, _w); - by0 = get_y(by0, 0, _h); - _x0 = get_x(_x0, 0, _w); - _y0 = get_y(_y0, 0, _h); - ax0 = get_x(ax0, 0, _w); - ay0 = get_y(ay0, 0, _h); - + #region ==== draw ==== + surface_set_target(curve_surface); + DRAW_CLEAR draw_set_color(COLORS.widget_curve_line); - if(i > 0) { //draw pre line - draw_line(bx0, by0, _x0, _y0); - - draw_circle_prec(bx0, by0, 3, false); - if(hover && point_in_circle(msx, msy, bx0, by0, 10)) { - draw_circle_prec(bx0, by0, 5, false); - node_hovering = ind + 2; - node_hover_typ = -1; - } - } + draw_set_alpha(0.75); + var y0 = _h - _h * (0 - miny) / (maxy - miny); + draw_line(0, y0, _w, y0); + var y1 = _h - _h * (1 - miny) / (maxy - miny); + draw_line(0, y1, _w, y1); + draw_set_alpha(1); + + for( var i = 0; i < points; i++ ) { + var ind = i * 6; + var _x0 = _data[ind + 2]; + var _y0 = _data[ind + 3]; + var bx0 = _x0 + _data[ind + 0]; + var by0 = _y0 + _data[ind + 1]; + var ax0 = _x0 + _data[ind + 4]; + var ay0 = _y0 + _data[ind + 5]; - if(i < points - 1) { //draw post line - draw_line(ax0, ay0, _x0, _y0); + bx0 = get_x(bx0, 0, _w); + by0 = get_y(by0, 0, _h); + _x0 = get_x(_x0, 0, _w); + _y0 = get_y(_y0, 0, _h); + ax0 = get_x(ax0, 0, _w); + ay0 = get_y(ay0, 0, _h); - draw_circle_prec(ax0, ay0, 3, false); - if(hover && point_in_circle(msx, msy, ax0, ay0, 10)) { - draw_circle_prec(ax0, ay0, 5, false); - node_hovering = ind + 2; - node_hover_typ = 1; + draw_set_color(COLORS.widget_curve_line); + if(i > 0) { //draw pre line + draw_line(bx0, by0, _x0, _y0); + + draw_circle_prec(bx0, by0, 3, false); + if(hover && point_in_circle(msx, msy, bx0, by0, 10)) { + draw_circle_prec(bx0, by0, 5, false); + node_hovering = ind + 2; + node_hover_typ = -1; + } } - } + if(i < points - 1) { //draw post line + draw_line(ax0, ay0, _x0, _y0); + + draw_circle_prec(ax0, ay0, 3, false); + if(hover && point_in_circle(msx, msy, ax0, ay0, 10)) { + draw_circle_prec(ax0, ay0, 5, false); + node_hovering = ind + 2; + node_hover_typ = 1; + } + } + + draw_set_color(COLORS._main_accent); + draw_circle_prec(_x0, _y0, 3, false); + if(hover && point_in_circle(msx, msy, _x0, _y0, 10)) { + draw_circle_prec(_x0, _y0, 5, false); + node_hovering = ind + 2; + node_hover_typ = 0; + } + + if(msx >= _x1 && msy <= _x0) + point_insert = i; + _x1 = _x0; + } + draw_set_color(COLORS._main_accent); - draw_circle_prec(_x0, _y0, 3, false); - if(hover && point_in_circle(msx, msy, _x0, _y0, 10)) { - draw_circle_prec(_x0, _y0, 5, false); - node_hovering = ind + 2; - node_hover_typ = 0; - } - - if(msx >= _x1 && msy <= _x0) - point_insert = i; - _x1 = _x0; + draw_curve(0, 0, _w, -_h, _data, miny, maxy); + + surface_reset_target(); + #endregion + + #region ==== buttons ==== + var bx = _x + _w - ui(6 + 24); + var by = _y + _h - ui(6 + 24); + + if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), _m, active, hover,, THEME.add) == 2) { + miny = 0; + maxy = 1; } - - draw_set_color(COLORS._main_accent); - draw_curve(0, 0, _w, -_h, _data, miny, maxy); - - surface_reset_target(); - - var bx = _x + _w - ui(6 + 24); - var by = _y + _h - ui(6 + 24); - if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), _m, active, hover,, THEME.add) == 2) { - miny = 0; - maxy = 1; - } - - bx -= ui(24 + 4); - if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), _m, active, hover,, THEME.minus) == 2) { - miny = -1; - maxy = 2; - } + bx -= ui(24 + 4); + if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), _m, active, hover,, THEME.minus) == 2) { + miny = -1; + maxy = 2; + } + #endregion - if(hover) { + if(!_is_array && hover) { #region if(point_in_rectangle(_m[0], _m[1], _x + _w - ui(6 + 24 * 2 + 4), _y + _h - ui(6 + 24), _x + _w + ui(5), _y + _h + ui(5))) { } else if(point_in_rectangle(msx, msy, -ui(5), -ui(5), _w + ui(5), _h + ui(5))) { if(mouse_press(mb_left, active)) { @@ -220,7 +231,7 @@ function curveBox(_onModify) : widget() constructor { } } } - } + } #endregion draw_surface(curve_surface, _x, _y); draw_set_color(COLORS.widget_curve_outline); diff --git a/scripts/d3d_camera/d3d_camera.gml b/scripts/d3d_camera/d3d_camera.gml index 6d90bef6a..de9c32248 100644 --- a/scripts/d3d_camera/d3d_camera.gml +++ b/scripts/d3d_camera/d3d_camera.gml @@ -20,7 +20,7 @@ function __3dCamera() constructor { fov = 60; view_near = .01; - view_far = 10; + view_far = 50; view_w = 1; view_h = 1; diff --git a/scripts/d3d_material/d3d_material.gml b/scripts/d3d_material/d3d_material.gml index 5dcaddd7b..accadcde7 100644 --- a/scripts/d3d_material/d3d_material.gml +++ b/scripts/d3d_material/d3d_material.gml @@ -1,6 +1,9 @@ -function __d3dMaterial(surface = noone, roughness = 0) constructor { - self.roughness = roughness; - self.surface = surface; +function __d3dMaterial(surface = noone) constructor { + self.surface = surface; + self.diffuse = 1; + self.specular = 0; + self.metalic = false; + self.shine = 1; static getTexture = function() { if(!is_surface(surface)) return -1; diff --git a/scripts/d3d_object/d3d_object.gml b/scripts/d3d_object/d3d_object.gml index f8bbef5d9..f1fa4ca1d 100644 --- a/scripts/d3d_object/d3d_object.gml +++ b/scripts/d3d_object/d3d_object.gml @@ -164,9 +164,18 @@ function __3dObject() constructor { matrix_stack_push(sca); matrix_set(matrix_world, matrix_stack_top()); } + } + + if(VF == global.VF_POS_NORM_TEX_COL) + for( var i = 0, n = array_length(VB); i < n; i++ ) { + var _mat = array_safe_get(materials, i, noone); + var _tex = _mat == noone? -1 : _mat.getTexture(); - for( var i = 0, n = array_length(VB); i < n; i++ ) - vertex_submit(VB[i], render_type, array_safe_get(texture, i, -1)); + shader_set_f("mat_diffuse", _mat == noone? 1 : _mat.diffuse ); + shader_set_f("mat_specular", _mat == noone? 0 : _mat.specular ); + shader_set_f("mat_shine", _mat == noone? 1 : _mat.shine ); + shader_set_i("mat_metalic", _mat == noone? 0 : _mat.metalic ); + vertex_submit(VB[i], render_type, _tex); } if(params.show_normal && NVB != noone) { diff --git a/scripts/d3d_scene/d3d_scene.gml b/scripts/d3d_scene/d3d_scene.gml index 1185369d0..0842d9acc 100644 --- a/scripts/d3d_scene/d3d_scene.gml +++ b/scripts/d3d_scene/d3d_scene.gml @@ -108,6 +108,7 @@ function __3dScene(camera) constructor { shader_set_f("light_ont_shadow_bias", lightPnt_shadowBias); } + shader_set_f("cameraPosition", camera.position.toArray()); shader_set_i("gammaCorrection", gammaCorrection); shader_set_f("planeNear", camera.view_near); shader_set_f("planeFar", camera.view_far ); diff --git a/scripts/fontScrollBox/fontScrollBox.gml b/scripts/fontScrollBox/fontScrollBox.gml index 21dc69e23..fbbc3ac04 100644 --- a/scripts/fontScrollBox/fontScrollBox.gml +++ b/scripts/fontScrollBox/fontScrollBox.gml @@ -60,7 +60,12 @@ function fontScrollBox(_onModify) : widget() constructor { if(mouse_press(mb_left)) deactivate(); } - _text = filename_name_only(_text); + var _txt = ""; + var _texts = is_array(_text)? _text : [ _text ]; + for( var i = 0, n = array_length(_texts); i < n; i++ ) + _txt += (i? ", " : "") + filename_name_only(_texts[i]); + _txt = $"[{_txt}]"; + _text = is_array(_text)? _txt : filename_name_only(_text); draw_set_text(f_p0, align, fa_center, COLORS._main_text); draw_set_alpha(0.5 + 0.5 * interactable); diff --git a/scripts/node_3d_material/node_3d_material.gml b/scripts/node_3d_material/node_3d_material.gml new file mode 100644 index 000000000..22a6a1b04 --- /dev/null +++ b/scripts/node_3d_material/node_3d_material.gml @@ -0,0 +1,54 @@ +function Node_3D_Material(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constructor { + name = "3D Material"; + solid_surf = noone; + + inputs[| 0] = nodeValue("Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(true, true); + + inputs[| 1] = nodeValue("Diffuse", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) + .setDisplay(VALUE_DISPLAY.slider, [ 0, 1, 0.01 ]); + + inputs[| 2] = nodeValue("Specular", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) + .setDisplay(VALUE_DISPLAY.slider, [ 0, 1, 0.01 ]); + + inputs[| 3] = nodeValue("Shininess", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1); + + inputs[| 4] = nodeValue("Metalic", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + + outputs[| 0] = nodeValue("Material", self, JUNCTION_CONNECT.output, VALUE_TYPE.d3Material, noone); + + static processData = function(_output, _data, _output_index, _array_index = 0) { + var _surf = _data[0]; + var _diff = _data[1]; + var _spec = _data[2]; + var _shin = _data[3]; + var _metl = _data[4]; + + if(!is_surface(_surf)) { + solid_surf = surface_verify(solid_surf, 1, 1); + _surf = solid_surf; + } + + var _mat = new __d3dMaterial(_surf); + _mat.diffuse = _diff; + _mat.specular = _spec; + _mat.shine = _shin; + _mat.metalic = _metl; + + return _mat; + } + + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { + var bbox = drawGetBbox(xx, yy, _s); + var _mat = outputs[| 0].getValue(); + + if(_mat == noone) return; + if(is_array(_mat)) { + if(array_empty(_mat)) return; + _mat = _mat[0]; + } + + if(is_surface(_mat.surface)) + draw_surface_bbox(_mat.surface, bbox); + } +} \ No newline at end of file diff --git a/scripts/node_3d_material/node_3d_material.yy b/scripts/node_3d_material/node_3d_material.yy new file mode 100644 index 000000000..97d016d46 --- /dev/null +++ b/scripts/node_3d_material/node_3d_material.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "node_3d_material", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "3D", + "path": "folders/nodes/data/3D.yy", + }, +} \ No newline at end of file diff --git a/scripts/node_3d_material/node_counter.yy b/scripts/node_3d_material/node_counter.yy new file mode 100644 index 000000000..10832a0b0 --- /dev/null +++ b/scripts/node_3d_material/node_counter.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "variable", + "path": "folders/nodes/data/variable.yy", + }, + "resourceVersion": "1.0", + "name": "node_counter", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/node_3d_mesh_uvsphere/node_3d_mesh_uvsphere.gml b/scripts/node_3d_mesh_uvsphere/node_3d_mesh_uvsphere.gml index 6f59f4f7c..e86020fb7 100644 --- a/scripts/node_3d_mesh_uvsphere/node_3d_mesh_uvsphere.gml +++ b/scripts/node_3d_mesh_uvsphere/node_3d_mesh_uvsphere.gml @@ -7,25 +7,26 @@ function Node_3D_Mesh_Sphere_UV(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _ inputs[| in_mesh + 1] = nodeValue("Vertical Slices", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 16 ); - inputs[| in_mesh + 2] = nodeValue("Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Material, noone ); + inputs[| in_mesh + 2] = nodeValue("Material", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Material, noone ) + .setVisible(true, true); inputs[| in_mesh + 3] = nodeValue("Smooth Normal", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false ); input_display_list = [ __d3d_input_list_mesh, in_mesh + 0, in_mesh + 1, in_mesh + 3, __d3d_input_list_transform, - ["Texture", false], in_mesh + 2, + ["Material", false], in_mesh + 2, ] static processData = function(_output, _data, _output_index, _array_index = 0) { #region var _sideH = _data[in_mesh + 0]; var _sideV = _data[in_mesh + 1]; - var _tex = _data[in_mesh + 2]; + var _mat = _data[in_mesh + 2]; var _smt = _data[in_mesh + 3]; var object = getObject(_array_index); object.checkParameter({hori: _sideH, vert: _sideV, smooth: _smt}); - object.texture = [ surface_texture(_tex) ]; + object.materials = [ _mat ]; setTransform(object, _data); diff --git a/scripts/node_area/node_area.gml b/scripts/node_area/node_area.gml index 083bfda76..864fdf0ab 100644 --- a/scripts/node_area/node_area.gml +++ b/scripts/node_area/node_area.gml @@ -20,9 +20,11 @@ function Node_Area(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons .setDisplay(VALUE_DISPLAY.vector); static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { - var _pos = inputs[| 0].getValue(); - var _span = inputs[| 1].getValue(); - var _shape = inputs[| 2].getValue(); + if(process_amount > 1) return; + + var _pos = getInputData(0); + var _span = getInputData(1); + var _shape = getInputData(2); var px = _x + _pos[0] * _s; var py = _y + _pos[1] * _s; var ex = _span[0] * _s; diff --git a/scripts/node_gradient_output/node_gradient_output.gml b/scripts/node_gradient_output/node_gradient_output.gml index 12c0f96c0..6a33d7121 100644 --- a/scripts/node_gradient_output/node_gradient_output.gml +++ b/scripts/node_gradient_output/node_gradient_output.gml @@ -20,7 +20,7 @@ function Node_Gradient_Out(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro var pal = _data[0]; var pos = _data[1]; - //print("Gradient out " + string(pal)) + if(!is_instanceof(pal, gradientObject)) return 0; if(_output_index == 0) return pal; if(_output_index == 1) return pal.eval(pos); diff --git a/scripts/node_processor/node_processor.gml b/scripts/node_processor/node_processor.gml index e2f4b1d48..15ba34f40 100644 --- a/scripts/node_processor/node_processor.gml +++ b/scripts/node_processor/node_processor.gml @@ -30,6 +30,8 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct triggerRender(); }, false) ]); + static getInputData = function(index) { return array_safe_get(current_data, index, 0); } + static processData = function(_outSurf, _data, _output_index, _array_index = 0) { return _outSurf; } static getSingleValue = function(_index, _arr = 0, output = false) { #region @@ -69,7 +71,6 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct static processDataArray = function(outIndex) { #region var _output = outputs[| outIndex]; var _out = _output.getValue(); - all_inputs = array_create(ds_list_size(inputs)); if(process_amount == 1) { #region render single data if(_output.type == VALUE_TYPE.d3object) //passing 3D vertex call @@ -117,6 +118,7 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct #endregion var _data = array_create(ds_list_size(inputs)); + for(var l = 0; l < process_amount; l++) { for(var i = 0; i < ds_list_size(inputs); i++) _data[i] = all_inputs[i][l]; @@ -216,10 +218,9 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct case ARRAY_PROCESS.hold : process_amount = max(process_amount, amo); break; + case ARRAY_PROCESS.expand : case ARRAY_PROCESS.expand_inv : - if(amo && process_amount == 0) - process_amount = 1; process_amount *= max(1, amo); break; } diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index a762d6833..d54b2424b 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -361,14 +361,15 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { var d3d = ds_list_create(); #region addNodeCatagory("3D", d3d); ds_list_add(d3d, "2D Operations"); - addNodeObject(d3d, "Normal", s_node_normal, "Node_Normal", [1, Node_Normal],, "Create normal map using greyscale value as height."); + addNodeObject(d3d, "Normal", s_node_normal, "Node_Normal", [1, Node_Normal],, "Create normal map using greyscale value as height."); addNodeObject(d3d, "Normal Light", s_node_normal_light, "Node_Normal_Light", [1, Node_Normal_Light],, "Light up the image using normal mapping."); addNodeObject(d3d, "Bevel", s_node_bevel, "Node_Bevel", [1, Node_Bevel], ["shade", "auto shade"], "Apply 2D bevel on the image."); addNodeObject(d3d, "Sprite Stack", s_node_stack, "Node_Sprite_Stack", [1, Node_Sprite_Stack],, "Create sprite stack either from repeating a single image or stacking different images using array."); ds_list_add(d3d, "3D"); - addNodeObject(d3d, "3D Scene", s_node_3d_cube, "Node_3D_Scene", [1, Node_3D_Scene]); - addNodeObject(d3d, "3D Camera", s_node_3d_cube, "Node_3D_Camera", [1, Node_3D_Camera]); + addNodeObject(d3d, "3D Scene", s_node_3d_cube, "Node_3D_Scene", [1, Node_3D_Scene]); + addNodeObject(d3d, "3D Camera", s_node_3d_cube, "Node_3D_Camera", [1, Node_3D_Camera]); + addNodeObject(d3d, "3D Material", s_node_3d_cube, "Node_3D_Material", [1, Node_3D_Material]); ds_list_add(d3d, "Mesh"); addNodeObject(d3d, "3D Object", s_node_3d_obj, "Node_3D_Mesh_Obj", [0, Node_create_3D_Obj],, "Load .obj file from your computer as a 3D object."); diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index ddc5e1467..763201901 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -154,7 +154,7 @@ function value_color(i) { #region $ffa64d, //d3Light $ffa64d, //d3Camera $ffa64d, //d3Scene - $ffa64d, //d3Material + $976bff, //d3Material ]; if(i == 99) return $5dde8f; @@ -198,7 +198,8 @@ function value_bit(i) { #region case VALUE_TYPE.d3Light : return 1 << 29; case VALUE_TYPE.d3Camera : return 1 << 29; case VALUE_TYPE.d3Scene : return 1 << 29 | 1 << 30; - + case VALUE_TYPE.d3Material : return 1 << 33; + case VALUE_TYPE.any : return ~0 & ~(1 << 32); } return 0; @@ -1176,19 +1177,22 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } #endregion static arrayBalance = function(val) { #region //Balance array (generate uniform array from single values) - if(!is_array(def_val)) + if(!is_array(def_val)) return val; + if(typeArrayDynamic(display_type)) return val; + if(isArray(val)) + return val; + if(!is_array(val)) val = array_create(def_length, val); else if(array_length(val) < def_length) { for( var i = array_length(val); i < def_length; i++ ) val[i] = 0; - } else if(array_length(val) > def_length) - array_resize(val, def_length); - + } + return val; } #endregion @@ -1362,13 +1366,14 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru val = getValue(); if(!isArray(val)) - return 0; + return 1; if(array_depth == 0 && !typeArray(display_type)) return array_length(val); - var ar = val; - repeat(array_depth - 1 + typeArray(display_type)) + var ar = val; + var _depth = max(0, array_depth + typeArray(display_type) - 1); + repeat(_depth) ar = ar[0]; return array_length(ar); diff --git a/scripts/panel_preview/panel_preview.gml b/scripts/panel_preview/panel_preview.gml index a0a586c91..fd37af8e8 100644 --- a/scripts/panel_preview/panel_preview.gml +++ b/scripts/panel_preview/panel_preview.gml @@ -863,7 +863,7 @@ function Panel_Preview() : PanelContent() constructor { if(d3_scene_light_enabled) { d3_scene.addLightDirectional(d3_scene_light0); - d3_scene.addLightDirectional(d3_scene_light1); + //d3_scene.addLightDirectional(d3_scene_light1); } for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) { diff --git a/scripts/rotatorRange/rotatorRange.gml b/scripts/rotatorRange/rotatorRange.gml index 216d97c03..80f7dda88 100644 --- a/scripts/rotatorRange/rotatorRange.gml +++ b/scripts/rotatorRange/rotatorRange.gml @@ -39,6 +39,7 @@ function rotatorRange(_onModify) : widget() constructor { if(!is_real(_data[0])) return; if(!is_real(_data[1])) return; + var knob_y = _y + h / 2; var _r = ui(28); diff --git a/scripts/scrollBox/scrollBox.gml b/scripts/scrollBox/scrollBox.gml index 0cca4faba..59dddca0b 100644 --- a/scripts/scrollBox/scrollBox.gml +++ b/scripts/scrollBox/scrollBox.gml @@ -45,6 +45,7 @@ function scrollBox(_data, _onModify, update_hover = true) : widget() constructor if(is_method(data_list)) data = data_list(); else data = data_list; + if(is_array(_val)) return 0; var _text = is_string(_val)? _val : array_safe_get(data, _val); curr_text = _text; diff --git a/scripts/toggleGroup/toggleGroup.gml b/scripts/toggleGroup/toggleGroup.gml index e894589e6..bd16efc5a 100644 --- a/scripts/toggleGroup/toggleGroup.gml +++ b/scripts/toggleGroup/toggleGroup.gml @@ -33,6 +33,8 @@ function toggleGroup(_data, _onClick) : widget() constructor { h = _h; value = _data; + if(!is_array(_data)) return 0; + var amo = array_length(data); var ww = _w / amo; diff --git a/scripts/transformBox/transformBox.gml b/scripts/transformBox/transformBox.gml index a091c9149..7ded8cc00 100644 --- a/scripts/transformBox/transformBox.gml +++ b/scripts/transformBox/transformBox.gml @@ -48,6 +48,10 @@ function transformBox(_onModify) : widget() constructor { w = _w; h = ui(148); + if(!is_array(_data)) return 0; + if(array_empty(_data)) return 0; + if(is_array(_data[0])) return 0; + rot.setFocusHover(active, hover); for(var i = 0; i < array_length(_data); i++) tb[i].setFocusHover(active, hover); diff --git a/scripts/vectorBox/vectorBox.gml b/scripts/vectorBox/vectorBox.gml index 902ce97cc..627dcb4ab 100644 --- a/scripts/vectorBox/vectorBox.gml +++ b/scripts/vectorBox/vectorBox.gml @@ -87,7 +87,10 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor { w = _w; h = _h; - if(!is_array(_data)) return; + if(!is_array(_data)) return 0; + if(array_empty(_data)) return 0; + if(is_array(_data[0])) return 0; + current_value = _data; if(extras && instanceof(extras) == "buttonClass") { diff --git a/shaders/sh_d3d_default/sh_d3d_default.fsh b/shaders/sh_d3d_default/sh_d3d_default.fsh index 68f94ce2c..9af3a756e 100644 --- a/shaders/sh_d3d_default/sh_d3d_default.fsh +++ b/shaders/sh_d3d_default/sh_d3d_default.fsh @@ -1,13 +1,17 @@ -// -// Simple passthrough fragment shader -// +// PC3D rendering shader +// - BRDF By Xpanda and OGLDEV + varying vec2 v_vTexcoord; varying vec4 v_vColour; varying vec3 v_vNormal; varying vec4 v_worldPosition; +varying vec3 v_viewPosition; varying float v_cameraDistance; +#define PI 3.14159265359 +#define TAU 6.28318530718 + #region ---- light ---- uniform vec4 light_ambient; uniform float shadowBias; @@ -48,11 +52,21 @@ varying float v_cameraDistance; uniform sampler2D light_pnt_shadowmap_7; #endregion -#region ---- rendering ---- - uniform int gammaCorrection; +#region ---- material ---- + vec4 mat_baseColor; + + uniform float mat_diffuse; + uniform float mat_specular; + uniform float mat_shine; + uniform int mat_metalic; #endregion -#region ---- matrix ---- +#region ---- rendering ---- + uniform vec3 cameraPosition; + uniform int gammaCorrection; +#endregion + +#region ++++ matrix ++++ float matrixGet(mat4 matrix, int index) { if(index < 0 || index > 15) return 0.; @@ -71,32 +85,60 @@ varying float v_cameraDistance; } #endregion -float sampleDirShadowMap(int index, vec2 position) { - if(index == 0) return texture2D(light_dir_shadowmap_0, position).r; - if(index == 1) return texture2D(light_dir_shadowmap_1, position).r; - if(index == 2) return texture2D(light_dir_shadowmap_2, position).r; - if(index == 3) return texture2D(light_dir_shadowmap_3, position).r; - return 0.; -} - -float samplePntShadowMap(int index, vec2 position, int side) { - position.x /= 2.; - if(side >= 3) { - position.x += 0.5; - side -= 3; +#region ++++ shadow sampler ++++ + float sampleDirShadowMap(int index, vec2 position) { + if(index == 0) return texture2D(light_dir_shadowmap_0, position).r; + if(index == 1) return texture2D(light_dir_shadowmap_1, position).r; + if(index == 2) return texture2D(light_dir_shadowmap_2, position).r; + if(index == 3) return texture2D(light_dir_shadowmap_3, position).r; + return 0.; } + + float samplePntShadowMap(int index, vec2 position, int side) { + position.x /= 2.; + if(side >= 3) { + position.x += 0.5; + side -= 3; + } - if(index == 0) return texture2D(light_pnt_shadowmap_0, position)[side]; - if(index == 1) return texture2D(light_pnt_shadowmap_1, position)[side]; - if(index == 2) return texture2D(light_pnt_shadowmap_2, position)[side]; - if(index == 3) return texture2D(light_pnt_shadowmap_3, position)[side]; - return 0.; -} + if(index == 0) return texture2D(light_pnt_shadowmap_0, position)[side]; + if(index == 1) return texture2D(light_pnt_shadowmap_1, position)[side]; + if(index == 2) return texture2D(light_pnt_shadowmap_2, position)[side]; + if(index == 3) return texture2D(light_pnt_shadowmap_3, position)[side]; + return 0.; + } +#endregion + +#region ++++ Phong shading ++++ + vec3 phongLight(vec3 normal, vec3 lightVec, vec3 viewVec, vec3 light) { + vec3 lightDir = normalize(lightVec); + vec3 viewDir = normalize(viewVec); + vec3 refcDir = reflect(-lightDir, normal); + + float kD = 1, kS = 0; + + if(mat_diffuse + mat_specular != 0) { + kD = mat_diffuse / (mat_diffuse + mat_specular); + kS = mat_specular / (mat_diffuse + mat_specular); + } + + vec3 lLambert = max(0., dot(normal, lightDir)) * light; + + float specular = pow(max(dot(viewDir, refcDir), 0.), max(0.001, mat_shine)); + vec3 lSpecular = specular * light; + if(mat_metalic == 1) lSpecular *= mat_baseColor.rgb; + + return kD * lLambert + kS * lSpecular; + } +#endregion void main() { - vec4 final_color = texture2D( gm_BaseTexture, v_vTexcoord ); - final_color *= v_vColour; - vec3 normal = normalize(v_vNormal); + mat_baseColor = texture2D( gm_BaseTexture, v_vTexcoord ); + mat_baseColor *= v_vColour; + + vec4 final_color = mat_baseColor; + vec3 normal = normalize(v_vNormal); + vec3 viewDirection = normalize(cameraPosition - v_worldPosition.xyz); gl_FragData[0] = vec4(0.); gl_FragData[1] = vec4(0.); @@ -107,7 +149,7 @@ void main() { vec3 light_effect = light_ambient.rgb; float val = 0.; - #region ---- directional ---- + #region ++++ directional ++++ float light_dir_strength; float light_map_depth; float lightDistance; @@ -116,9 +158,9 @@ void main() { shadow_map_index = 0; for(int i = 0; i < light_dir_count; i++) { vec3 lightVector = normalize(light_dir_direction[i]); - light_dir_strength = dot(normal, normalize(lightVector)); - if(light_dir_strength < 0.) - continue; + //light_dir_strength = dot(normal, lightVector); + //if(light_dir_strength < 0.) + // continue; if(light_dir_shadow_active[i] == 1) { vec4 cameraSpace = light_dir_view[i] * v_worldPosition; @@ -137,11 +179,14 @@ void main() { continue; } - light_dir_strength = max(light_dir_strength * light_dir_intensity[i], 0.); - light_effect += light_dir_color[i].rgb * light_dir_strength; + //light_dir_strength = max(light_dir_strength * light_dir_intensity[i], 0.); + vec3 light_phong = phongLight(normal, lightVector, viewDirection, light_dir_color[i].rgb); + + light_effect += light_phong; } #endregion - #region ---- point ---- + + #region ++++ point ++++ float light_pnt_strength; float light_distance; float light_attenuation; @@ -149,9 +194,9 @@ void main() { shadow_map_index = 0; for(int i = 0; i < light_pnt_count; i++) { vec3 lightVector = normalize(light_pnt_position[i] - v_worldPosition.xyz); - light_pnt_strength = dot(normal, lightVector); - if(light_pnt_strength < 0.) - continue; + //light_pnt_strength = dot(normal, lightVector); + //if(light_pnt_strength < 0.) + // continue; light_distance = length(lightVector); if(light_distance > light_pnt_radius[i]) @@ -180,24 +225,27 @@ void main() { if(v_lightDistance > light_map_depth + bias) continue; } - + light_attenuation = 1. - pow(light_distance / light_pnt_radius[i], 2.); - light_pnt_strength = max(light_pnt_strength * light_pnt_intensity[i] * light_attenuation, 0.); - light_effect += light_pnt_color[i].rgb * light_pnt_strength; + //light_pnt_strength = max(light_pnt_strength * light_pnt_intensity[i] * light_attenuation, 0.); + vec3 light_phong = phongLight(normal, lightVector, viewDirection, light_pnt_color[i].rgb * light_attenuation); + + light_effect += light_phong; } #endregion light_effect = max(light_effect, 0.); + + if(gammaCorrection == 1) { + light_effect.r = pow(light_effect.r, 1. / 2.2); + light_effect.g = pow(light_effect.g, 1. / 2.2); + light_effect.b = pow(light_effect.b, 1. / 2.2); + } + final_color.rgb *= light_effect; #endregion - if(gammaCorrection == 1) { - final_color.r = pow(final_color.r, 1. / 2.2); - final_color.g = pow(final_color.g, 1. / 2.2); - final_color.b = pow(final_color.b, 1. / 2.2); - } - gl_FragData[0] = final_color; gl_FragData[1] = vec4(0.5 + normal * 0.5, 1.); gl_FragData[2] = vec4(vec3(v_cameraDistance), 1.); diff --git a/shaders/sh_d3d_default/sh_d3d_default.vsh b/shaders/sh_d3d_default/sh_d3d_default.vsh index b3cd0ad18..23c0d0f9e 100644 --- a/shaders/sh_d3d_default/sh_d3d_default.vsh +++ b/shaders/sh_d3d_default/sh_d3d_default.vsh @@ -1,15 +1,16 @@ // // 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) +attribute vec3 in_Position; +attribute vec3 in_Normal; +attribute vec4 in_Colour; +attribute vec2 in_TextureCoord; varying vec2 v_vTexcoord; varying vec4 v_vColour; varying vec3 v_vNormal; varying vec4 v_worldPosition; +varying vec3 v_viewPosition; varying float v_cameraDistance; uniform float planeNear; @@ -19,7 +20,8 @@ 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_worldPosition = (gm_Matrices[MATRIX_WORLD] * object_space_pos); + v_worldPosition = gm_Matrices[MATRIX_WORLD] * object_space_pos; + v_viewPosition = (gm_Matrices[MATRIX_WORLD_VIEW] * object_space_pos).xyz; v_vColour = in_Colour; v_vTexcoord = in_TextureCoord;