From 5ed5a427ceb3958f38443da7a5eca1da443f6fac Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sat, 27 Apr 2024 19:10:39 +0700 Subject: [PATCH] atlas artifact fix --- .../scripts/node_atlas/node_atlas.gml.backup0 | 4 +-- .../scripts/node_atlas/node_atlas.gml.backup1 | 4 +-- .../preferences/preferences.gml.backup0 | 2 +- .../preferences/preferences.gml.backup1 | 2 +- .../shaders/sh_atlas/sh_atlas.fsh.backup0 | 35 ++++++++++-------- .../shaders/sh_atlas/sh_atlas.fsh.backup1 | 36 +++++++++++-------- scripts/node_atlas/node_atlas.gml | 2 +- shaders/sh_atlas/sh_atlas.fsh | 33 ++++++++++------- 8 files changed, 70 insertions(+), 48 deletions(-) diff --git a/#backups/scripts/node_atlas/node_atlas.gml.backup0 b/#backups/scripts/node_atlas/node_atlas.gml.backup0 index 1c8415569..52dcb347f 100644 --- a/#backups/scripts/node_atlas/node_atlas.gml.backup0 +++ b/#backups/scripts/node_atlas/node_atlas.gml.backup0 @@ -1,4 +1,4 @@ -// 2024-04-18 08:44:11 +// 2024-04-27 18:41:22 function Node_Atlas(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { name = "Pixel Expand"; @@ -27,7 +27,7 @@ function Node_Atlas(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con if(_meth == 0) { var _bg = 0; - var _itr = ceil(max(_dim[0], _dim[1]) / 64); + var _itr = ceil(max(_dim[0], _dim[1]) / 16); surface_set_shader(temp_surface[!_bg]); draw_surface_safe(_surf); diff --git a/#backups/scripts/node_atlas/node_atlas.gml.backup1 b/#backups/scripts/node_atlas/node_atlas.gml.backup1 index 3c6937ff1..b208e1871 100644 --- a/#backups/scripts/node_atlas/node_atlas.gml.backup1 +++ b/#backups/scripts/node_atlas/node_atlas.gml.backup1 @@ -1,4 +1,4 @@ -// 2024-04-18 08:40:55 +// 2024-04-27 18:41:21 function Node_Atlas(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { name = "Pixel Expand"; @@ -27,7 +27,7 @@ function Node_Atlas(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con if(_meth == 0) { var _bg = 0; - var _itr = ceil(max(_dim[0], _dim[1]) / 64); + var _itr = ceil(max(_dim[0], _dim[1]) / 16); surface_set_shader(temp_surface[!_bg]); draw_surface_safe(_surf); diff --git a/#backups/scripts/preferences/preferences.gml.backup0 b/#backups/scripts/preferences/preferences.gml.backup0 index 5388aad8b..5186a0573 100644 --- a/#backups/scripts/preferences/preferences.gml.backup0 +++ b/#backups/scripts/preferences/preferences.gml.backup0 @@ -1,4 +1,4 @@ -// 2024-04-26 19:16:18 +// 2024-04-27 19:10:19 #region preference globalvar PREFERENCES, PREFERENCES_DEF, HOTKEYS_DATA; PREFERENCES = {}; diff --git a/#backups/scripts/preferences/preferences.gml.backup1 b/#backups/scripts/preferences/preferences.gml.backup1 index dc279a9a6..5388aad8b 100644 --- a/#backups/scripts/preferences/preferences.gml.backup1 +++ b/#backups/scripts/preferences/preferences.gml.backup1 @@ -1,4 +1,4 @@ -// 2024-04-26 19:16:04 +// 2024-04-26 19:16:18 #region preference globalvar PREFERENCES, PREFERENCES_DEF, HOTKEYS_DATA; PREFERENCES = {}; diff --git a/#backups/shaders/sh_atlas/sh_atlas.fsh.backup0 b/#backups/shaders/sh_atlas/sh_atlas.fsh.backup0 index f29005127..82cebf93d 100644 --- a/#backups/shaders/sh_atlas/sh_atlas.fsh.backup0 +++ b/#backups/shaders/sh_atlas/sh_atlas.fsh.backup0 @@ -1,39 +1,46 @@ -// 2024-04-27 16:30:10 +// 2024-04-27 18:43:20 varying vec2 v_vTexcoord; varying vec4 v_vColour; uniform vec2 dimension; #define TAU 6.283185307179586 -#define distance_sample 64. +#define distance_sample 32. void main() { vec2 tx = 1. / dimension; + vec2 px = v_vTexcoord * dimension; vec4 col = texture2D( gm_BaseTexture, v_vTexcoord ); gl_FragColor = col; if(col.a == 1.) return; + bool samp = false; + float angular_sample = distance_sample * TAU * 2.; + for(float i = 1.; i <= distance_sample; i++) { float base = 1.; float top = 0.; + float minDist = 9999.; - for(float j = 0.; j <= 128.; j++) { - float ang = top / base * TAU; - top += 2.; - if(top >= base) { - top = 1.; - base *= 2.; - } + for(float j = 0.; j <= angular_sample; j++) { + float ang = j / angular_sample * TAU; - vec2 pxs = v_vTexcoord + vec2( cos(ang), sin(ang)) * i * tx; - vec4 sam = texture2D( gm_BaseTexture, pxs ); - - if(sam.a < 1.) continue; + vec2 pxs = floor(px + vec2( cos(ang), sin(ang)) * i) + 0.5; + vec2 txs = pxs * tx; + vec4 sam = texture2D( gm_BaseTexture, txs ); + float dst = distance(px, pxs); + + if(sam.a < 1. || dst > minDist) continue; gl_FragColor = sam; - return; + // gl_FragColor = vec4(vec3(i / distance_sample), 1.); + minDist = dst; + + samp = true; } + + if(samp) return; } } diff --git a/#backups/shaders/sh_atlas/sh_atlas.fsh.backup1 b/#backups/shaders/sh_atlas/sh_atlas.fsh.backup1 index f734dd315..87d5a8446 100644 --- a/#backups/shaders/sh_atlas/sh_atlas.fsh.backup1 +++ b/#backups/shaders/sh_atlas/sh_atlas.fsh.backup1 @@ -1,38 +1,46 @@ -// 2024-04-18 08:42:38 +// 2024-04-27 18:43:14 varying vec2 v_vTexcoord; varying vec4 v_vColour; uniform vec2 dimension; #define TAU 6.283185307179586 +#define distance_sample 32. void main() { vec2 tx = 1. / dimension; + vec2 px = v_vTexcoord * dimension; vec4 col = texture2D( gm_BaseTexture, v_vTexcoord ); gl_FragColor = col; if(col.a == 1.) return; - for(float i = 1.; i <= 64.; i++) { + bool samp = false; + float angular_sample = distance_sample * TAU * 2.; + + for(float i = 1.; i <= distance_sample; i++) { float base = 1.; float top = 0.; + float minDist = 9999.; - for(float j = 0.; j <= 64.; j++) { - float ang = top / base * TAU; - top += 2.; - if(top >= base) { - top = 1.; - base *= 2.; - } + for(float j = 0.; j <= angular_sample; j++) { + float ang = j / angular_sample * TAU; - vec2 pxs = v_vTexcoord + vec2( cos(ang), sin(ang)) * i * tx; - vec4 sam = texture2D( gm_BaseTexture, pxs ); - - if(sam.a < 1.) continue; + vec2 pxs = floor(px + vec2( cos(ang), sin(ang)) * i) + 0.5; + vec2 txs = pxs * tx; + vec4 sam = texture2D( gm_BaseTexture, txs ); + float dst = distance(px, pxs); + + if(sam.a < 1. || dst > minDist) continue; gl_FragColor = sam; - return; + // gl_FragColor = vec4(vec3(i / distance_sample), 1.); + minDist = dst; + + samp = true; } + + if(samp) return; } } diff --git a/scripts/node_atlas/node_atlas.gml b/scripts/node_atlas/node_atlas.gml index c5a3ecccc..d98345801 100644 --- a/scripts/node_atlas/node_atlas.gml +++ b/scripts/node_atlas/node_atlas.gml @@ -26,7 +26,7 @@ function Node_Atlas(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con if(_meth == 0) { var _bg = 0; - var _itr = ceil(max(_dim[0], _dim[1]) / 64); + var _itr = ceil(max(_dim[0], _dim[1]) / 16); surface_set_shader(temp_surface[!_bg]); draw_surface_safe(_surf); diff --git a/shaders/sh_atlas/sh_atlas.fsh b/shaders/sh_atlas/sh_atlas.fsh index e134e765c..84d963b26 100644 --- a/shaders/sh_atlas/sh_atlas.fsh +++ b/shaders/sh_atlas/sh_atlas.fsh @@ -4,35 +4,42 @@ varying vec4 v_vColour; uniform vec2 dimension; #define TAU 6.283185307179586 -#define distance_sample 64. +#define distance_sample 32. void main() { vec2 tx = 1. / dimension; + vec2 px = v_vTexcoord * dimension; vec4 col = texture2D( gm_BaseTexture, v_vTexcoord ); gl_FragColor = col; if(col.a == 1.) return; + bool samp = false; + float angular_sample = distance_sample * TAU * 2.; + for(float i = 1.; i <= distance_sample; i++) { float base = 1.; float top = 0.; + float minDist = 9999.; - for(float j = 0.; j <= 128.; j++) { - float ang = top / base * TAU; - top += 2.; - if(top >= base) { - top = 1.; - base *= 2.; - } + for(float j = 0.; j <= angular_sample; j++) { + float ang = j / angular_sample * TAU; - vec2 pxs = v_vTexcoord + vec2( cos(ang), sin(ang)) * i * tx; - vec4 sam = texture2D( gm_BaseTexture, pxs ); - - if(sam.a < 1.) continue; + vec2 pxs = floor(px + vec2( cos(ang), sin(ang)) * i) + 0.5; + vec2 txs = pxs * tx; + vec4 sam = texture2D( gm_BaseTexture, txs ); + float dst = distance(px, pxs); + + if(sam.a < 1. || dst > minDist) continue; gl_FragColor = sam; - return; + // gl_FragColor = vec4(vec3(i / distance_sample), 1.); + minDist = dst; + + samp = true; } + + if(samp) return; } }