diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index dc223cd90..54a296c67 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -603,6 +603,7 @@ {"name":"node_scatter_points","order":6,"path":"scripts/node_scatter_points/node_scatter_points.yy",}, {"name":"pack_bottom_left","order":2,"path":"scripts/pack_bottom_left/pack_bottom_left.yy",}, {"name":"o_dialog_lua_reference","order":5,"path":"objects/o_dialog_lua_reference/o_dialog_lua_reference.yy",}, + {"name":"__node_custom","order":14,"path":"scripts/__node_custom/__node_custom.yy",}, {"name":"node_strand_gravity","order":4,"path":"scripts/node_strand_gravity/node_strand_gravity.yy",}, {"name":"load_palette","order":3,"path":"scripts/load_palette/load_palette.yy",}, {"name":"luaHighlight","order":1,"path":"scripts/luaHighlight/luaHighlight.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index f7c698434..ef84c2fd3 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -284,6 +284,7 @@ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"UI.json","CopyToMask":-1,"filePath":"datafiles/data/locale/sample locale",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"words.json","CopyToMask":-1,"filePath":"datafiles/data/locale/sample locale",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"nodes.json","CopyToMask":-1,"filePath":"datafiles/data",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"default.zip","CopyToMask":-1,"filePath":"datafiles/data/themes",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"FiraCode-Medium.ttf","CopyToMask":-1,"filePath":"datafiles/data/themes/default/fonts",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"fonts.json","CopyToMask":-1,"filePath":"datafiles/data/themes/default/fonts",}, @@ -1190,6 +1191,7 @@ {"id":{"name":"s_node_surface_to_buffer","path":"sprites/s_node_surface_to_buffer/s_node_surface_to_buffer.yy",},}, {"id":{"name":"node_PCX_fn_math","path":"scripts/node_PCX_fn_math/node_PCX_fn_math.yy",},}, {"id":{"name":"o_dialog_lua_reference","path":"objects/o_dialog_lua_reference/o_dialog_lua_reference.yy",},}, + {"id":{"name":"__node_custom","path":"scripts/__node_custom/__node_custom.yy",},}, {"id":{"name":"node_surface_data","path":"scripts/node_surface_data/node_surface_data.yy",},}, {"id":{"name":"node_strand_gravity","path":"scripts/node_strand_gravity/node_strand_gravity.yy",},}, {"id":{"name":"load_palette","path":"scripts/load_palette/load_palette.yy",},}, diff --git a/datafiles/data/Nodes/Custom/info.json b/datafiles/data/Nodes/Custom/info.json new file mode 100644 index 000000000..e69de29bb diff --git a/scripts/__node_custom/__node_custom.gml b/scripts/__node_custom/__node_custom.gml new file mode 100644 index 000000000..0ab5aa2d2 --- /dev/null +++ b/scripts/__node_custom/__node_custom.gml @@ -0,0 +1,141 @@ +function Node_create_Custom(_x, _y, _group = noone, _param = {}) { + if(!struct_has(_param, "path")) return noone; + var path = _param.path; + + var node = new Node_Custom(_x, _y, _group); + node.setPath(path); + return node; +} + +function Node_create_Custom_path(_x, _y, path) { + if(!file_exists(path)) return noone; + + var node = new Node_Custom(_x, _y, PANEL_GRAPH.getCurrentContext()); + node.setPath(path); + return node; +} + +function Node_Custom(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { + name = "Custom"; + path = ""; + + inputs[| 0] = nodeValue("Base Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone); + + outputs[| 0] = nodeValue("Output", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone ); + + static setPath = function(path) { + self.path = path; + } + + static createNewInput = function() { + var index = ds_list_size(inputs); + inputs[| index] = nodeValue("Uniform", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0 ) + .setVisible(true, true); + } + + static onValueUpdate = function(index) { #region + var _refresh = index == 0 || index == 1 || + (index >= input_fix_len && (index - input_fix_len) % data_length != 2); + + if(_refresh) { + refreshShader(); + refreshDynamicInput(); + } + } #endregion + + static processData = function(_output, _data, _output_index, _array_index = 0) { #region + var _surf = _data[2]; + if(!is_surface(_surf)) return noone; + if(!d3d11_shader_exists(shader.vs)) return noone; + if(!d3d11_shader_exists(shader.fs)) return noone; + + _output = surface_verify(_output, surface_get_width_safe(_surf), surface_get_height_safe(_surf)); + + surface_set_target(_output); + DRAW_CLEAR + + d3d11_shader_override_vs(shader.vs); + d3d11_shader_override_ps(shader.fs); + + var uTypes = array_create(8, 0); + var sampler_slot = 1; + + d3d11_cbuffer_begin(); + var _buffer = buffer_create(1, buffer_grow, 1); + var _cbSize = 0; + + for( var i = input_fix_len, n = array_length(_data); i < n; i += data_length ) { + var _arg_name = _data[i + 0]; + var _arg_type = _data[i + 1]; + var _arg_valu = _data[i + 2]; + + if(_arg_name == "") continue; + + var _uni = shader_get_uniform(shader.fs, _arg_name); + + switch(_arg_type) { + case 1 : + d3d11_cbuffer_add_int(1); + _cbSize++; + + buffer_write(_buffer, buffer_s32, _arg_valu); + break; + case 0 : + d3d11_cbuffer_add_float(1); + _cbSize++; + + buffer_write(_buffer, buffer_f32, _arg_valu); + break; + case 2 : + case 3 : + case 4 : + case 5 : + case 6 : + if(is_array(_arg_valu)) { + d3d11_cbuffer_add_float(array_length(_arg_valu)); + _cbSize += array_length(_arg_valu); + + for( var j = 0, m = array_length(_arg_valu); j < m; j++ ) + buffer_write(_buffer, buffer_f32, _arg_valu[j]); + } + break; + case 8 : + var _clr = colToVec4(_arg_valu); + d3d11_cbuffer_add_float(4); + _cbSize += 4; + + for( var j = 0, m = 4; j < m; j++ ) + buffer_write(_buffer, buffer_f32, _clr[i]); + break; + case 7 : + if(is_surface(_arg_valu)) + d3d11_texture_set_stage_ps(sampler_slot, surface_get_texture(_arg_valu)); + sampler_slot++; + break; + } + } + + d3d11_cbuffer_add_float(4 - _cbSize % 4); + var cbuff = d3d11_cbuffer_end(); + d3d11_cbuffer_update(cbuff, _buffer); + buffer_delete(_buffer); + + d3d11_shader_set_cbuffer_ps(10, cbuff); + + matrix_set(matrix_world, matrix_build(0, 0, 0, 0, 0, 0, + surface_get_width_safe(_surf), surface_get_height_safe(_surf), 1)); + vertex_submit(global.HLSL_VB, pr_trianglestrip, surface_get_texture(_surf)); + matrix_set(matrix_world, matrix_build_identity()); + + d3d11_shader_override_vs(-1); + d3d11_shader_override_ps(-1); + surface_reset_target(); + + return _output; + } #endregion + + static postConnect = function() { + refreshShader(); + refreshDynamicInput(); + } +} \ No newline at end of file diff --git a/scripts/__node_custom/__node_custom.yy b/scripts/__node_custom/__node_custom.yy new file mode 100644 index 000000000..8013d76ae --- /dev/null +++ b/scripts/__node_custom/__node_custom.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "__node_custom", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "node", + "path": "folders/nodes/data/node.yy", + }, +} \ No newline at end of file diff --git a/scripts/__node_custom/node_checkerboard.yy b/scripts/__node_custom/node_checkerboard.yy new file mode 100644 index 000000000..f65eb196c --- /dev/null +++ b/scripts/__node_custom/node_checkerboard.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "generator", + "path": "folders/nodes/data/generator.yy", + }, + "resourceVersion": "1.0", + "name": "node_checkerboard", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/__node_custom/node_stripe.yy b/scripts/__node_custom/node_stripe.yy new file mode 100644 index 000000000..3c179d416 --- /dev/null +++ b/scripts/__node_custom/node_stripe.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "generator", + "path": "folders/nodes/data/generator.yy", + }, + "resourceVersion": "1.0", + "name": "node_stripe", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/angle_functions/angle_functions.gml b/scripts/angle_functions/angle_functions.gml index 3e3f99c1b..68ecb894c 100644 --- a/scripts/angle_functions/angle_functions.gml +++ b/scripts/angle_functions/angle_functions.gml @@ -4,8 +4,10 @@ function angle_random_eval(range, seed = undefined) { if(seed != undefined) random_set_seed(seed); + if(array_empty(range)) return 0; + if(array_length(range) < 2) - return range + return range[0] else if(array_length(range) == 2) return irandom_range(range[0], range[1]); else if(array_length(range) > 2) { @@ -17,5 +19,5 @@ function angle_random_eval(range, seed = undefined) { } } - return range; + return array_safe_get(range, 0); } \ No newline at end of file diff --git a/scripts/curveBox/curveBox.gml b/scripts/curveBox/curveBox.gml index eb80aaf90..9cb96bf59 100644 --- a/scripts/curveBox/curveBox.gml +++ b/scripts/curveBox/curveBox.gml @@ -22,12 +22,10 @@ function curveBox(_onModify) : widget() constructor { 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(_data) || array_length(_data) == 0) return 0; + if(is_array(_data[0])) return 0; - if(!_is_array) return 0; + var points = array_length(_data) / 6; curve_surface = surface_verify(curve_surface, _w, _h); @@ -198,7 +196,7 @@ function curveBox(_onModify) : widget() constructor { } #endregion - if(!_is_array && hover) { #region + if(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)) { diff --git a/scripts/draw_surface_blend/draw_surface_blend.gml b/scripts/draw_surface_blend/draw_surface_blend.gml index 41d9eb255..579a2aa1d 100644 --- a/scripts/draw_surface_blend/draw_surface_blend.gml +++ b/scripts/draw_surface_blend/draw_surface_blend.gml @@ -38,7 +38,7 @@ function draw_surface_blend(background, foreground, blend = 0, alpha = 1, _pre_a shader_set_i("tile_type", tile); } - BLEND_ALPHA + BLEND_OVERRIDE draw_surface_stretched_safe(background, 0, 0, surf_w, surf_h); BLEND_NORMAL shader_reset(); diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index e014e079c..1b35d1a37 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -101,10 +101,10 @@ globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER; - VERSION = 11520; + VERSION = 11521; SAVE_VERSION = 11500; - VERSION_STRING = "1.15.2.0"; - BUILD_NUMBER = 11520; + VERSION_STRING = "1.15.2.1"; + BUILD_NUMBER = 11521; globalvar APPEND_MAP; APPEND_MAP = ds_map_create(); diff --git a/scripts/node_blend/node_blend.gml b/scripts/node_blend/node_blend.gml index 3374e3d21..6d04f5e0a 100644 --- a/scripts/node_blend/node_blend.gml +++ b/scripts/node_blend/node_blend.gml @@ -100,7 +100,7 @@ function Node_Blend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con surface_set_target(temp_surface[0]); DRAW_CLEAR - BLEND_ALPHA + BLEND_OVERRIDE draw_surface_safe(_fore, sx, sy); BLEND_NORMAL surface_reset_target(); diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index 3e2b9f5a5..35934d3ad 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -683,7 +683,7 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { #regio //var vct = ds_list_create(); //addNodeCatagory("VCT", vct); // addNodeObject(vct, "Biterator", s_node_print, "Node_Biterator", [1, Node_Biterator]); - + //////////////////////////////////////////////////////////////// PIXEL BUILDER //////////////////////////////////////////////////////////////// var pb_draw = ds_list_create(); #region diff --git a/scripts/node_scatter/node_scatter.gml b/scripts/node_scatter/node_scatter.gml index 0d91c7c4a..5fe61fad4 100644 --- a/scripts/node_scatter/node_scatter.gml +++ b/scripts/node_scatter/node_scatter.gml @@ -12,7 +12,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c inputs[| 3] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1, 1, 1 ] ) .setDisplay(VALUE_DISPLAY.vector_range); - inputs[| 4] = nodeValue("Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 0, 0, 0, 0, 0 ]) + inputs[| 4] = nodeValue("Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 0, 0, 0, 0, 0 ] ) .setDisplay(VALUE_DISPLAY.rotation_random); inputs[| 5] = nodeValue("Area", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ DEF_SURF_W / 2, DEF_SURF_H / 2, DEF_SURF_W / 2, DEF_SURF_H / 2, AREA_SHAPE.rectangle ]) diff --git a/scripts/node_time_remap/node_time_remap.gml b/scripts/node_time_remap/node_time_remap.gml index b1910329c..7047484ca 100644 --- a/scripts/node_time_remap/node_time_remap.gml +++ b/scripts/node_time_remap/node_time_remap.gml @@ -39,9 +39,7 @@ function Node_Time_Remap(_x, _y, _group = noone) : Node(_x, _y, _group) construc var ste = 1 / _life; - surface_set_target(_surf); - DRAW_CLEAR - shader_set(shader); + surface_set_shader(_surf, shader); texture_set_stage(uniform_map, surface_get_texture(_map)); for(var i = 0; i <= _life; i++) { @@ -59,8 +57,7 @@ function Node_Time_Remap(_x, _y, _group = noone) : Node(_x, _y, _group) construc draw_surface_safe(s, 0, 0); } - shader_reset(); - surface_reset_target(); + surface_reset_shader(); cacheCurrentFrame(_inSurf); } #endregion diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 4986b80c3..4d7ade780 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -246,6 +246,7 @@ function typeArray(_type) { #region case VALUE_DISPLAY.range : case VALUE_DISPLAY.vector_range : case VALUE_DISPLAY.rotation_range : + case VALUE_DISPLAY.rotation_random : case VALUE_DISPLAY.slider_range : case VALUE_DISPLAY.vector : diff --git a/shaders/sh_blend_add/sh_blend_add.fsh b/shaders/sh_blend_add/sh_blend_add.fsh index 8c3fdfa2f..fe9a78af0 100644 --- a/shaders/sh_blend_add/sh_blend_add.fsh +++ b/shaders/sh_blend_add/sh_blend_add.fsh @@ -34,7 +34,9 @@ void main() { _col1.a *= opacity * sampleMask(); _col1.rgb *= _col1.a; + float al = _col1.a + _col0.a * (1. - _col1.a); vec4 res = _col0 + _col1; - if(preserveAlpha == 1) res.a = _col0.a; + res.rgb /= al; + res.a = preserveAlpha == 1? _col0.a : res.a; gl_FragColor = res; } diff --git a/shaders/sh_blend_hue/sh_blend_hue.fsh b/shaders/sh_blend_hue/sh_blend_hue.fsh index 01fb47e25..ebd99dd7b 100644 --- a/shaders/sh_blend_hue/sh_blend_hue.fsh +++ b/shaders/sh_blend_hue/sh_blend_hue.fsh @@ -49,8 +49,10 @@ void main() { vec3 _hsv1 = rgb2hsv(_col1.rgb); _hsv1.yz = _hsv0.yz; + float al = _col1.a + _col0.a * (1. - _col1.a); vec4 res = vec4(mix(_col0.rgb, hsv2rgb(_hsv1), _col1.a * opacity * sampleMask()), _col0.a); - if(preserveAlpha == 1) res.a = _col0.a; + res.rgb /= al; + res.a = preserveAlpha == 1? _col0.a : res.a; gl_FragColor = res; } diff --git a/shaders/sh_blend_luma/sh_blend_luma.fsh b/shaders/sh_blend_luma/sh_blend_luma.fsh index 73c5e185a..45aa9dfd1 100644 --- a/shaders/sh_blend_luma/sh_blend_luma.fsh +++ b/shaders/sh_blend_luma/sh_blend_luma.fsh @@ -102,8 +102,10 @@ void main() { _hsl0.z = mix(_hsl0.z, _hsl1.z, _col1.a * opacity * sampleMask()); + float al = _col1.a + _col0.a * (1. - _col1.a); vec4 res = vec4(hsl2rgb(_hsl0), _col0.a); - if(preserveAlpha == 1) res.a = _col0.a; + res.rgb /= al; + res.a = preserveAlpha == 1? _col0.a : res.a; gl_FragColor = res; } diff --git a/shaders/sh_blend_multiply/sh_blend_multiply.fsh b/shaders/sh_blend_multiply/sh_blend_multiply.fsh index 0f7fb539f..59eb296ae 100644 --- a/shaders/sh_blend_multiply/sh_blend_multiply.fsh +++ b/shaders/sh_blend_multiply/sh_blend_multiply.fsh @@ -35,9 +35,10 @@ void main() { vec4 blend = (_col0 * (1. - opacity)) + (_col0 * _col1 * opacity); float po = preserveAlpha == 1? _col1.a : opacity; + float al = _col1.a + _col0.a * (1. - _col1.a); vec4 res = mix(_col0, blend, po); - - if(preserveAlpha == 1) res.a = _col0.a; + res.rgb /= al; + res.a = preserveAlpha == 1? _col0.a : res.a; gl_FragColor = res; } diff --git a/shaders/sh_blend_overlay/sh_blend_overlay.fsh b/shaders/sh_blend_overlay/sh_blend_overlay.fsh index 71a5725b7..9c176d29e 100644 --- a/shaders/sh_blend_overlay/sh_blend_overlay.fsh +++ b/shaders/sh_blend_overlay/sh_blend_overlay.fsh @@ -36,9 +36,10 @@ void main() { vec4 blend = lum > 0.5? (1. - (1. - 2. * (_col1 - 0.5)) * (1. - _col0)) : ((2. * _col1) * _col0); float po = preserveAlpha == 1? _col1.a : opacity; + float al = _col1.a + _col0.a * (1. - _col1.a); vec4 res = mix(_col0, blend, po); - - if(preserveAlpha == 1) res.a = _col0.a; + res.rgb /= al; + res.a = preserveAlpha == 1? _col0.a : res.a; gl_FragColor = res; } diff --git a/shaders/sh_blend_sat/sh_blend_sat.fsh b/shaders/sh_blend_sat/sh_blend_sat.fsh index 0a7001bda..bc8035abd 100644 --- a/shaders/sh_blend_sat/sh_blend_sat.fsh +++ b/shaders/sh_blend_sat/sh_blend_sat.fsh @@ -50,8 +50,10 @@ void main() { _hsv0.y = mix(_hsv0.y, _hsv1.y, _col1.a * opacity * sampleMask()); + float al = _col1.a + _col0.a * (1. - _col1.a); vec4 res = vec4(hsv2rgb(_hsv0), _col0.a); - if(preserveAlpha == 1) res.a = _col0.a; + res.rgb /= al; + res.a = preserveAlpha == 1? _col0.a : res.a; gl_FragColor = res; } diff --git a/shaders/sh_blend_screen/sh_blend_screen.fsh b/shaders/sh_blend_screen/sh_blend_screen.fsh index 177e6e702..d7f06ee9a 100644 --- a/shaders/sh_blend_screen/sh_blend_screen.fsh +++ b/shaders/sh_blend_screen/sh_blend_screen.fsh @@ -39,9 +39,10 @@ void main() { vec4 blend = vec4(1.) - (vec4(1.) - _col0) * (vec4(1.) - _col1); float po = preserveAlpha == 1? _col1.a : opacity; + float al = _col1.a + _col0.a * (1. - _col1.a); vec4 res = mix(_col0, blend, po); - - if(preserveAlpha == 1) res.a = _col0.a; + res.rgb /= al; + res.a = preserveAlpha == 1? _col0.a : res.a; gl_FragColor = res; } diff --git a/shaders/sh_blend_subtract/sh_blend_subtract.fsh b/shaders/sh_blend_subtract/sh_blend_subtract.fsh index f66b7975d..8f15993dc 100644 --- a/shaders/sh_blend_subtract/sh_blend_subtract.fsh +++ b/shaders/sh_blend_subtract/sh_blend_subtract.fsh @@ -37,9 +37,10 @@ void main() { vec4 blend = _col0 - _col1; float po = preserveAlpha == 1? _col1.a : opacity; + float al = _col1.a + _col0.a * (1. - _col1.a); vec4 res = mix(_col0, blend, po); - - if(preserveAlpha == 1) res.a = _col0.a; + res.rgb /= al; + res.a = preserveAlpha == 1? _col0.a : res.a; gl_FragColor = res; }