2D meshes

    See also

    If you are interested in displaying 3D meshes on a 2D viewport, see the tutorial.

    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 node.

    Currently, the only way to generate a 2D mesh within the editor is by either importing an OBJ file as a mesh, or converting it from a Sprite.

    This workflow is useful for optimizing 2D drawing in some situations. When drawing large images with transparency, Godot will draw the whole quad to the screen. The large transparent areas will still be drawn.

    Converting to a mesh will ensure that only the opaque parts will be drawn and the rest will be ignored.

    You can take advantage of this optimization by converting a Sprite to a . Start with an image that contains large amounts of transparency on the edges, like this tree:

    Put it in a Sprite and select “Convert to 2D Mesh” from the menu:

    ../../_images/mesh2d2.png

    The default values are good enough for many cases, but you can change growth and simplification according to your needs:

    ../../_images/mesh2d4.png

    Finally, push the Convert 2D Mesh button and your Sprite will be replaced: