From 8cf4801f5ed707fe6a58df4baca9b7a2de8a6019 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sat, 24 Aug 2024 17:17:52 +0700 Subject: [PATCH] .3 --- .../_node_VFX_spawner/_node_VFX_spawner.gml | 2 +- scripts/assets_data/assets_data.gml | 1 - scripts/directory_object/directory_object.gml | 6 +- .../node_3d_transform_image.gml | 75 ++++++++++--------- scripts/node_keyframe/node_keyframe.gml | 2 +- scripts/node_mk_subpixel/node_mk_subpixel.gml | 14 +++- scripts/node_value/node_value.gml | 8 +- .../node_value_surface/node_value_surface.gml | 6 +- .../sh_mk_subpixel_chevron.fsh | 2 +- .../sh_mk_subpixel_diagonal.fsh | 2 +- .../sh_mk_subpixel_hex_disc.fsh | 2 +- .../sh_mk_subpixel_linear.fsh | 2 +- .../sh_mk_subpixel_linear_block.fsh | 2 +- .../sh_mk_subpixel_linear_block_offset.fsh | 2 +- .../sh_mk_subpixel_square.fsh | 2 +- .../sh_mk_subpixel_square_non.fsh | 2 +- 16 files changed, 70 insertions(+), 60 deletions(-) diff --git a/scripts/_node_VFX_spawner/_node_VFX_spawner.gml b/scripts/_node_VFX_spawner/_node_VFX_spawner.gml index 751c13269..3d0080c1b 100644 --- a/scripts/_node_VFX_spawner/_node_VFX_spawner.gml +++ b/scripts/_node_VFX_spawner/_node_VFX_spawner.gml @@ -328,7 +328,7 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co if(is_instanceof(_s, SurfaceAtlas)) _s = _s.surface.get(); - if(!surface_exists(_s)) + if(!is_surface(_s)) continue; surface_cache[$ surfs[i]] = surface_clone(_s); diff --git a/scripts/assets_data/assets_data.gml b/scripts/assets_data/assets_data.gml index ec7d044ce..706944a3f 100644 --- a/scripts/assets_data/assets_data.gml +++ b/scripts/assets_data/assets_data.gml @@ -51,7 +51,6 @@ } function get_asset(key) { - if(!ds_map_exists(global.ASSET_MAP, key)) return noone; if(ds_map_exists(global.ASSET_CACHE, key)) { diff --git a/scripts/directory_object/directory_object.gml b/scripts/directory_object/directory_object.gml index 8ae1f2e19..0441cf283 100644 --- a/scripts/directory_object/directory_object.gml +++ b/scripts/directory_object/directory_object.gml @@ -235,14 +235,14 @@ function DirectoryObject(name, path) constructor { #region var l_y = _y; for(var i = 0; i < ds_list_size(subDir); i++) { var _hg = subDir[| i].draw(parent, _x + ui(16), _y, _m, _w - ui(16), _hover, _focus, _homedir, _params); - draw_set_color(COLORS.collection_tree_line); - draw_line(_x + ui(12), _y + hg / 2, _x + ui(16), _y + hg / 2); + // draw_set_color(COLORS.collection_tree_line); + // draw_line(_x + ui(12), _y + hg / 2, _x + ui(16), _y + hg / 2); hh += _hg; _y += _hg; } draw_set_color(COLORS.collection_tree_line); - draw_line(_x + ui(12), l_y, _x + ui(12), _y - hg / 2); + draw_line(_x + ui(12), l_y, _x + ui(12), _y - ui(4)); } return hh; diff --git a/scripts/node_3d_transform_image/node_3d_transform_image.gml b/scripts/node_3d_transform_image/node_3d_transform_image.gml index f8c95eb03..d0c996d01 100644 --- a/scripts/node_3d_transform_image/node_3d_transform_image.gml +++ b/scripts/node_3d_transform_image/node_3d_transform_image.gml @@ -3,7 +3,7 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, batch_output = false; preview_channel = 1; - object = new __3dPlane(); + object = new __3dPlane(); object.checkParameter({ normal: 2 }); objectPreview = new __3dPlane(); @@ -12,19 +12,18 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, objectPreview.materials[0] = materialPreview; camera = camera_create(); - viewMat = matrix_build_lookat(0, 0, 1, - 0, 0, 0, - 1, 0, 0); - - projMat = matrix_build_projection_ortho(1, 1, 0.001, 10); - newInput(in_mesh + 0, nodeValue_Surface("Surface", self)) .setVisible(true, true); + newInput(in_mesh + 1, nodeValue_Enum_Button("Projection", self, 0, [ "Orthographic", "Perspective" ])); + + newInput(in_mesh + 2, nodeValue_Float("FOV", self, 45)); + input_display_list = [ - ["Material", false], in_mesh + 0, + ["Material", false], in_mesh + 0, __d3d_input_list_transform, + ["Camera", false], in_mesh + 1, in_mesh + 2, ] outputs[0].setVisible(false); @@ -33,31 +32,31 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, output_display_list = [ 1 ] static onDrawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) { - #region draw result - var _outSurf = outputs[1].getValue(); - if(is_array(_outSurf)) _outSurf = array_safe_get_fast(_outSurf, preview_index); - if(!is_surface(_outSurf)) return; - - var _w = _panel.w; - var _h = _panel.h - _panel.toolbar_height; - var _pw = surface_get_width_safe(_outSurf); - var _ph = surface_get_height_safe(_outSurf); - var _ps = min(128 / _ph, 160 / _pw); - - var _pws = _pw * _ps; - var _phs = _ph * _ps; - - var _px = _w - 16 - _pws; - var _py = _h - 16 - _phs; - - draw_surface_ext_safe(_outSurf, _px, _py, _ps, _ps); - draw_set_color(COLORS._main_icon); - draw_rectangle(_px, _py, _px + _pws, _py + _phs, true); - #endregion + var _outSurf = outputs[1].getValue(); + if(is_array(_outSurf)) _outSurf = array_safe_get_fast(_outSurf, preview_index); + if(!is_surface(_outSurf)) return; + + var _w = _panel.w; + var _h = _panel.h - _panel.toolbar_height; + var _pw = surface_get_width_safe(_outSurf); + var _ph = surface_get_height_safe(_outSurf); + var _ps = min(128 / _ph, 160 / _pw); + + var _pws = _pw * _ps; + var _phs = _ph * _ps; + + var _px = _w - 16 - _pws; + var _py = _h - 16 - _phs; + + draw_surface_ext_safe(_outSurf, _px, _py, _ps, _ps); + draw_set_color(COLORS._main_icon); + draw_rectangle(_px, _py, _px + _pws, _py + _phs, true); } - static processData = function(_output, _data, _output_index, _array_index = 0) { #region + static processData = function(_output, _data, _output_index, _array_index = 0) { var _surf = _data[in_mesh + 0]; + var _proj = _data[in_mesh + 1]; + var _fov = _data[in_mesh + 2]; if(!is_surface(_surf)) return 0; if(_output_index == 0) { @@ -72,7 +71,13 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, } if(_output_index == 1) { - _output = surface_verify(_output, surface_get_width_safe(_surf), surface_get_height_safe(_surf)); + var _dim = surface_get_dimension(_surf); + var projMat = _proj? matrix_build_projection_perspective_fov(_fov, _dim[0] / _dim[1], 0.001, 10) : matrix_build_projection_ortho(1, 1, 0.001, 10); + var viewMat = matrix_build_lookat(0, 0, 1, + 0, 0, 0, + 1, 0, 0); + + _output = surface_verify(_output, _dim[0], _dim[1]); surface_set_target(_output); DRAW_CLEAR camera_set_view_mat(camera, viewMat); @@ -94,13 +99,13 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, } return 0; - } #endregion + } static getPreviewObject = function() { return objectPreview; } - static getPreviewValues = function() { return array_safe_get_fast(all_inputs, in_mesh + 0, noone); } + static getPreviewValues = function() { return outputs[1].getValue(); } - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover = false, _focus = false) { #region + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover = false, _focus = false) { if(!previewable) return; var _surf = outputs[1].getValue(); @@ -112,5 +117,5 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, if(!isHighlightingInGraph()) aa *= 0.25; draw_surface_bbox(_surf, bbox,, aa); - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_keyframe/node_keyframe.gml b/scripts/node_keyframe/node_keyframe.gml index 278afad46..6c783eda3 100644 --- a/scripts/node_keyframe/node_keyframe.gml +++ b/scripts/node_keyframe/node_keyframe.gml @@ -441,7 +441,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { case VALUE_TYPE.float : return _val; case VALUE_TYPE.text : return is_string(_val)? _val : string_real(_val); case VALUE_TYPE.color : return is_real(_val)? cola(_val) : _val; - case VALUE_TYPE.surface : return is_string(_val)? get_asset(_val) : _val; + case VALUE_TYPE.surface : return is_string(_val)? get_asset(_val) : _val; } return _val; diff --git a/scripts/node_mk_subpixel/node_mk_subpixel.gml b/scripts/node_mk_subpixel/node_mk_subpixel.gml index 36fd8d9e9..d98e2275c 100644 --- a/scripts/node_mk_subpixel/node_mk_subpixel.gml +++ b/scripts/node_mk_subpixel/node_mk_subpixel.gml @@ -5,7 +5,7 @@ function Node_MK_Subpixel(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou newInput(1, nodeValue_Enum_Scroll("Type", self, 0, [ "Hex Disc", "Strip", "Linear Block", "Linear Block offset", "Chevron", "Square", "Square Non-Uniform" ])); - newInput(2, nodeValue_Int("Scale", self, 1)); + newInput(2, nodeValue_Int("Density", self, 8)); newInput(3, nodeValue_Float("Size", self, .6)) .setDisplay(VALUE_DISPLAY.slider); @@ -30,8 +30,10 @@ function Node_MK_Subpixel(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou newInput(11, nodeValue_Bool("Ridge", self, false)); + newInput(12, nodeValue_Float("Scene Scale", self, 1)); + input_display_list = [ new Inspector_Sprite(s_MKFX), 7, - ["Subpixel", false], 1, 2, + ["Subpixel", false], 1, 2, 12, ["Effect", false], 3, 4, 8, ["Render", false], 6, 5, ["Ridge", false, 11], 9, 10, @@ -51,6 +53,7 @@ function Node_MK_Subpixel(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou var _rgcn = _data[9]; var _rgin = _data[10]; var _ruse = _data[11]; + var _scns = _data[12]; var _dim = surface_get_dimension(_surf); var sh = sh_mk_subpixel_hex_disc; @@ -81,7 +84,12 @@ function Node_MK_Subpixel(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou shader_set_f("ridgeCount", _rgcn); shader_set_f("ridgeIntens", _rgin); - draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]); + var _cx = _dim[0] / 2; + var _cy = _dim[1] / 2; + var _px = _cx - _dim[0] * _scns / 2; + var _py = _cy - _dim[1] * _scns / 2; + + draw_surface_ext(_surf, _px, _py, _scns, _scns, 0, c_white, 1); surface_reset_shader(); return _outSurf; diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 154ee4939..6776169f0 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1408,7 +1408,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru /////============== SET ============= - static onValidate = function() { #region + static onValidate = function() { if(!validateValue) return; var _val = value_validation, str = ""; value_validation = VALIDATION.pass; @@ -1465,14 +1465,14 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru #endregion return self; - } #endregion + } static setValue = function(val = 0, record = true, time = CURRENT_FRAME, _update = true) { ////Set value val = unit.invApply(val); return setValueDirect(val, noone, record, time, _update); } - static overrideValue = function(_val) { #region + static overrideValue = function(_val) { animator.values = []; array_push(animator.values, new valueKey(0, _val, animator)); @@ -1480,7 +1480,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru animators[i].values = []; array_push(animators[i].values, new valueKey(0, array_safe_get_fast(_val, i), animators[i])); } - } #endregion + } static setValueInspector = function(_val = 0, index = noone, time = CURRENT_FRAME) { INLINE diff --git a/scripts/node_value_surface/node_value_surface.gml b/scripts/node_value_surface/node_value_surface.gml index 038fa3b98..c948ebecb 100644 --- a/scripts/node_value_surface/node_value_surface.gml +++ b/scripts/node_value_surface/node_value_surface.gml @@ -14,13 +14,11 @@ function NodeValue_Surface(_name, _node, _value, _tooltip = "") : NodeValue(_nam draw_junction_index = VALUE_TYPE.surface; if(is_instanceof(val, SurfaceAtlas) || (array_valid(val) && is_instanceof(val[0], SurfaceAtlas))) draw_junction_index = VALUE_TYPE.atlas; - + return val; } - static __getAnimValue = function(_time = CURRENT_FRAME) { - return array_empty(animator.values)? noone : animator.values[0].value; - } + static __getAnimValue = function(_time = CURRENT_FRAME) { return array_empty(animator.values)? noone : animator.processValue(animator.values[0].value); } static arrayLength = arrayLengthSimple; } \ No newline at end of file diff --git a/shaders/sh_mk_subpixel_chevron/sh_mk_subpixel_chevron.fsh b/shaders/sh_mk_subpixel_chevron/sh_mk_subpixel_chevron.fsh index d2cdd8c5f..e9b9f8fdd 100644 --- a/shaders/sh_mk_subpixel_chevron/sh_mk_subpixel_chevron.fsh +++ b/shaders/sh_mk_subpixel_chevron/sh_mk_subpixel_chevron.fsh @@ -76,7 +76,7 @@ void main() { else if(indx == 2) clr.b = intensity; clr *= lig; - vec3 baseC = texture2D( texture, uv ).rgb; + vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; baseC.rgb *= clr; gl_FragColor = vec4(baseC, 1.); diff --git a/shaders/sh_mk_subpixel_diagonal/sh_mk_subpixel_diagonal.fsh b/shaders/sh_mk_subpixel_diagonal/sh_mk_subpixel_diagonal.fsh index cb74b7a59..0a7334562 100644 --- a/shaders/sh_mk_subpixel_diagonal/sh_mk_subpixel_diagonal.fsh +++ b/shaders/sh_mk_subpixel_diagonal/sh_mk_subpixel_diagonal.fsh @@ -78,7 +78,7 @@ void main() { clr *= lig; vec2 uv = (hex / scs + .5) / vec2(dimension.x / dimension.y, 1.); - vec3 baseC = texture2D( texture, uv ).rgb; + vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; baseC.rgb *= clr; gl_FragColor = vec4(baseC, 1.); diff --git a/shaders/sh_mk_subpixel_hex_disc/sh_mk_subpixel_hex_disc.fsh b/shaders/sh_mk_subpixel_hex_disc/sh_mk_subpixel_hex_disc.fsh index 0b1c8263a..6491a8e50 100644 --- a/shaders/sh_mk_subpixel_hex_disc/sh_mk_subpixel_hex_disc.fsh +++ b/shaders/sh_mk_subpixel_hex_disc/sh_mk_subpixel_hex_disc.fsh @@ -87,7 +87,7 @@ void main() { clr *= lig; vec2 uv = (hex / scs + .5) / vec2(dimension.x / dimension.y, 1.); - vec3 baseC = texture2D( texture, uv ).rgb; + vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; baseC.rgb *= clr; gl_FragColor = vec4(baseC, 1.); diff --git a/shaders/sh_mk_subpixel_linear/sh_mk_subpixel_linear.fsh b/shaders/sh_mk_subpixel_linear/sh_mk_subpixel_linear.fsh index afd7d9a46..d18871c4b 100644 --- a/shaders/sh_mk_subpixel_linear/sh_mk_subpixel_linear.fsh +++ b/shaders/sh_mk_subpixel_linear/sh_mk_subpixel_linear.fsh @@ -59,7 +59,7 @@ void main() { else if(indx == 2) clr.b = intensity; clr *= lig; - vec3 baseC = texture2D( texture, uv ).rgb; + vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; baseC.rgb *= clr; gl_FragColor = vec4(baseC, 1.); diff --git a/shaders/sh_mk_subpixel_linear_block/sh_mk_subpixel_linear_block.fsh b/shaders/sh_mk_subpixel_linear_block/sh_mk_subpixel_linear_block.fsh index d24ecb5e6..60fd5c9a0 100644 --- a/shaders/sh_mk_subpixel_linear_block/sh_mk_subpixel_linear_block.fsh +++ b/shaders/sh_mk_subpixel_linear_block/sh_mk_subpixel_linear_block.fsh @@ -66,7 +66,7 @@ void main() { else if(indx == 2) clr.b = intensity; clr *= lig; - vec3 baseC = texture2D( texture, uv ).rgb; + vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; baseC.rgb *= clr; gl_FragColor = vec4(baseC, 1.); diff --git a/shaders/sh_mk_subpixel_linear_block_offset/sh_mk_subpixel_linear_block_offset.fsh b/shaders/sh_mk_subpixel_linear_block_offset/sh_mk_subpixel_linear_block_offset.fsh index 6bfce6d45..f80943fdc 100644 --- a/shaders/sh_mk_subpixel_linear_block_offset/sh_mk_subpixel_linear_block_offset.fsh +++ b/shaders/sh_mk_subpixel_linear_block_offset/sh_mk_subpixel_linear_block_offset.fsh @@ -70,7 +70,7 @@ void main() { else if(indx == 2) clr.b = intensity; clr *= lig; - vec3 baseC = texture2D( texture, uv ).rgb; + vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; baseC.rgb *= clr; gl_FragColor = vec4(baseC, 1.); diff --git a/shaders/sh_mk_subpixel_square/sh_mk_subpixel_square.fsh b/shaders/sh_mk_subpixel_square/sh_mk_subpixel_square.fsh index ad4d61f5a..125bd9c97 100644 --- a/shaders/sh_mk_subpixel_square/sh_mk_subpixel_square.fsh +++ b/shaders/sh_mk_subpixel_square/sh_mk_subpixel_square.fsh @@ -67,7 +67,7 @@ void main() { else if(indx == 2) clr.b = intensity; clr *= lig; - vec3 baseC = texture2D( texture, uv ).rgb; + vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; baseC.rgb *= clr; gl_FragColor = vec4(baseC, 1.); diff --git a/shaders/sh_mk_subpixel_square_non/sh_mk_subpixel_square_non.fsh b/shaders/sh_mk_subpixel_square_non/sh_mk_subpixel_square_non.fsh index c1b7bb4e2..9af925b0e 100644 --- a/shaders/sh_mk_subpixel_square_non/sh_mk_subpixel_square_non.fsh +++ b/shaders/sh_mk_subpixel_square_non/sh_mk_subpixel_square_non.fsh @@ -69,7 +69,7 @@ void main() { else if(indx == 2) clr.b = intensity; clr *= lig; - vec3 baseC = texture2D( texture, uv ).rgb; + vec3 baseC = texture2D( gm_BaseTexture, uv ).rgb; baseC.rgb *= clr; gl_FragColor = vec4(baseC, 1.);