Skip to content

Camera.LayerMask has no effect on a camera that renders into its own FrameBuffer #240

Description

@SimonMeysman

Evergine 2026.5.26.921 · .NET 10 · Windows 11 · DX11 head (and WebGPU head where noted).
Desktop application: a 3D viewer for building models.

What happens

A Camera3D with its own FrameBuffer renders the entire scene into that target regardless of its layer
mask. We want it to draw exactly one render layer, so we can build a screen-space mask of selected objects.

What we expect

With LayerMaskDefaultValue = false and a single true entry, the camera draws only that layer — the way the
main camera does.

Evidence

A RenderDoc capture of one frame shows 652 colour draws and 782 depth draws into a target that should
receive one draw — model, ground grid and UI alike. Dumping the colour target confirms it: a complete render of
the scene.

At the moment of those draws the camera's state, logged from our own code, is exactly what it should be:

LayerMaskDefaultValue = False
LayerMask entries     = 9        (8 explicit false, 1 true for the layer we want)
requested layer key   = present, value = True

What we already ruled out

  • Not the key scheme. We use camera.LayerMask[layer.Id.GetHashCode()], and the main camera honours the
    same dictionary with the same keys — its exclusions work.
  • Not ordering. Tried setting the entry before and after entityManager.Add(...).
  • Not creation time. Tried building the camera during scene setup and lazily later; no difference.
  • Not a missed change notification. Tried re-asserting LayerMaskDefaultValue after attach, and writing the
    entry false then true to force a change.
  • Not reliance on the default. Tried naming every layer explicitly with false rather than depending on
    LayerMaskDefaultValue.
  • Camera.LayerBoolMask is null — but it is null on the main camera too, so that does not appear to be the
    consulted state.

Questions

  1. Is LayerMask supposed to apply to a camera with a FrameBuffer? If not, is that documented anywhere?
  2. If this is by design, what is the supported way to render a subset of the scene into a texture? A
    per-camera replacement/override material, a custom render step, or a second Scene rendered to a
    FrameBuffer — whichever is intended. A pointer to a sample would be ideal.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions