2D meshes

Introduction

Viewport and ViewportTexture). See also Using a Viewport as a texture tutorial. SurfaceTool from code and displaying them in a MeshInstance2D 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.

Optimizing pixels drawn

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. ParallaxBackground). Converting to a mesh will ensure that only the opaque parts will be drawn and the rest will be ignored.

Converting Sprites to 2D meshes

Sprite to a MeshInstance2D. Start with an image that contains large amounts of transparency on the edges, like this tree: Sprite and select “Convert to 2D Mesh” from the menu: A dialog will appear, showing a preview of how the 2D mesh will be created: The default values are good enough for many cases, but you can change growth and simplification according to your needs: Convert 2D Mesh button and your Sprite will be replaced: