Open-Source Wikis

/

Bevy

/

Packages

/

bevy_sprite_render

bevyengine/bevy

bevy_sprite_render

The 2D sprite renderer. Reads Sprite components from bevy_sprite, batches them per material/texture, and draws into the standard 2D phases.

Purpose

The renderer half of bevy_sprite. Provides:

  • The default ColorMaterial for solid + textured sprites.
  • The 2D mesh draw path for Mesh2d entities.
  • Sprite batching, atlas extraction, and the Material2d plugin glue.
  • The 2D-specific render-phase items.

Directory layout

crates/bevy_sprite_render/src/
├── lib.rs             # SpriteRenderPlugin
├── render/            # Sprite batching + draw functions
├── mesh2d/            # Mesh2d (a 2D version of the PBR mesh path, simpler shading)
├── tilemap_chunk/     # Tilemap chunk renderer
├── texture_slice/     # Slice/tile renderer
├── color_material.rs
└── …

Key abstractions

Type File Description
SpriteRenderPlugin crates/bevy_sprite_render/src/lib.rs Adds the 2D pipeline pieces.
ColorMaterial crates/bevy_sprite_render/src/color_material.rs Default Material2d.
Material2d crates/bevy_sprite_render/src/mesh2d/ Trait — 2D analogue of Material.
Mesh2d crates/bevy_sprite_render/src/mesh2d/mesh.rs Component pairing entity with a 2D mesh.
MeshMaterial2d<M> crates/bevy_sprite_render/src/mesh2d/material.rs Material binding component.

How it works

Sprites are extracted into the render world with their image handle, color, transform, and atlas data. A batching system groups consecutive sprites by texture and material into draw calls, building a quad index buffer per batch. Mesh2d entities go through a path mirroring the 3D mesh-render system but simpler (no skinning, simpler lighting).

Integration points

  • Depends on: bevy_render, bevy_core_pipeline, bevy_camera, bevy_sprite, bevy_material, bevy_color, bevy_image, bevy_mesh.
  • Depended on by: bevy_internal (in default plugins).

Entry points for modification

  • Custom 2D material: implement Material2d and register Material2dPlugin::<M>. Examples in examples/2d/.
  • Sprite batching: render/mod.rs.
  • Tilemap chunks: tilemap_chunk/.

See also

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

bevy_sprite_render – Bevy wiki | Factory