diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index cac940bf6..26ee23899 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -1313,7 +1313,7 @@ {"name":"sh_grid_tri","order":3,"path":"shaders/sh_grid_tri/sh_grid_tri.yy",}, {"name":"sh_herringbone_tile","order":5,"path":"shaders/sh_herringbone_tile/sh_herringbone_tile.yy",}, {"name":"sh_image_trace","order":34,"path":"shaders/sh_image_trace/sh_image_trace.yy",}, - {"name":"sh_invert_all","order":20,"path":"shaders/sh_invert_all/sh_invert_all.yy",}, + {"name":"sh_mask_invert","order":20,"path":"shaders/sh_mask_invert/sh_mask_invert.yy",}, {"name":"sh_invert","order":17,"path":"shaders/sh_invert/sh_invert.yy",}, {"name":"sh_kuwahara_ani","order":37,"path":"shaders/sh_kuwahara_ani/sh_kuwahara_ani.yy",}, {"name":"sh_kuwahara","order":36,"path":"shaders/sh_kuwahara/sh_kuwahara.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 511edb0fd..36497c3d0 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -1828,7 +1828,7 @@ {"id":{"name":"sh_herringbone_tile","path":"shaders/sh_herringbone_tile/sh_herringbone_tile.yy",},}, {"id":{"name":"sh_image_trace","path":"shaders/sh_image_trace/sh_image_trace.yy",},}, {"id":{"name":"sh_interpret_number","path":"shaders/sh_interpret_number/sh_interpret_number.yy",},}, - {"id":{"name":"sh_invert_all","path":"shaders/sh_invert_all/sh_invert_all.yy",},}, + {"id":{"name":"sh_mask_invert","path":"shaders/sh_mask_invert/sh_mask_invert.yy",},}, {"id":{"name":"sh_invert","path":"shaders/sh_invert/sh_invert.yy",},}, {"id":{"name":"sh_kuwahara_ani","path":"shaders/sh_kuwahara_ani/sh_kuwahara_ani.yy",},}, {"id":{"name":"sh_kuwahara","path":"shaders/sh_kuwahara/sh_kuwahara.yy",},}, diff --git a/scripts/mask_function/mask_function.gml b/scripts/mask_function/mask_function.gml index 5dae1a3c4..4bdb1a7f1 100644 --- a/scripts/mask_function/mask_function.gml +++ b/scripts/mask_function/mask_function.gml @@ -31,7 +31,8 @@ function mask_modify(mask, invert = false, feather = 0) { #region __temp_mask = surface_verify(__temp_mask, surface_get_width_safe(mask), surface_get_height_safe(mask)); - surface_set_shader(__temp_mask, invert? sh_invert_all : noone); + surface_set_shader(__temp_mask, sh_mask_invert); + shader_set_i("invert", invert); draw_surface(mask, 0, 0); surface_reset_shader(); diff --git a/scripts/node_armature_bind/node_armature_bind.gml b/scripts/node_armature_bind/node_armature_bind.gml index c4964c3d7..0aec72496 100644 --- a/scripts/node_armature_bind/node_armature_bind.gml +++ b/scripts/node_armature_bind/node_armature_bind.gml @@ -907,6 +907,8 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr } #endregion static attributeDeserialize = function(attr) { #region + struct_append(attributes, attr); + if(struct_has(attributes, "use_project_dimension") && !struct_has(attr, "use_project_dimension")) attributes.use_project_dimension = false; diff --git a/scripts/node_ase_file_read/node_ase_file_read.gml b/scripts/node_ase_file_read/node_ase_file_read.gml index 10b2d23fb..57d1f3cb6 100644 --- a/scripts/node_ase_file_read/node_ase_file_read.gml +++ b/scripts/node_ase_file_read/node_ase_file_read.gml @@ -372,6 +372,8 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const } #endregion static attributeDeserialize = function(attr) { #region + struct_append(attributes, attr); + if(struct_has(attr, "layer_visible")) attributes.layer_visible = attr.layer_visible; } #endregion diff --git a/scripts/node_blend/node_blend.gml b/scripts/node_blend/node_blend.gml index 21b7b19dc..88525ccd5 100644 --- a/scripts/node_blend/node_blend.gml +++ b/scripts/node_blend/node_blend.gml @@ -147,10 +147,6 @@ function Node_Blend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con inputs[| 7].setVisible(_outp == 4); inputs[| 14].setVisible(_fill == 0 && !_atlas); - - var _msk = is_surface(getSingleValue(4)); - inputs[| 12].setVisible(_msk); - inputs[| 12].setVisible(_msk); } #endregion static processData = function(_outSurf, _data, _output_index, _array_index) { #region diff --git a/scripts/node_collection/node_collection.gml b/scripts/node_collection/node_collection.gml index 1e92d34d3..9a38bf487 100644 --- a/scripts/node_collection/node_collection.gml +++ b/scripts/node_collection/node_collection.gml @@ -208,7 +208,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc static onInspector2Update = function() { #region var i = 0; - repeat(node_length) { + repeat(ds_list_size(nodes)) { if(nodes[| i].hasInspector2Update()) nodes[| i].inspector2Update(); i++; @@ -219,11 +219,12 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc will_refresh = false; static refreshNodes = function() { #region will_refresh = false; - node_length = ds_list_size(nodes); hasInsp1 = false; hasInsp2 = false; + node_length = ds_list_size(nodes); + var i = 0; repeat(node_length) { hasInsp1 |= nodes[| i].hasInspector1Update(); @@ -231,6 +232,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc i++; } + } #endregion static getNodeBase = function() { #region @@ -330,10 +332,9 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc static setRenderStatus = function(result) { #region LOG_BLOCK_START(); - if(rendered == result) return; - LOG_IF(global.FLAG.render == 1, $"Set render status for {INAME} : {result}"); rendered = result; + if(rendered == result) return; if(result) for( var i = custom_output_index, n = ds_list_size(outputs); i < n; i++ ) { @@ -354,6 +355,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc static isActiveDynamic = function(frame = CURRENT_FRAME) { #region if(update_on_frame) return true; + if(!rendered) return true; for( var i = custom_input_index, n = ds_list_size(inputs); i < n; i++ ) if(inputs[| i].isActiveDynamic(frame) || !inputs[| i].from.rendered) return true; @@ -372,6 +374,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc _node.group = self; will_refresh = true; + node_length = ds_list_size(nodes); } #endregion static remove = function(_node) { #region @@ -392,6 +395,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc _node.group = group; will_refresh = true; + node_length = ds_list_size(nodes); } #endregion static clearCache = function() { #region @@ -401,10 +405,10 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc } } #endregion - static stepBegin = function() { + static stepBegin = function() { #region if(will_refresh) refreshNodes(); doStepBegin(); - } + } #endregion static step = function() { #region if(combine_render_time) { @@ -444,19 +448,37 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc } #endregion static sortIO = function() { #region - for( var i = 0; i < ds_list_size(inputs); i++ ) - array_push_unique(attributes.input_display_list, i); + var _ilen = ds_list_size(inputs); + var _iarr = attributes.input_display_list; + + for( var i = 0; i < _ilen; i++ ) + array_push_unique(_iarr, i); + for( var i = array_length(_iarr) - 1; i >= 0; i-- ) { + if(_iarr[i] >= _ilen) array_delete(_iarr, i, 1); + } + input_display_list = attributes.input_display_list; - for( var i = 0; i < ds_list_size(outputs); i++ ) - array_push_unique(attributes.output_display_list, i); + /////////////////////////////////////////////////////////////////// + + var _olen = ds_list_size(outputs); + var _oarr = attributes.output_display_list; + + for( var i = 0; i < _olen; i++ ) + array_push_unique(_oarr, i); + for( var i = array_length(_oarr) - 1; i >= 0; i-- ) { + if(_oarr[i] >= _olen) + array_delete(_oarr, i, 1); + } output_display_list = attributes.output_display_list; + /////////////////////////////////////////////////////////////////// + refreshNodeDisplay(); } #endregion static getTool = function() { #region - for(var i = 0; i < node_length; i++) { + for(var i = 0, n = ds_list_size(nodes); i < n; i++) { var _node = nodes[| i]; if(!_node.active) continue; if(_node.isTool) return _node.getTool(); @@ -473,7 +495,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc var dups = ds_list_create(); - for(var i = 0; i < node_length; i++) { + for(var i = 0, n = ds_list_size(nodes); i < n; i++) { var _node = nodes[| i]; var _cnode = _node.clone(target); ds_list_add(dups, _cnode); @@ -506,12 +528,13 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc } #endregion static resetRender = function(_clearCache = false) { #region - LOG_LINE_IF(global.FLAG.render == 1, $"Reset Render for {INAME}"); + LOG_LINE_IF(global.FLAG.render == 1, $"Reset Render for group {INAME}"); setRenderStatus(false); if(_clearCache) clearInputCache(); - for( var i = 0; i < node_length; i++ ) + if(reset_all_child) + for(var i = 0, n = ds_list_size(nodes); i < n; i++) nodes[| i].resetRender(_clearCache); } #endregion @@ -540,7 +563,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc static getGraphPreviewSurface = function() { #region var _output_junc = outputs[| preview_channel]; - for( var i = 0, n = node_length; i < n; i++ ) { + for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) { if(!nodes[| i].active) continue; if(is_instanceof(nodes[| i], Node_Group_Thumbnail)) _output_junc = nodes[| i].inputs[| 0]; @@ -559,12 +582,85 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc static enable = function() { #region active = true; timeline_item.active = true; - for( var i = 0, n = node_length; i < n; i++ ) nodes[| i].enable(); + for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) nodes[| i].enable(); } #endregion static disable = function() { #region active = false; timeline_item.active = false; - for( var i = 0, n = node_length; i < n; i++ ) nodes[| i].disable(); + for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) nodes[| i].disable(); + } #endregion + + static attributeSerialize = function() { #region + sortIO(); + + var _attr = variable_clone(attributes); + + _attr.custom_input_list = []; + for( var i = custom_input_index, n = ds_list_size(inputs); i < n; i++ ) { + if(struct_has(inputs[| i], "from")) + array_push(_attr.custom_input_list, inputs[| i].from.node_id); + } + + _attr.custom_output_list = []; + for( var i = custom_output_index, n = ds_list_size(outputs); i < n; i++ ) { + if(struct_has(outputs[| i], "from")) + array_push(_attr.custom_output_list , outputs[| i].from.node_id); + } + + return _attr; + } #endregion + + static doApplyDeserialize = function() { #region + var attr = attributes; + + if(struct_has(attr, "custom_input_list")) { + var _ilist = attr.custom_input_list; + var _inarr = {}; + + for( var i = ds_list_size(inputs) - 1; i >= custom_input_index; i-- ) { + if(!struct_has(inputs[| i], "from")) continue; + + var _frNode = inputs[| i].from.node_id; + if(array_exists(_ilist, _frNode)) { + _inarr[$ _frNode] = inputs[| i]; + ds_list_delete(inputs, i); + } + } + + for( var i = 0, n = array_length(_ilist); i < n; i++ ) { + if(!struct_has(_inarr, _ilist[i])) continue; + + ds_list_add(inputs, _inarr[$ _ilist[i]]); + } + } + + if(struct_has(attr, "custom_output_list")) { + var _ilist = attr.custom_output_list; + var _inarr = {}; + + for( var i = ds_list_size(outputs) - 1; i >= custom_output_index; i-- ) { + if(!struct_has(outputs[| i], "from")) continue; + + var _frNode = outputs[| i].from.node_id; + if(array_exists(_ilist, _frNode)) { + _inarr[$ _frNode] = outputs[| i]; + ds_list_delete(outputs, i); + } + } + + for( var i = 0, n = array_length(_ilist); i < n; i++ ) { + if(!struct_has(_inarr, _ilist[i])) continue; + + ds_list_add(outputs, _inarr[$ _ilist[i]]); + } + } + + var custom_input_list = []; + for( var i = custom_input_index, n = ds_list_size(inputs); i < n; i++ ) { + if(struct_has(inputs[| i], "from")) + array_push(custom_input_list, inputs[| i].from.node_id); + } + } #endregion static processSerialize = function(_map) { #region diff --git a/scripts/node_composite/node_composite.gml b/scripts/node_composite/node_composite.gml index 0e879b0e0..0c82f5a5a 100644 --- a/scripts/node_composite/node_composite.gml +++ b/scripts/node_composite/node_composite.gml @@ -880,6 +880,8 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) } #endregion static attributeDeserialize = function(attr) { #region + struct_append(attributes, attr); + if(struct_has(attributes, "use_project_dimension") && !struct_has(attr, "use_project_dimension")) attributes.use_project_dimension = false; diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index d20f8631e..4d6a5c49b 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -357,17 +357,19 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { inputs[| i].visible_in_list = false; inputs_amount = (input_display_list == -1 || !use_display_list)? ds_list_size(inputs) : array_length(input_display_list); - inputs_index = array_create(inputs_amount); - var _i = 0; + inputs_index = []; + for( var i = 0; i < inputs_amount; i++ ) { var _input = getInputJunctionIndex(i); if(_input == noone) continue; - inputs_index[_i++] = _input; - inputs[| _input].visible_in_list = true; + var _inp = inputs[| _input]; + if(!is_struct(_inp) || !is_instanceof(_inp, NodeValue)) continue; + + array_push(inputs_index, _input); + _inp.visible_in_list = true; } - inputs_amount = _i; - array_resize(inputs_index, inputs_amount); + inputs_amount = array_length(inputs_index); outputs_amount = output_display_list == -1? ds_list_size(outputs) : array_length(output_display_list); outputs_index = array_create_ext(outputs_amount, function(index) { return getOutputJunctionIndex(index); }); @@ -515,7 +517,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { static isActiveDynamic = function(frame = CURRENT_FRAME) { #region if(update_on_frame) return true; - if(!rendered) return true; + if(!rendered) return true; force_requeue = false; for(var i = 0; i < ds_list_size(inputs); i++) @@ -716,16 +718,14 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { static triggerRender = function() { #region LOG_BLOCK_START(); - //printCallStack(); LOG_IF(global.FLAG.render == 1, $"Trigger render for {self}"); - setRenderStatus(false); + resetRender(false); RENDER_PARTIAL - if(is_instanceof(group, Node_Collection) && group.reset_all_child) { - group.resetRender(); + if(is_instanceof(group, Node_Collection)) { + group.triggerRender(); } else { - resetRender(); var nodes = getNextNodesRaw(); for(var i = 0; i < array_length(nodes); i++) @@ -795,6 +795,15 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { return true; } #endregion + static setRenderStatus = function(result) { #region + INLINE + + if(rendered == result) return; + LOG_LINE_IF(global.FLAG.render == 1, $"Set render status for {self} : {result}"); + + rendered = result; + } #endregion + static getPreviousNodes = function() { #region var prev = []; @@ -897,15 +906,6 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { static onInspect = function() {} - static setRenderStatus = function(result) { #region - INLINE - - if(rendered == result) return; - LOG_LINE_IF(global.FLAG.render == 1, $"Set render status for {self} : {result}"); - - rendered = result; - } #endregion - static pointIn = function(_x, _y, _mx, _my, _s) { #region var xx = x * _s + _x; var yy = y * _s + _y; @@ -1616,6 +1616,8 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { static enable = function() { INLINE active = true; timeline_item.active = true; } static disable = function() { INLINE active = false; timeline_item.active = false; } + static onDestroy = function() {} + static destroy = function(_merge = false) { #region if(!active) return; disable(); @@ -1660,10 +1662,13 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { RENDER_ALL_REORDER } #endregion + static onRestore = function() {} + static restore = function() { #region if(active) return; enable(); - ds_list_add(group == noone? PROJECT.nodes : group.getNodeList(), self); + + onRestore(); if(group) group.refreshNodes(); RENDER_ALL_REORDER @@ -1681,8 +1686,6 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { } } #endregion - static onDestroy = function() {} - static clearInputCache = function() { #region for( var i = 0; i < ds_list_size(inputs); i++ ) inputs[| i].cache_value[0] = false; @@ -2118,7 +2121,8 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { static attributeDeserialize = function(attr) { #region if(struct_has(attributes, "use_project_dimension") && !struct_has(attr, "use_project_dimension")) attributes.use_project_dimension = false; - struct_override(attributes, attr); + + struct_append(attributes, attr); } #endregion static postDeserialize = function() {} diff --git a/scripts/node_group_input/node_group_input.gml b/scripts/node_group_input/node_group_input.gml index 3bfdc6687..c92d7bcbc 100644 --- a/scripts/node_group_input/node_group_input.gml +++ b/scripts/node_group_input/node_group_input.gml @@ -291,8 +291,11 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru ds_list_add(group.inputs, inParent); outputs[| 0].setFrom(inParent, false, false); - group.refreshNodeDisplay(); - group.sortIO(); + + if(!LOADING && !APPENDING) { + group.refreshNodeDisplay(); + group.sortIO(); + } onValueUpdate(0); @@ -379,8 +382,10 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru static onDestroy = function() { #region if(is_undefined(inParent)) return; + ds_list_remove(group.inputs, inParent); group.sortIO(); + group.refreshNodes(); } #endregion static ungroup = function() { #region diff --git a/scripts/node_group_output/node_group_output.gml b/scripts/node_group_output/node_group_output.gml index 1be8ad7f5..2020c9d22 100644 --- a/scripts/node_group_output/node_group_output.gml +++ b/scripts/node_group_output/node_group_output.gml @@ -79,8 +79,11 @@ function Node_Group_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constr outParent.from = self; ds_list_add(group.outputs, outParent); - group.refreshNodeDisplay(); - group.sortIO(); + + if(!LOADING && !APPENDING) { + group.refreshNodeDisplay(); + group.sortIO(); + } outParent.setFrom(inputs[| 0]); } if(!LOADING && !APPENDING) createOutput(); #endregion @@ -104,7 +107,6 @@ function Node_Group_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constr if(group == noone) return; createOutput(false); - group.sortIO(); } #endregion static doApplyDeserialize = function() { #region @@ -113,8 +115,10 @@ function Node_Group_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constr static onDestroy = function() { #region if(is_undefined(outParent)) return; + ds_list_remove(group.outputs, outParent); group.sortIO(); + group.refreshNodes(); } #endregion static ungroup = function() { #region diff --git a/scripts/node_mesh_warp/node_mesh_warp.gml b/scripts/node_mesh_warp/node_mesh_warp.gml index 89b6fed5d..3de826522 100644 --- a/scripts/node_mesh_warp/node_mesh_warp.gml +++ b/scripts/node_mesh_warp/node_mesh_warp.gml @@ -814,6 +814,8 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) loadPin = noone; static attributeDeserialize = function(attr) { #region + struct_append(attributes, attr); + if(struct_has(attr, "pin")) loadPin = attr.pin; if(struct_has(attr, "mesh_bound")) attributes.mesh_bound = attr.mesh_bound;; } #endregion diff --git a/scripts/node_rigid_object/node_rigid_object.gml b/scripts/node_rigid_object/node_rigid_object.gml index 3188e9a43..177dc3943 100644 --- a/scripts/node_rigid_object/node_rigid_object.gml +++ b/scripts/node_rigid_object/node_rigid_object.gml @@ -756,6 +756,8 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr } #endregion static attributeDeserialize = function(attr) { #region + struct_append(attributes, attr); + if(struct_has(attr, "mesh")) attributes.mesh = json_parse(attr.mesh); } #endregion diff --git a/scripts/node_strand_create/node_strand_create.gml b/scripts/node_strand_create/node_strand_create.gml index 374caf266..94993c9ab 100644 --- a/scripts/node_strand_create/node_strand_create.gml +++ b/scripts/node_strand_create/node_strand_create.gml @@ -554,6 +554,8 @@ function Node_Strand_Create(_x, _y, _group = noone) : Node(_x, _y, _group) const } #endregion static attributeDeserialize = function(attr) { #region + struct_append(attributes, attr); + if(struct_has(attr, "fixStrand")) groomed.deserialize(attr.fixStrand); diff --git a/scripts/pathAnchorBox/pathAnchorBox.gml b/scripts/pathAnchorBox/pathAnchorBox.gml index 467bd6d00..cb362859a 100644 --- a/scripts/pathAnchorBox/pathAnchorBox.gml +++ b/scripts/pathAnchorBox/pathAnchorBox.gml @@ -76,7 +76,7 @@ function pathAnchorBox(_onModify) : widget() constructor { tb[4].draw(_tx + (_tw + 4) * 2 + _bw + 8, _ty, _tw, _th, _data[4], _m); tb[5].draw(_tx + (_tw + 4) * 3 + _bw + 8, _ty, _tw, _th, _data[5], _m); - var _linked = _data[6]; + var _linked = array_safe_get(_data, 6); var _blend = !_linked? COLORS._main_accent : COLORS._main_icon; var bx = _x + _w / 2 - _bw / 2 - 2; var by = _ty + _th / 2 - _bw / 2; diff --git a/scripts/version_checker/version_checker.gml b/scripts/version_checker/version_checker.gml index 229bd5de4..e1d32aa83 100644 --- a/scripts/version_checker/version_checker.gml +++ b/scripts/version_checker/version_checker.gml @@ -4,7 +4,7 @@ function check_version(path) { return true; } - if(TESTING) return true; + //if(TESTING) return true; var res = json_load_struct(path); json_save_struct(path, { version: BUILD_NUMBER }); diff --git a/shaders/sh_invert_all/sh_invert_all.fsh b/shaders/sh_invert_all/sh_invert_all.fsh deleted file mode 100644 index a3f6dce6a..000000000 --- a/shaders/sh_invert_all/sh_invert_all.fsh +++ /dev/null @@ -1,10 +0,0 @@ -// -// Simple passthrough fragment shader -// -varying vec2 v_vTexcoord; -varying vec4 v_vColour; - -void main() { - vec4 c = texture2D( gm_BaseTexture, v_vTexcoord ); - gl_FragColor = 1. - c; -} diff --git a/shaders/sh_mask_invert/sh_mask_invert.fsh b/shaders/sh_mask_invert/sh_mask_invert.fsh new file mode 100644 index 000000000..8517a30bc --- /dev/null +++ b/shaders/sh_mask_invert/sh_mask_invert.fsh @@ -0,0 +1,12 @@ +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform int invert; + +void main() { + vec4 c = texture2D( gm_BaseTexture, v_vTexcoord ); + float m = (c.r + c.g + c.b) / 3. * c.a; + if(invert == 1) m = 1. - m; + + gl_FragColor = vec4(m, m, m, 1.); +} diff --git a/shaders/sh_invert_all/sh_invert_all.vsh b/shaders/sh_mask_invert/sh_mask_invert.vsh similarity index 100% rename from shaders/sh_invert_all/sh_invert_all.vsh rename to shaders/sh_mask_invert/sh_mask_invert.vsh diff --git a/shaders/sh_invert_all/sh_invert_all.yy b/shaders/sh_mask_invert/sh_mask_invert.yy similarity index 75% rename from shaders/sh_invert_all/sh_invert_all.yy rename to shaders/sh_mask_invert/sh_mask_invert.yy index 7b657d4c0..dc0630b6d 100644 --- a/shaders/sh_invert_all/sh_invert_all.yy +++ b/shaders/sh_mask_invert/sh_mask_invert.yy @@ -1,7 +1,7 @@ { "$GMShader":"", - "%Name":"sh_invert_all", - "name":"sh_invert_all", + "%Name":"sh_mask_invert", + "name":"sh_mask_invert", "parent":{ "name":"color", "path":"folders/shader/filter/color.yy",