sprite - Godot - 我可以像素化一个节点(Sprite)吗?
解决方案
我自己想通了,确实很容易。我只需要一个着色器:
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
看起来就像图像示例中的样子。
PS它不适用于GUI节点,也许我会解决这个问题。
推荐阅读
- python - 变分自编码器的潜在维度分析:为什么使用 z_mean 而不是 z?
- python-3.x - 如何将colab中的音频文件转换为文本?
- php - 检查是否可以使用 laravel 识别路线
- gcc - gcc 10.3.1.1.fc32 构建失败并显示“gcc:致命错误:'-fuse-linker-plugin',但未找到 liblto_plugin.so”
- javascript - 即使使用 preventDefault 也检测 onmouseup/onmousemove
- onflow-cadence - (Cadence) 尝试部署到 Flow 测试网时出现“部署包含不存在的合约”错误
- html - 如何使用 React 和 Material UI 制作响应式内容?
- python - 无法让 solve_ivp 使用 2ODE 并在方程中使用不同的变量
- javascript - 断断续续的过渡:同时转换多个路径(和 xaxis)
- xml - 将多个 MarkLogic 查询与 cts:search 组合