Skip to main content

FroxelGrid

Struct FroxelGrid 

Source
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: f32

Linearer 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

Source

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).

Source

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.

Source

pub fn cell(&self, x: u32, y: u32, z: u32) -> [f32; 4]

Zelle bei (x, y, Schicht) — x am schnellsten, dann y.

Source

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.

Source

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).

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> FroxelGrid

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FroxelGrid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.