pub struct FroxelGrid {
pub fx: u32,
pub fy: u32,
pub fz: u32,
pub far: f32,
pub cells: Vec<[f32; 4]>,
}Expand description
Das Foxel-Raster: Schichtgrenzen, Zell-Inhalte und die zwei
Operatoren Injektion und Marsch. Zellen-layout: x am schnellsten,
dann y, dann Schicht — identisch zur 2D-Array-Textur der GPU.
Fields§
§fx: u32§fy: u32§fz: u32§far: f32Linearer Sichttiefe-Radius der Scheibe — Schicht i läuft von
bound(i) bis bound(i+1); die Grenze ist Teil des Kerns,
nicht der Aufrufer, damit GPU und CPU dieselbe rechnen.
cells: Vec<[f32; 4]>Je Zelle RGBA: rgb = Streuung (In-Scatter), a = Extinktion σ.
Implementations§
Source§impl FroxelGrid
impl FroxelGrid
Sourcepub fn new(fx: u32, fy: u32, fz: u32, far: f32) -> Self
pub fn new(fx: u32, fy: u32, fz: u32, far: f32) -> Self
Raster mit fx·fy Zellen und fz quadratischen Schichten bis
far; alle Zellen beginnen leer (σ = 0, Streuung schwarz).
Sourcepub fn bound(&self, i: u32) -> f32
pub fn bound(&self, i: u32) -> f32
Schichtgrenze i (für i in 0..=fz): far · (i/fz)² —
dieselbe Klammer wie fog_bound in deferred.wgsl.
Sourcepub fn cell(&self, x: u32, y: u32, z: u32) -> [f32; 4]
pub fn cell(&self, x: u32, y: u32, z: u32) -> [f32; 4]
Zelle bei (x, y, Schicht) — x am schnellsten, dann y.
Sourcepub fn accumulate(&mut self, incoming: &FroxelGrid, alpha: f32)
pub fn accumulate(&mut self, incoming: &FroxelGrid, alpha: f32)
Temporaler Accumulator: faltet incoming mit Gewicht alpha in
sich (das bisherige Raster = Vergangenheit) hinein —
zelle ← zelle + (neu − zelle)·alpha, Zug für Zug die
Blend-Endung von cs_froxel in deferred.wgsl. alpha = 1
übernimmt hart (Reset), alpha = 0 hält das Alte. Gleiche
Achsen voraus.
Sourcepub fn accumulated(
prev: &FroxelGrid,
fresh: &FroxelGrid,
alpha: f32,
) -> FroxelGrid
pub fn accumulated( prev: &FroxelGrid, fresh: &FroxelGrid, alpha: f32, ) -> FroxelGrid
Reine Variante von Self::accumulate: die Mischung aus
prev und fresh als neues Raster (für Tore und Tests).
Sourcepub fn slice_of(&self, d: f32) -> u32
pub fn slice_of(&self, d: f32) -> u32
Schichtindex, der d enthält: die größte Schicht z mit
bound(z) < d (Grenzen selbst gehören eine Schicht tiefer —
dieselbe Konvention wie crate::cluster::ClusterGrid::slice_of).
Sourcepub fn sample(&self, gx: f32, gy: f32, gz: f32) -> [f32; 4]
pub fn sample(&self, gx: f32, gy: f32, gz: f32) -> [f32; 4]
Trilineare Abtastung in Raster-Texelkoordinaten (Zellmittelpunkte
bei +0.5), Rand klemmend — gespiegeltes fog_sample der GPU.
Sourcepub fn inject(
&mut self,
fog: &FogField,
lights: &[FogLight],
cam: &Camera,
sun_dir: V3,
)
pub fn inject( &mut self, fog: &FogField, lights: &[FogLight], cam: &Camera, sun_dir: V3, )
Füllt alle Zellen: Dichte aus dem Höhenfeld, Streuung aus
Ambient + Sonne + Lichtern (HG-Phase entlang der Kamerastrahl-
Richtung), Extinktion σ = dichte · extinction. Ohne Kegel —
dieselbe Spur wie inject_with_spots mit leerer Spot-Liste.
Sourcepub fn inject_with_spots(
&mut self,
fog: &FogField,
lights: &[FogLight],
spots: &[FogSpot],
cam: &Camera,
sun_dir: V3,
)
pub fn inject_with_spots( &mut self, fog: &FogField, lights: &[FogLight], spots: &[FogSpot], cam: &Camera, sun_dir: V3, )
Wie Self::inject, sammelt aber zusätzlich Kegel-Produzenten
(Lichtschächte) ein: Reichweiten-Abklingen wie die Lichter, mal
einer glatten Kegel-Blende um die Achse, mal HG-Phase — dieselbe
Spur wie Self::inject_with_clouds mit leerer Spot-Liste und
ohne Wolke.
Sourcepub fn inject_with_clouds(
&mut self,
fog: &FogField,
lights: &[FogLight],
spots: &[FogSpot],
cloud: Option<&CloudLayer>,
cam: &Camera,
sun_dir: V3,
)
pub fn inject_with_clouds( &mut self, fog: &FogField, lights: &[FogLight], spots: &[FogSpot], cloud: Option<&CloudLayer>, cam: &Camera, sun_dir: V3, )
Vollspur der Injektion: Nebelfeld, Punktlichter, Kegel-Produzenten
und optional ein Wolken-Produzent (crate::clouds::CloudLayer).
Die Wolke ergänzt pro Zelle eine eigene Dichte mit eigener
Vorwärtsphase und Multi-Scatter-Verstärkung; die Extinktion der
Zelle trägt beide Dichten — Marsch, Accumulator und march_fog
bleiben unverändert. Zug-für-Zug-Spiegelung: cs_froxel in
deferred.wgsl.
Sourcepub fn march(&self, ndc: (f32, f32), dist: f32) -> (V3, f32)
pub fn march(&self, ndc: (f32, f32), dist: f32) -> (V3, f32)
Marsch von der Kamera zur Sichttiefe dist entlang des
Pixelstrahls (ndc = NDC des Pixels): vorn nach hinten über
die geschnittenen Schichten, Zellwert trilinear an der
Segmentmitte. Liefert (In-Streuung, Transmittanz) — gespiegeltes
march_fog in fs_light. Die Raster-Geometrie steckt komplett
in Schichtgrenzen und NDC, die Kamera ist nicht nötig.
Trait Implementations§
Source§impl Clone for FroxelGrid
impl Clone for FroxelGrid
Source§fn clone(&self) -> FroxelGrid
fn clone(&self) -> FroxelGrid
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more