From a7bb431b86587ae20f62481e432f1a0a5de5657f Mon Sep 17 00:00:00 2001 From: Tanasart Date: Tue, 21 Nov 2023 20:03:09 +0700 Subject: [PATCH] - [RGB Combine] Fix mode property not functional. - [Color adjust] Fix node picking up random surface as mask when no mask attached. --- scripts/globals/globals.gml | 6 ++-- .../node_color_adjustment.gml | 8 ++++-- scripts/node_combine_rgb/node_combine_rgb.gml | 28 +++++++++---------- scripts/shader_functions/shader_functions.gml | 10 +++---- shaders/sh_combine_rgb/sh_combine_rgb.fsh | 27 +++++++++--------- 5 files changed, 42 insertions(+), 37 deletions(-) diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 80d6cb44f..385d2a297 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -25,10 +25,10 @@ globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION; LATEST_VERSION = 11500; - VERSION = 11582; + VERSION = 11583; SAVE_VERSION = 11570; - VERSION_STRING = "1.16rc2"; - BUILD_NUMBER = 11582; + VERSION_STRING = "1.16rc3"; + BUILD_NUMBER = 11583; globalvar APPEND_MAP; APPEND_MAP = ds_map_create(); diff --git a/scripts/node_color_adjustment/node_color_adjustment.gml b/scripts/node_color_adjustment/node_color_adjustment.gml index b101f62f5..5fff3243c 100644 --- a/scripts/node_color_adjustment/node_color_adjustment.gml +++ b/scripts/node_color_adjustment/node_color_adjustment.gml @@ -44,12 +44,16 @@ function Node_Color_adjust(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro inputs[| 14] = nodeValue("Blend mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) .setDisplay(VALUE_DISPLAY.enum_scroll, BLEND_TYPES); + inputs[| 15] = nodeValue("Channel", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0b1111) + .setDisplay(VALUE_DISPLAY.toggle, { data: array_create(4, THEME.inspector_channel) }); + outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); outputs[| 1] = nodeValue("Color out", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, []) .setDisplay(VALUE_DISPLAY.palette); - input_display_list = [11, 12, 0, 8, 13, 9, + input_display_list = [11, 12, 15, 9, + ["Surface", false], 0, 8, 13, ["Brightness", false], 1, 10, 2, ["HSV", false], 3, 4, 5, ["Color blend", false], 6, 14, 7 @@ -141,7 +145,7 @@ function Node_Color_adjust(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro shader_set_color("blend", _bl, _bla); shader_set_i("blendMode", _blm); - shader_set_i("use_mask", _m != DEF_SURFACE); + shader_set_i("use_mask", is_surface(_m)); shader_set_surface("mask", _m); gpu_set_colorwriteenable(1, 1, 1, 0); diff --git a/scripts/node_combine_rgb/node_combine_rgb.gml b/scripts/node_combine_rgb/node_combine_rgb.gml index 0c478e5ee..becc0a4e6 100644 --- a/scripts/node_combine_rgb/node_combine_rgb.gml +++ b/scripts/node_combine_rgb/node_combine_rgb.gml @@ -1,10 +1,10 @@ function Node_Combine_RGB(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { name = "RGB Combine"; - inputs[| 0] = nodeValue("Red", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); - inputs[| 1] = nodeValue("Green", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); - inputs[| 2] = nodeValue("Blue", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); - inputs[| 3] = nodeValue("Alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); + inputs[| 0] = nodeValue("Red", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone); + inputs[| 1] = nodeValue("Green", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone); + inputs[| 2] = nodeValue("Blue", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone); + inputs[| 3] = nodeValue("Alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone); inputs[| 4] = nodeValue("Sampling type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) .setDisplay(VALUE_DISPLAY.enum_scroll, ["Brightness", "Channel value"]); @@ -19,20 +19,20 @@ function Node_Combine_RGB(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou attribute_surface_depth(); static processData = function(_outSurf, _data, _output_index, _array_index) { #region - var _r = _data[0]; - var _g = _data[1]; - var _b = _data[2]; - var _a = _data[3]; + var _r = _data[0]; + var _g = _data[1]; + var _b = _data[2]; + var _a = _data[3]; var _mode = _data[4]; surface_set_shader(_outSurf, sh_combine_rgb); - shader_set_surface("samR", _r); - shader_set_surface("samG", _g); - shader_set_surface("samB", _b); - shader_set_surface("samA", _a); + shader_set_surface("samplerR", _r); + shader_set_surface("samplerG", _g); + shader_set_surface("samplerB", _b); + shader_set_surface("samplerA", _a); - shader_set_i("useA", _mode); - shader_set_i("mode", is_surface(_a)); + shader_set_i("useA", is_surface(_a)); + shader_set_i("mode", _mode); draw_sprite_stretched(s_fx_pixel, 0, 0, 0, surface_get_width_safe(_outSurf), surface_get_height_safe(_outSurf)); surface_reset_shader(); diff --git a/scripts/shader_functions/shader_functions.gml b/scripts/shader_functions/shader_functions.gml index 8063c7850..6785539a0 100644 --- a/scripts/shader_functions/shader_functions.gml +++ b/scripts/shader_functions/shader_functions.gml @@ -81,14 +81,14 @@ function shader_set_surface(sampler, surface, linear = false, _repeat = false) { INLINE var shader = shader_current(); - if(shader == -1) return; - - if(is_struct(shader) && is_instanceof(shader, dynaSurf)) - shader = shader.surfaces[0]; - if(!is_surface(surface)) return; + if(shader == -1) return noone; var t = shader_get_sampler_index(shader, sampler); + if(is_instanceof(surface, dynaSurf)) + surface = surface.surfaces[0]; + if(!is_surface(surface)) return t; + texture_set_stage(t, surface_get_texture(surface)); gpu_set_tex_filter_ext(t, linear); gpu_set_tex_repeat_ext(t, _repeat); diff --git a/shaders/sh_combine_rgb/sh_combine_rgb.fsh b/shaders/sh_combine_rgb/sh_combine_rgb.fsh index f9e443e54..8de7447c0 100644 --- a/shaders/sh_combine_rgb/sh_combine_rgb.fsh +++ b/shaders/sh_combine_rgb/sh_combine_rgb.fsh @@ -6,28 +6,29 @@ varying vec4 v_vColour; uniform int useA; uniform int mode; -uniform sampler2D samR, samG, samB, samA; +uniform sampler2D samplerR; +uniform sampler2D samplerG; +uniform sampler2D samplerB; +uniform sampler2D samplerA; -float samC(vec4 col, int ch) { - if(mode == 0) - return (col[0] + col[1] + col[2]) / 3.; - +float sample(vec4 col, int ch) { + if(mode == 0) return (col[0] + col[1] + col[2]) / 3.; return col[ch]; } void main() { - vec4 _r = texture2D( samR, v_vTexcoord ); - vec4 _g = texture2D( samG, v_vTexcoord ); - vec4 _b = texture2D( samB, v_vTexcoord ); + vec4 _r = texture2D( samplerR, v_vTexcoord ); + vec4 _g = texture2D( samplerG, v_vTexcoord ); + vec4 _b = texture2D( samplerB, v_vTexcoord ); - float r = samC(_r, 0); - float g = samC(_g, 1); - float b = samC(_b, 2); + float r = sample(_r, 0); + float g = sample(_g, 1); + float b = sample(_b, 2); float a = 1.; if(useA == 1) { - vec4 _a = texture2D( samA, v_vTexcoord ); - a = samC(_a, 3); + vec4 _a = texture2D( samplerA, v_vTexcoord ); + a = sample(_a, 3); } gl_FragColor = vec4(r, g, b, a);