Volumetric fog: a `FogVolume` with `Visibility::Hidden` is still rendered

Aperta Adatta ai principianti
#26,688 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@adityawrk ci sta già lavorando.

Dal 28/11/2026.

  • #26695 di @adityawrk — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
game-dev

Direzione di ricerca

Inizia da bevy_pbr/src/volumetric_fog/render.rs e leggi extract_volumetric_fog, che, secondo quanto indicato dall’issue, estrae ogni FogVolume senza controllarne la visibilità. Esamina come viene gestita la visibilità dei componenti estratti nel render-world e come vengono ripuliti i volumi di nebbia rimossi. Il lavoro è completato quando un volume nascosto smette di contribuire alla nebbia, le modifiche alla visibilità hanno effetto durante l’esecuzione e i test esistenti sulla nebbia volumetrica o una riproduzione mirata confermano il comportamento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

C-Bug S-Needs-Triage

Bevy version and features

  • 0.20.1 (the code is the same on main)
  • Features: default + dlss

[Optional] Relevant system information

  • cargo 1.99.1 (5f94df478 2026-08-27)
  • Windows 11
AdapterInfo { name: "NVIDIA GeForce RTX 5080", vendor: 4318, device: 11266, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "616.92", backend: Vulkan }

What you did

use bevy::light::{FogVolume, VolumetricFog, VolumetricLight};
use bevy::prelude::*;

fn main() {
    App::new().add_plugins(DefaultPlugins).add_systems(Startup, setup).run();
}

fn setup(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<StandardMaterial>>) {
    commands.spawn((
        Camera3d::default(),
        Transform::from_xyz(0.0, 3.0, 12.0).looking_at(Vec3::ZERO, Vec3::Y),
        VolumetricFog { ambient_intensity: 0.0, ..default() },
    ));
    commands.spawn((
        DirectionalLight { shadow_maps_enabled: true, illuminance: 32000.0, ..default() },
        VolumetricLight,
        Transform::from_xyz(1.0, 2.0, -1.0).looking_at(Vec3::ZERO, Vec3::Y),
    ));
    commands.spawn((
        Mesh3d(meshes.add(Plane3d::default().mesh().size(30.0, 30.0))),
        MeshMaterial3d(materials.add(Color::srgb(0.2, 0.2, 0.2))),
    ));
    commands.spawn((
        Mesh3d(meshes.add(Cuboid::new(1.0, 2.0, 1.0))),
        MeshMaterial3d(materials.add(Color::srgb(0.8, 0.3, 0.2))),
        Transform::from_xyz(0.0, 1.0, 0.0),
    ));
    // Hidden — but the fog is still drawn.
    commands.spawn((FogVolume::default(), Transform::from_scale(Vec3::splat(10.0)), Visibility::Hidden));
}

What went wrong

  • Expected: no fog — the volume is hidden.
  • Actual: the fog is drawn as if the volume were visible. Toggling Visibility at runtime changes
    nothing either. (In our game a hidden volume stayed where the camera had been and kept glowing
    all night.)

Left: the example above (Visibility::Hidden). Right: the same volume with density_factor = 0.0
— what a hidden volume should look like.

fog_5

Additional information

bevy_pbr/src/volumetric_fog/render.rs, extract_volumetric_fog extracts every FogVolume
and never looks at visibility:

fog_volumes: Extract<Query<(RenderEntity, &FogVolume, &GlobalTransform)>>,

FogVolume requires Visibility, so hiding it is expected to work. Suggested fix: add
&ViewVisibility (or &InheritedVisibility) to the query, and for a hidden volume remove its
FogVolume from the render world (or skip it in prepare_volumetric_fog_uniforms), the same way
as when the component is removed.

Workaround: set density_factor = 0.0 while the volume is hidden, or remove the FogVolume
component.

Lingua principale
Rust
Stelle
50k
Fork
5.1k
Merge medio
2g 20h
PR unite (30g)
129

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bevyengine/bevy

Tutte le issue di bevyengine/bevy

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.