【发布时间】:2021-03-05 07:39:57
【问题描述】:
【问题讨论】:
【问题讨论】:
我自己想通了,确实很容易。我只需要一个着色器:
shader_type canvas_item;
uniform float size_x = 32.0; // blocks by x direction
uniform float size_y = 32.0; // blocks by y direction
void fragment() {
COLOR = texture(TEXTURE, vec2(floor(UV.x * size_x) / (size_x - 1.0), floor(UV.y * size_y) / (size_y - 1.0)));
}
fragment 函数内部将UV 向上缩放,使用floor 向下舍入,然后将结果向下缩放。上面的图像(在问题中)被像素化为 32x32 大小,使用此着色器后,Sprite 看起来就像在图像示例中一样。
P.S.它不适用于GUI节点,也许我会解决这个问题。
【讨论】: