Volumetric fog: light inside a FogVolume is attenuated over the whole volume's bounding radius, so large volumes get almost no light

Aperta
#26,669 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Start with bevy_pbr/src/volumetric_fog/volumetric_fog.wesl and trace how render.rs computes bounding_radius. Compare the directional, point, and spot light attenuation paths, then inspect the relevant volumetric fog tests or examples. Done means light attenuation reflects the path through the volume toward each light and large sparse volumes no longer lose nearly all direct light.

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

Descrizione

C-Bug S-Needs-Triage

Bevy version and features

  • 0.20.1
  • Default features; the camera has VolumetricFog, the sun is a DirectionalLight with
    shadows and VolumetricLight.

[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

Ground fog over a large open area: one FogVolume around the camera, scaled to a box of
2400 m × 300 m × 2400 m, with a 3D density texture that is mostly empty above the ground
layer.

What went wrong

  • Expected: thin fog lit by the sun, brighter where it is thin.
  • Actual: the fog gets almost no direct light and looks dark. Making the volume bigger makes it
    darker, even when the fog itself (density × thickness) does not change.

Additional information

bevy_pbr/src/volumetric_fog/volumetric_fog.wesl, directional lights (and the same line in the
point/spot light loop):

let light_attenuation = exp(-density * bounding_radius * (absorption + scattering));

bounding_radius is the radius of the sphere around the whole volume (render.rs:
view_from_local.transform_vector3a(Vec3A::splat(0.5)).length()). So every sample is
attenuated as if the light travelled through a full bounding radius of fog at the local
density, no matter where the sample is or how much fog really lies toward the light. For the
2400 × 300 × 2400 m box bounding_radius is ~1.7 km. With density = 0.05,
scattering = 0.35, absorption = 0: exp(-0.05 * 1704 * 0.35) = exp(-30) ≈ 0, so the volume
receives no direct light at all. A small volume with the same density looks fine.

Expected behavior: attenuate over the path from the sample to where the light enters the
volume (distance to the volume boundary along L, from a ray-box intersection in the volume's
local space), or march toward the light through the density texture. For point and spot lights,
over the distance to the light inside the volume.

Workaround we use (a hack, for our case only): replace bounding_radius in that line with a
fixed path length (the thickness of our fog layer), plus a precomputed "sun visibility" channel
in our density texture.

Tested on one machine.

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.