求助,图像缩放问题
love2d吧
全部回复
仅看楼主
level 9
使用love.graphics.draw(img, x, y, 0, .1, .1)绘制的图像会出现锯齿,怎么样才能够避免这种现象,如图,上面是直接绘制的结果,下面是使用软件修改后的图像,上面的图像出现了了锯齿
2021年08月13日 14点08分 1
level 9
自己写了一个shader,问题解决了
extern float scale_w;
extern float scale_h;
extern int img_w;
extern int img_h;
#ifdef VERTEX
vec4 position( mat4 transform_projection, vec4 vertex_position ) {
return transform_projection*vertex_position;
}
#endif
#ifdef PIXEL
vec4 effect( vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords ) {
int count_w = int (1.0 / scale_w + 0.5);
int count_h = int (1.0 / scale_h + 0.5);
int count = 1;
vec4 color_sum = vec4(0, 0, 0, 0);
vec2 pos_per;
vec4 color_per;
for (int i = 1; i <= count_w; i++) {
for (int k = 1; k <= count_h; k++) {
pos_per = vec2((texture_coords.x * img_w + i-(count_w / 2)) / img_w, (texture_coords.y * img_h + k - (count_h / 2)) / img_h);
color_per = Texel(tex, pos_per);
if (color_per.a != 0) {
color_sum += color_per;
count++;
}
}
}
vec4 color_avg = color_sum / count;
if (count_w != 20) {
return vec4(2,2,2,2);
}else{
return color_avg;
}
}
#endif
2021年08月15日 09点08分 2
level 9
不过,怎么样才能不使用extern,获得图像的尺寸信息呢
2021年08月15日 09点08分 3
level 3
两点兄还有继续使用love2d开发吗?有没有出成品?
我看你从19年到22年都有在用love2d做开发,很厉害啊![真棒]
2024年04月16日 17点04分 4
已经是一枚标准的社畜了,没在搞这些了
2024年04月26日 04点04分
@两点之间℃ 祝你工作顺利
2024年04月26日 10点04分
1