2D Meshes (2D网格)¶
简介¶
In 3D, meshes are used to display the world. In 2D, they are rare as images are used more often.
Godot's 2D engine is a pure two-dimensional engine, so it can't really display 3D meshes directly (although it can be done
via Viewport
and ViewportTexture
).
参见
如果你对在二维视区上显示三维网格感兴趣,请参见 使用视区作为纹理 教程。
2D meshes are meshes that contain two-dimensional geometry (Z can be omitted or ignored) instead of 3D.
You can experiment creating them yourself using SurfaceTool
from code and displaying them in a MeshInstance2D
node.
目前,在编辑器中生成二维网格的唯一方法,是导入一个OBJ文件作为网格,或者从Sprite转换而来。
优化绘制的像素¶
在某些情况下,这个工作流程对于优化二维绘图比较有用。当绘制具有透明度的大型图像时,Godot将把整个四方形(quad)绘制到屏幕上。大片的透明区域还是会被绘制。
如果绘制非常大的图像时(大概屏幕大小),或者将多个有大透明区域的图像叠加在一起(例如使用“视差背景”时), 这会影响性能,尤其是在移动设备上。
转换成网格能确保只绘制不透明部分,其余部分被忽略。