- [Invert] Add option to invert alpha.

This commit is contained in:
Tanasart 2024-07-11 14:23:34 +07:00
parent a44e2c96e0
commit 4cb634bd8b
3 changed files with 18 additions and 19 deletions

View File

@ -16,7 +16,9 @@ function Node_Invert(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
__init_mask_modifier(1); // inputs 5, 6
input_display_list = [ 3, 4,
inputs[| 7] = nodeValue("Include Alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
input_display_list = [ 3, 4, 7,
["Surfaces", true], 0, 1, 2, 5, 6,
]
@ -24,26 +26,22 @@ function Node_Invert(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
attribute_surface_depth();
static step = function() { #region
static step = function() {
__step_mask_modifier();
} #endregion
}
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
surface_set_target(_outSurf);
DRAW_CLEAR
BLEND_OVERRIDE;
shader_set(sh_invert);
static processData = function(_outSurf, _data, _output_index, _array_index) {
surface_set_shader(_outSurf, sh_invert);
shader_set_i("alpha", _data[7]);
draw_surface_safe(_data[0]);
shader_reset();
BLEND_NORMAL;
surface_reset_target();
surface_reset_shader();
__process_mask_modifier(_data);
_outSurf = mask_apply(_data[0], _outSurf, _data[1], _data[2]);
_outSurf = channel_apply(_data[0], _outSurf, _data[4]);
return _outSurf;
} #endregion
}
}

View File

@ -118,7 +118,7 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
var sz = min(size, array_length(_data));
var _bs = min(_h, ui(32));
if(unit) for(var i = 0; i < sz; i++) tb[i].slide_int = unit.mode == VALUE_UNIT.constant? true : false;
if(unit && unit.reference != noone) for(var i = 0; i < sz; i++) tb[i].slide_int = unit.mode == VALUE_UNIT.constant? true : false;
if((_w - _bs) / sz > ui(48)) {
if(side_button) {

View File

@ -1,10 +1,11 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform int alpha;
void main() {
vec4 c = texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor = vec4(1. - c.rgb, c.a);
if(alpha == 0) gl_FragColor = vec4(1. - c.rgb, c.a);
else if(alpha == 1) gl_FragColor = 1. - c;
}