Volumetric fog: rays are marched over the depth difference, not the ray length — off-axis rays are too short
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- computer-graphics
Direzione di ricerca
Inizia da bevy_pbr/src/volumetric_fog/volumetric_fog.wesl e confronta come viene usato ray_length_view per il ray marching e il termine ambientale. Il rapporto propone la correzione per step_size_world e segnala che il termine ambientale presenta lo stesso problema tra profondità e lunghezza del raggio. Controlla il percorso di rendering della nebbia e i test pertinenti; il lavoro è completato quando i raggi fuori asse usano tutta la loro lunghezza e la trasmittanza varia sullo schermo come previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
A wide-angle camera inside a large uniform FogVolume, a white unlit wall 50 m in front of it,
perpendicular to the view axis. The fog only absorbs (light_intensity: 0.0, no ambient), so the
wall shows the fog's transmittance exp(-σ · ray length) directly:
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(),
Projection::Perspective(PerspectiveProjection { fov: 100f32.to_radians(), ..default() }),
Transform::default(),
VolumetricFog { ambient_intensity: 0.0, ..default() },
));
// The fog needs a volumetric light to be drawn at all; the fog itself ignores it (light_intensity 0).
commands.spawn((
DirectionalLight::default(),
VolumetricLight,
Transform::from_xyz(0.0, 1.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y),
));
// A white unlit wall 50 m in front of the camera, perpendicular to the view axis.
commands.spawn((
Mesh3d(meshes.add(Plane3d::new(Vec3::Z, Vec2::splat(500.0)))),
MeshMaterial3d(materials.add(StandardMaterial { base_color: Color::WHITE, unlit: true, ..default() })),
Transform::from_xyz(0.0, 0.0, -50.0),
));
// Uniform fog around the camera: absorption only, so the wall shows the transmittance exp(-σ·length).
commands.spawn((
FogVolume { density_factor: 0.02, light_intensity: 0.0, ..default() },
Transform::from_scale(Vec3::splat(400.0)),
));
}
What went wrong
- Expected: the wall gets darker towards the edges of the screen — the ray to the centre is 50 m
long, the ray to a corner of this frame about 130 m (50 / cos 68°). - Actual: the wall is one flat grey, as if every ray were 50 m long. Off-axis rays are shortened by
cos(angle to the view axis), so fog is always thinner at the sides of the screen than in the
middle. In our game (ultrawide, about 110° horizontally) this showed up as a bright blob in the
middle of the screen that followed the camera.
Left: the example above. Right: the same example with the one-line fix below.
Additional information
bevy_pbr/src/volumetric_fog/volumetric_fog.wesl:
let ray_length_view = max(0.0, end_depth_view - start_depth_view); // difference of view-space depths
...
let step_size_world = ray_length_view * inv_step_count;
...
let P_view = start_pos_view + Rd_view * f32(step) * step_size_world; // but steps go along the normalized ray
The length along the ray is (end_depth_view - start_depth_view) / -Rd_view.z. Suggested fix
(one line):
let step_size_world = ray_length_view * inv_step_count / max(-Rd_view.z, 1e-3);
The ambient term before the loop, exp(-ray_length_view * (absorption + scattering)), has the
same mistake.
- Lingua principale
- Rust
- Stelle
- 50k
- Fork
- 5.1k
- Merge medio
- 2g 20h
- PR unite (30g)
- 129
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di bevyengine/bevy
-
C-Bug S-Needs-Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
bevyengine/bevy#26718 ·
I maintainer di solito rispondono entro 2 giorni
-
Volumetric fog: a `FogVolume` with `Visibility::Hidden` is still renderedForse già presa @adityawrk l’ha presa 2 giorni fa. ApertaC-Bug S-Needs-Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
bevyengine/bevy#26688 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
bevyengine/bevy#26684 ·
I maintainer di solito rispondono entro 2 giorni
-
Create a bevy_fuzzy exampleForse già presa @Tatsuya0330 l’ha presa 1 giorno fa. ApertaA-UI C-Examples C-Feature D-Straightforward S-Needs-Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bevyengine/bevy#26676 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bevyengine/bevy#26649 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di bevyengine/bevy
Issue simili
-
area:ui effort:medium enhancement P7 source:agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
marketing
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
machine rename accepts a label already used by another machine, making --machine <label> ambiguousApertamaintainer-needed p2 remote triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
bug help wanted ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
userFRM/egui-charts#4605 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno