atlas artifact fix

This commit is contained in:
Tanasart 2024-04-27 19:10:39 +07:00
parent b2953cfb7c
commit 5ed5a427ce
8 changed files with 70 additions and 48 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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