- New Blend edge node.

This commit is contained in:
Tanasart 2024-06-12 15:06:17 +07:00
parent 6ec32374bf
commit 1d616cfc81
9 changed files with 144 additions and 21 deletions

View file

@ -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",},

View file

@ -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",},},

View file

@ -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;
}

View file

@ -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.");

View file

@ -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);

View file

@ -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);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -0,0 +1,90 @@
{
"$GMSprite":"",
"%Name":"s_node_blend_edge",
"bboxMode":0,
"bbox_bottom":63,
"bbox_left":0,
"bbox_right":63,
"bbox_top":0,
"collisionKind":1,
"collisionTolerance":0,
"DynamicTexturePage":false,
"edgeFiltering":false,
"For3D":false,
"frames":[
{"$GMSpriteFrame":"","%Name":"0eab1d7e-c05a-4c81-8014-d441c44b42d9","name":"0eab1d7e-c05a-4c81-8014-d441c44b42d9","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
],
"gridX":0,
"gridY":0,
"height":64,
"HTile":false,
"layers":[
{"$GMImageLayer":"","%Name":"1cb8cdda-51c9-4f2e-89b7-2540ea24f5a6","blendMode":0,"displayName":"default","isLocked":false,"name":"1cb8cdda-51c9-4f2e-89b7-2540ea24f5a6","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
],
"name":"s_node_blend_edge",
"nineSlice":null,
"origin":4,
"parent":{
"name":"filter",
"path":"folders/nodes/icons/filter.yy",
},
"preMultiplyAlpha":false,
"resourceType":"GMSprite",
"resourceVersion":"2.0",
"sequence":{
"$GMSequence":"",
"%Name":"s_node_blend_edge",
"autoRecord":true,
"backdropHeight":768,
"backdropImageOpacity":0.5,
"backdropImagePath":"",
"backdropWidth":1366,
"backdropXOffset":0.0,
"backdropYOffset":0.0,
"events":{
"$KeyframeStore<MessageEventKeyframe>":"",
"Keyframes":[],
"resourceType":"KeyframeStore<MessageEventKeyframe>",
"resourceVersion":"2.0",
},
"eventStubScript":null,
"eventToFunction":{},
"length":1.0,
"lockOrigin":false,
"moments":{
"$KeyframeStore<MomentsEventKeyframe>":"",
"Keyframes":[],
"resourceType":"KeyframeStore<MomentsEventKeyframe>",
"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<SpriteFrameKeyframe>":"","Keyframes":[
{"$Keyframe<SpriteFrameKeyframe>":"","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<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","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,
}