Skip to main content

bevy_material/
opaque.rs

1use bevy_reflect::{prelude::ReflectDefault, Reflect};
2
3/// Render method used for opaque materials.
4///
5/// The forward rendering main pass draws each mesh entity and shades it according to its
6/// corresponding material and the lights that affect it. Some render features like Screen Space
7/// Ambient Occlusion require running depth and normal prepasses, that are 'deferred'-like
8/// prepasses over all mesh entities to populate depth and normal textures. This means that when
9/// using render features that require running prepasses, multiple passes over all visible geometry
10/// are required. This can be slow if there is a lot of geometry that cannot be batched into few
11/// draws.
12///
13/// Deferred rendering runs a prepass to gather not only geometric information like depth and
14/// normals, but also all the material properties like base color, emissive color, reflectance,
15/// metalness, etc, and writes them into a deferred 'g-buffer' texture. The deferred main pass is
16/// then a fullscreen pass that reads data from these textures and executes shading. This allows
17/// for one pass over geometry, but is at the cost of not being able to use MSAA, and has heavier
18/// bandwidth usage which can be unsuitable for low end mobile or other bandwidth-constrained devices.
19///
20/// If a material indicates `OpaqueRendererMethod::Auto`, `DefaultOpaqueRendererMethod` will be used.
21#[derive(Default, Clone, Copy, Debug, PartialEq, Reflect)]
22#[reflect(Default, Clone, PartialEq)]
23pub enum OpaqueRendererMethod {
24    #[default]
25    Forward,
26    Deferred,
27    Auto,
28}