Skip to content

Clarify that a Camera without RenderLayers only renders RenderLayers::layer(0) #18874

Open
@FrTerstappen

Description

@FrTerstappen

How can Bevy's documentation be improved?

The documentation of RenderLayers in

/// Describes which rendering layers an entity belongs to.
///
/// Cameras with this component will only render entities with intersecting
/// layers.
///
/// Entities may belong to one or more layers, or no layer at all.
///
/// The [`Default`] instance of `RenderLayers` contains layer `0`, the first layer.
///
/// An entity with this component without any layers is invisible.
///
/// Entities without this component belong to layer `0`.
contains the following part:

/// Cameras with this component will only render entities with intersecting
/// layers.

This lead me to assume that a camera without this component renders entities without regard to the layer they belong to. This does not work as a camera without RenderLayers only renders entities belonging to RenderLayers::layer(0).

This can be seen in

let view_mask = maybe_view_mask.unwrap_or_default();
where a missing RenderLayers is replaced with the default.

While it could be argued that the line

/// Entities without this component belong to layer `0`. 

also applies to the camera this was not clear to me.

I propose expanding the camera related section of the docs to something like this:

/// Cameras with this component will only render entities with intersecting
/// layers.
/// Cameras without this component will only render entities belonging to the default render layer (RenderLayers::layer(0)).

A further improvement would be to describe how to create a camera that renders all layers (if that is even possible).
I currently create a RenderLayers component containing all layers I use.
This feels like a workaround and is error prone because I have to remember to add new layers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-DocsAn addition or correction to our documentationD-TrivialNice and easy! A great choice to get started with BevyS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions