diff --git a/fonts/_f_sdf/_f_sdf.old.png b/fonts/_f_sdf/_f_sdf.old.png index 74ea514e4..2ed780195 100644 Binary files a/fonts/_f_sdf/_f_sdf.old.png and b/fonts/_f_sdf/_f_sdf.old.png differ diff --git a/fonts/_f_sdf/_f_sdf.png b/fonts/_f_sdf/_f_sdf.png index 2ed780195..66d7fa234 100644 Binary files a/fonts/_f_sdf/_f_sdf.png and b/fonts/_f_sdf/_f_sdf.png differ diff --git a/fonts/_f_sdf_medium/_f_sdf_medium.old.png b/fonts/_f_sdf_medium/_f_sdf_medium.old.png index e46af3dc9..9a87707f5 100644 Binary files a/fonts/_f_sdf_medium/_f_sdf_medium.old.png and b/fonts/_f_sdf_medium/_f_sdf_medium.old.png differ diff --git a/fonts/_f_sdf_medium/_f_sdf_medium.png b/fonts/_f_sdf_medium/_f_sdf_medium.png index 9a87707f5..e8a232f27 100644 Binary files a/fonts/_f_sdf_medium/_f_sdf_medium.png and b/fonts/_f_sdf_medium/_f_sdf_medium.png differ diff --git a/scripts/node_blur_contrast/node_blur_contrast.gml b/scripts/node_blur_contrast/node_blur_contrast.gml index 9a3639142..64e3926aa 100644 --- a/scripts/node_blur_contrast/node_blur_contrast.gml +++ b/scripts/node_blur_contrast/node_blur_contrast.gml @@ -47,25 +47,14 @@ function Node_Blur_Contrast(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var ww = surface_get_width_safe(_surf); var hh = surface_get_height_safe(_surf); - temp_surface[0] = surface_verify(temp_surface[0], ww, hh, attrDepth()); - - surface_set_shader(temp_surface[0], sh_blur_box_contrast); - shader_set_surface("baseSurface", _surf); + surface_set_shader(_outSurf, sh_blur_box_contrast); shader_set_f("dimension", [ ww, hh ]); - shader_set_f("size", _size); - shader_set_f("treshold", _tres); - shader_set_i("direction", 0); + shader_set_f("size", _size); + shader_set_f("treshold", _tres); draw_surface_safe(_surf, 0, 0); surface_reset_shader(); - surface_set_shader(_outSurf, sh_blur_box_contrast); - shader_set(sh_blur_box_contrast); - shader_set_i("direction", 1); - - draw_surface_safe(temp_surface[0], 0, 0); - surface_reset_shader(); - __process_mask_modifier(_data); _outSurf = mask_apply(_data[0], _outSurf, _mask, _mix); _outSurf = channel_apply(_data[0], _outSurf, _data[6]); diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index 48927175e..3b6b49dc7 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -512,7 +512,7 @@ function __initNodes() { addNodeObject(filter, "Displace", s_node_displace, "Node_Displace", [1, Node_Displace], ["distort"], "Distort image using another image as a map."); addNodeObject(filter, "Texture Remap", s_node_texture_map, "Node_Texture_Remap", [1, Node_Texture_Remap],, "Remap image using texture map. Where red channel control x position and green channel control y position."); addNodeObject(filter, "Time Remap", s_node_time_map, "Node_Time_Remap", [1, Node_Time_Remap],, "Remap image using texture as time map. Where brighter pixel means using pixel from an older frame."); - addNodeObject(filter, "Morph Surface", s_node_morph_surface, "Node_Morph_Surface", [1, Node_Morph_Surface],, "Morph pixel bewteen two surfaces.").setVersion(1141); + addNodeObject(filter, "Morph Surface", s_node_morph_surface, "Node_Morph_Surface", [1, Node_Morph_Surface],, "Morph pixel between two surfaces.").setVersion(1141); ds_list_add(filter, "Effects"); addNodeObject(filter, "Outline", s_node_border, "Node_Outline", [1, Node_Outline], ["border"], "Add border to the image."); diff --git a/shaders/sh_blur_box_contrast/sh_blur_box_contrast.fsh b/shaders/sh_blur_box_contrast/sh_blur_box_contrast.fsh index cb42a955c..cc20b33c8 100644 --- a/shaders/sh_blur_box_contrast/sh_blur_box_contrast.fsh +++ b/shaders/sh_blur_box_contrast/sh_blur_box_contrast.fsh @@ -1,16 +1,15 @@ -// -// Simple passthrough fragment shader -// varying vec2 v_vTexcoord; varying vec4 v_vColour; -uniform sampler2D baseSurface; +#define TAU 6.283185307179586 +#define MAX_STRENGTH 64. + uniform vec2 dimension; uniform float size; uniform float treshold; uniform int direction; -vec3 rgb2xyz( vec3 c ) { +vec3 rgb2xyz( vec3 c ) { #region vec3 tmp; tmp.x = ( c.r > 0.04045 ) ? pow( ( c.r + 0.055 ) / 1.055, 2.4 ) : c.r / 12.92; tmp.y = ( c.g > 0.04045 ) ? pow( ( c.g + 0.055 ) / 1.055, 2.4 ) : c.g / 12.92, @@ -19,83 +18,47 @@ vec3 rgb2xyz( vec3 c ) { mat3( 0.4124, 0.3576, 0.1805, 0.2126, 0.7152, 0.0722, 0.0193, 0.1192, 0.9505 ); -} +} #endregion -vec3 xyz2lab( vec3 c ) { +vec3 xyz2lab( vec3 c ) { #region vec3 n = c / vec3( 95.047, 100, 108.883 ); vec3 v; v.x = ( n.x > 0.008856 ) ? pow( n.x, 1.0 / 3.0 ) : ( 7.787 * n.x ) + ( 16.0 / 116.0 ); v.y = ( n.y > 0.008856 ) ? pow( n.y, 1.0 / 3.0 ) : ( 7.787 * n.y ) + ( 16.0 / 116.0 ); v.z = ( n.z > 0.008856 ) ? pow( n.z, 1.0 / 3.0 ) : ( 7.787 * n.z ) + ( 16.0 / 116.0 ); return vec3(( 116.0 * v.y ) - 16.0, 500.0 * ( v.x - v.y ), 200.0 * ( v.y - v.z )); -} +} #endregion -vec3 rgb2lab(vec3 c) { +vec3 rgb2lab(vec3 c) { #region vec3 lab = xyz2lab( rgb2xyz( c ) ); return vec3( lab.x / 100.0, 0.5 + 0.5 * ( lab.y / 127.0 ), 0.5 + 0.5 * ( lab.z / 127.0 )); -} +} #endregion -float colorDifferent(in vec4 c1, in vec4 c2) { - vec3 lab1 = rgb2lab(c1.rgb * c1.a); - vec3 lab2 = rgb2lab(c2.rgb * c2.a); - - return length(lab1 - lab2); -} +float colorDifferent(in vec4 c1, in vec4 c2) { #region + return length(c1.rgb - c2.rgb) / 1.7320508076; +} #endregion void main() { - vec4 base_col = texture2D( baseSurface, v_vTexcoord); - vec4 curr_col = texture2D( gm_BaseTexture, v_vTexcoord); + vec2 tx = 1. / dimension; + vec4 col = texture2D( gm_BaseTexture, v_vTexcoord); + vec4 c = col; + float div = 1.; + float sz2 = size * size; - if(base_col.a > 0.5) { - vec4 col = curr_col; - vec4 _bcol, _ccol; - float mulp = 1.; - - if(direction == 0) { - for(float i = 1.; i < 32.; i++) { - if(i >= size) break; - - _bcol = texture2D( baseSurface, v_vTexcoord + vec2(i / dimension.x, 0.)); - if(_bcol.a > 0.5 && colorDifferent(base_col, _bcol) < treshold) { - _ccol = texture2D( gm_BaseTexture, v_vTexcoord + vec2(i / dimension.x, 0.)); - col += _ccol; - mulp++; - } - - _bcol = texture2D( baseSurface, v_vTexcoord - vec2(i / dimension.x, 0.)); - if(_bcol.a > 0.5 && colorDifferent(base_col, _bcol) < treshold) { - _ccol = texture2D( gm_BaseTexture, v_vTexcoord - vec2(i / dimension.x, 0.)); - col += _ccol; - mulp++; - } - } + for(float i = -MAX_STRENGTH; i <= MAX_STRENGTH; i++) + for(float j = -MAX_STRENGTH; j <= MAX_STRENGTH; j++) { + float dist = i * i + j * j; + if(dist >= sz2) continue; - col /= mulp; - } else if(direction == 1) { - for(float i = 1.; i < 32.; i++) { - if(i >= size) break; - - _bcol = texture2D( baseSurface, v_vTexcoord + vec2(0., i / dimension.y)); - if(_bcol.a > 0.5 && colorDifferent(base_col, _bcol) < treshold) { - _ccol = texture2D( gm_BaseTexture, v_vTexcoord + vec2(0., i / dimension.y)); - col += _ccol; - mulp++; - } - - _bcol = texture2D( baseSurface, v_vTexcoord - vec2(0., i / dimension.y)); - if(_bcol.a > 0.5 && colorDifferent(base_col, _bcol) < treshold) { - _ccol = texture2D( gm_BaseTexture, v_vTexcoord - vec2(0., i / dimension.y)); - col += _ccol; - mulp++; - } - } - - col /= mulp; + float amp = 1. - dist / sz2; + vec2 pxs = v_vTexcoord + vec2( i, j ) * tx; + vec4 bcol = texture2D( gm_BaseTexture, pxs); + + if(c.a == bcol.a && colorDifferent(c, bcol) <= treshold) { + col += bcol * amp; + div += amp; } - - col.a = base_col.a; - gl_FragColor = col; - } else { - gl_FragColor = base_col; } + + gl_FragColor = col / div; } diff --git a/shaders/sh_outline/sh_outline.fsh b/shaders/sh_outline/sh_outline.fsh index b4534d104..63c298dcd 100644 --- a/shaders/sh_outline/sh_outline.fsh +++ b/shaders/sh_outline/sh_outline.fsh @@ -1,9 +1,8 @@ -// -// Simple passthrough fragment shader -// varying vec2 v_vTexcoord; varying vec4 v_vColour; +#define TAU 6.283185307179586 + uniform vec2 dimension; uniform vec2 borderStart; @@ -27,8 +26,6 @@ uniform sampler2D blend_alphaSurf; uniform int sampleMode; uniform int outline_only; -#define TAU 6.283185307179586 - vec2 round(in vec2 v) { #region v.x = fract(v.x) > 0.5? ceil(v.x) : floor(v.x); v.y = fract(v.y) > 0.5? ceil(v.y) : floor(v.y);