From 1d616cfc8163ba1c8b4a3d5f8095a17e8ecd1f85 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Wed, 12 Jun 2024 15:06:17 +0700 Subject: [PATCH] - New Blend edge node. --- PixelComposer.resource_order | 1 + PixelComposer.yyp | 1 + scripts/node_blend_edge/node_blend_edge.gml | 43 +++++++-- scripts/node_registry/node_registry.gml | 2 +- scripts/node_value/node_value.gml | 2 +- shaders/sh_blend_edge/sh_blend_edge.fsh | 26 +++-- .../0eab1d7e-c05a-4c81-8014-d441c44b42d9.png | Bin 0 -> 1952 bytes .../1cb8cdda-51c9-4f2e-89b7-2540ea24f5a6.png | Bin 0 -> 1952 bytes .../s_node_blend_edge/s_node_blend_edge.yy | 90 ++++++++++++++++++ 9 files changed, 144 insertions(+), 21 deletions(-) create mode 100644 sprites/s_node_blend_edge/0eab1d7e-c05a-4c81-8014-d441c44b42d9.png create mode 100644 sprites/s_node_blend_edge/layers/0eab1d7e-c05a-4c81-8014-d441c44b42d9/1cb8cdda-51c9-4f2e-89b7-2540ea24f5a6.png create mode 100644 sprites/s_node_blend_edge/s_node_blend_edge.yy diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 22851e4fb..93dca1688 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -1675,6 +1675,7 @@ {"name":"s_node_bend_type","order":21,"path":"sprites/s_node_bend_type/s_node_bend_type.yy",}, {"name":"s_node_bend","order":20,"path":"sprites/s_node_bend/s_node_bend.yy",}, {"name":"s_node_bevel","order":4,"path":"sprites/s_node_bevel/s_node_bevel.yy",}, + {"name":"s_node_blend_edge","order":67,"path":"sprites/s_node_blend_edge/s_node_blend_edge.yy",}, {"name":"s_node_blend","order":5,"path":"sprites/s_node_blend/s_node_blend.yy",}, {"name":"s_node_blobify","order":6,"path":"sprites/s_node_blobify/s_node_blobify.yy",}, {"name":"s_node_bloom","order":7,"path":"sprites/s_node_bloom/s_node_bloom.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 77de05efb..e485dfb95 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -2221,6 +2221,7 @@ {"id":{"name":"s_node_bend_type","path":"sprites/s_node_bend_type/s_node_bend_type.yy",},}, {"id":{"name":"s_node_bend","path":"sprites/s_node_bend/s_node_bend.yy",},}, {"id":{"name":"s_node_bevel","path":"sprites/s_node_bevel/s_node_bevel.yy",},}, + {"id":{"name":"s_node_blend_edge","path":"sprites/s_node_blend_edge/s_node_blend_edge.yy",},}, {"id":{"name":"s_node_blend","path":"sprites/s_node_blend/s_node_blend.yy",},}, {"id":{"name":"s_node_blobify","path":"sprites/s_node_blobify/s_node_blobify.yy",},}, {"id":{"name":"s_node_bloom","path":"sprites/s_node_bloom/s_node_bloom.yy",},}, diff --git a/scripts/node_blend_edge/node_blend_edge.gml b/scripts/node_blend_edge/node_blend_edge.gml index 61b4010de..6dbce05aa 100644 --- a/scripts/node_blend_edge/node_blend_edge.gml +++ b/scripts/node_blend_edge/node_blend_edge.gml @@ -26,9 +26,12 @@ function Node_Blend_Edge(_x, _y, _group = noone) : Node_Processor(_x, _y, _group inputs[| 6] = nodeValue("Blending", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) .setDisplay(VALUE_DISPLAY.slider); + inputs[| 7] = nodeValue("Smoothness", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) + .setDisplay(VALUE_DISPLAY.slider); + input_display_list = [ 3, 4, ["Surfaces", true], 0, - ["Blend", false], 2, 1, 5, 6, + ["Blend", false], 2, 1, 5, 6, 7, ] outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); @@ -48,16 +51,36 @@ function Node_Blend_Edge(_x, _y, _group = noone) : Node_Processor(_x, _y, _group for( var i = 0, n = array_length(temp_surface); i < n; i++ ) temp_surface[i] = surface_verify(temp_surface[i], _sw, _sh); - surface_set_shader(_outSurf, sh_blend_edge); - shader_set_f("dimension", _sw, _sh); - shader_set_f_map("width", clamp(_data[1], 0.001, 0.999), _data[5], inputs[| 1]); - shader_set_i("edge" , _data[2]); - shader_set_f("blend" , clamp(_data[6], 0.001, 0.999)); - - draw_surface(_data[0], 0, 0); - surface_reset_shader(); + var _edg = _data[2]; - //return temp_surface[0]; + if(_edg == 0) { + surface_set_shader(temp_surface[0], sh_blend_edge); + shader_set_f("dimension", _sw, _sh); + shader_set_f_map("width", _data[1], _data[5], inputs[| 1]); + shader_set_i("edge" , 0); + shader_set_f("blend" , clamp(_data[6], 0.001, 0.999)); + shader_set_f("smooth" , _data[7]); + + draw_surface(_data[0], 0, 0); + surface_reset_shader(); + + surface_set_shader(_outSurf, sh_blend_edge); + shader_set_i("edge" , 1); + + draw_surface(temp_surface[0], 0, 0); + surface_reset_shader(); + + } else { + surface_set_shader(_outSurf, sh_blend_edge); + shader_set_f("dimension", _sw, _sh); + shader_set_f_map("width", _data[1], _data[5], inputs[| 1]); + shader_set_i("edge" , _edg - 1); + shader_set_f("blend" , clamp(_data[6], 0.001, 0.999)); + + draw_surface(_data[0], 0, 0); + surface_reset_shader(); + + } return _outSurf; } diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index a01a80a2d..627a5aad6 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -611,7 +611,7 @@ function __initNodes() { addNodeObject(filter, "Vignette", s_node_vignette, "Node_Vignette", [1, Node_Vignette],, "Apply vignette effect to the border.").setVersion(11630); addNodeObject(filter, "FXAA", s_node_FXAA, "Node_FXAA", [1, Node_FXAA],, "Apply fast approximate anti-aliasing to te image."); addNodeObject(filter, "JPEG", s_node_JPEG, "Node_JPEG", [1, Node_JPEG],, "Apply JPEG compression to the image.").setVersion(11730); - //addNodeObject(filter, "Blend Edge", s_node_FXAA, "Node_Blend_Edge", [1, Node_Blend_Edge]).setVersion(11640); + addNodeObject(filter, "Blend Edge", s_node_blend_edge, "Node_Blend_Edge", [1, Node_Blend_Edge]).setVersion(11740); ds_list_add(filter, "Colors"); addNodeObject(filter, "Replace Palette", s_node_replace_palette, "Node_Color_replace", [1, Node_Color_replace], ["isolate color", "select color", "palette swap", "color replace"], "Replace color that match one palette with another palette."); diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index e31d34463..9823be294 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -370,7 +370,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if( attributes.mapped) setValue([0, 0]); - if(!attributes.mapped && is_array(def_val)) + if(!attributes.mapped) setValue(def_val); setArrayDepth(attributes.mapped); diff --git a/shaders/sh_blend_edge/sh_blend_edge.fsh b/shaders/sh_blend_edge/sh_blend_edge.fsh index 7b0bbc75f..1c7692465 100644 --- a/shaders/sh_blend_edge/sh_blend_edge.fsh +++ b/shaders/sh_blend_edge/sh_blend_edge.fsh @@ -9,6 +9,7 @@ uniform int widthUseSurf; uniform sampler2D widthSurf; uniform float blend; +uniform float smooth; void main() { float wid = width.x; @@ -20,17 +21,24 @@ void main() { float bnd = 1. - blend; vec4 off; - float m = 0.; - vec2 v = 1. - max(vec2(0.), abs(v_vTexcoord - 0.5) * 2. / wid - bnd) / (1. - bnd); - vec2 vi = 1. - max(vec2(0.), (1. - abs(v_vTexcoord - 0.5) * 2.) / wid - bnd) / (1. - bnd); - float mi = 1. - max(vi.x, vi.y); + float m = 0.; + vec2 v = 1. - max(vec2(0.), (1. - abs(v_vTexcoord - 0.5) * 2.) / wid - bnd) / (1. - bnd); - if(edge == 0) m = min(max(v.x, v.y), max(v.x, v.y) + mi - 1.); - else if(edge == 1) m = v.x; - else if(edge == 2) m = v.y; + vec4 c1 = texture2D( gm_BaseTexture, v_vTexcoord ); + vec4 c2; + + if(edge == 0) { + m = v.x; + c2 = texture2D( gm_BaseTexture, vec2(fract(v_vTexcoord.x + 0.5), v_vTexcoord.y) ); + + } else if(edge == 1) { + m = v.y; + c2 = texture2D( gm_BaseTexture, vec2(v_vTexcoord.x, fract(v_vTexcoord.y + 0.5)) ); + + } m = clamp(m, 0., 1.); - //m = smoothstep(0., 1., m); + m = mix(m, smoothstep(0., 1., m), smooth); - gl_FragColor = vec4(vec3(m), 1.); + gl_FragColor = mix(c1, c2, m); } diff --git a/sprites/s_node_blend_edge/0eab1d7e-c05a-4c81-8014-d441c44b42d9.png b/sprites/s_node_blend_edge/0eab1d7e-c05a-4c81-8014-d441c44b42d9.png new file mode 100644 index 0000000000000000000000000000000000000000..9cfb8baab1c9564d3bfb229516a651f78e09b293 GIT binary patch literal 1952 zcmZ{lc{J1u8^?dYpFu`x#(J|is*$a+FIk30Lu1PpBMdRFmW%A$_*u$KNuh=kDJ8E8 zktG?1ZmyGVhN~fI3{q)9mkcwOckVy$Iqx6$Jm>j-&v~BnInVRg^Dw+Th&zy~NB{tK zxVjL$#g6|cw@Hb$E;^1UHtiEG-tGX9whsW{JOB`iOYmm^NW=la7YYE_lmUQB?9Gm& zw&I3VIEhFAw*HAK*8LK3p~RKo=$kVBy_|F*@(=X+ZhE`LFH^)BsUX!dsS~+G`4o_s z!{m%#XL3lf3wXOXwL|!%L)V$73#2nmdvocpNF=T5%cxyx8kg@f?Z9R6SP`m$r-Q_Be()1Z}<>*@~ z2Efo^ZJYozurX(is ziix26egzaB(hYuJ{)#39r)RCm!48|V4VF3-sjM!?l;fFM@eozs=wxE3-E~oZ zR6Dja zlSf_ekOWJTq-*!|WMZmwe=Gb$$Xh{J)m^BisM7V&*>#W;KsL?A5Z-rdfHzlJB4lS9 zt#b5+=O@F(F)sAP0B`Q4)C*nGb{Zf{?kI+K*!I8GhGd?yBqL&j+@9qgm#AM-Zg0z| zKSP2aR4E5YSCGl7v#Zle>q=PEQya}-G{Q5Sjc9Lq0g*}Uw+95{ea3jd$J;n;LtMDb z2)j&h7+(+uwqYodLLHO`o3)q2pmV9v_(udm_x5@J;d4DXhBGi--fA}rld=chrlTFe z9(wF3o~cAlWgkJMMQ-opnUxt+er#Ag>(RawWv;iJCf0S(rZ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oMfF%3N13 zOq|^0d`JvaopiJ2kJ!qC{n7iVRI z!`Yad>WdYJoBuZI_kX~dn22a<>c0cG9>>gy0p0&iNQgcY8J`e#CidT%{<|I)Vg_(^ L_8`":"", + "Keyframes":[], + "resourceType":"KeyframeStore", + "resourceVersion":"2.0", + }, + "eventStubScript":null, + "eventToFunction":{}, + "length":1.0, + "lockOrigin":false, + "moments":{ + "$KeyframeStore":"", + "Keyframes":[], + "resourceType":"KeyframeStore", + "resourceVersion":"2.0", + }, + "name":"s_node_blend_edge", + "playback":1, + "playbackSpeed":30.0, + "playbackSpeedType":0, + "resourceType":"GMSequence", + "resourceVersion":"2.0", + "showBackdrop":true, + "showBackdropImage":false, + "timeUnits":1, + "tracks":[ + {"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore":"","Keyframes":[ + {"$Keyframe":"","Channels":{ + "0":{"$SpriteFrameKeyframe":"","Id":{"name":"0eab1d7e-c05a-4c81-8014-d441c44b42d9","path":"sprites/s_node_blend_edge/s_node_blend_edge.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",}, + },"Disabled":false,"id":"b1f41c73-2dfc-4e6c-b7ed-310fc9652558","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe","resourceVersion":"2.0","Stretch":false,}, + ],"resourceType":"KeyframeStore","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,}, + ], + "visibleRange":null, + "volume":1.0, + "xorigin":32, + "yorigin":32, + }, + "swatchColours":null, + "swfPrecision":0.5, + "textureGroupId":{ + "name":"Default", + "path":"texturegroups/Default", + }, + "type":0, + "VTile":false, + "width":64, +} \ No newline at end of file