pub struct VolumetricFog {
pub density_field: FogDensityField,
pub scattering: f32,
pub absorption: f32,
pub fog_color: Color,
pub hg_asymmetry: f32,
pub step_count: u32,
pub max_distance: f32,
pub enabled: bool,
pub ambient_contribution: f32,
pub jitter_offset: f32,
}Expand description
Volumetric fog with ray marching, scattering, absorption, and the Henyey-Greenstein phase function.
Fields§
§density_field: FogDensityFieldFog density field.
scattering: f32Scattering coefficient (how much light is scattered per unit distance).
absorption: f32Absorption coefficient (how much light is absorbed per unit distance).
fog_color: ColorFog color.
hg_asymmetry: f32Henyey-Greenstein asymmetry parameter (-1 = back scatter, 0 = isotropic, 1 = forward).
step_count: u32Number of ray marching steps.
max_distance: f32Maximum ray marching distance.
enabled: boolWhether fog is enabled.
ambient_contribution: f32Ambient fog contribution (light scattered from the environment).
jitter_offset: f32Temporal reprojection jitter offset (for temporal anti-aliasing of fog).
Implementations§
Source§impl VolumetricFog
impl VolumetricFog
pub fn new(density_field: FogDensityField) -> Self
Sourcepub fn henyey_greenstein(cos_theta: f32, g: f32) -> f32
pub fn henyey_greenstein(cos_theta: f32, g: f32) -> f32
Henyey-Greenstein phase function.
Evaluates the probability of light scattering at angle cos_theta.
Sourcepub fn ray_march(
&self,
ray_origin: Vec3,
ray_dir: Vec3,
max_dist: f32,
light_dir: Vec3,
light_color: Color,
light_intensity: f32,
) -> (Color, f32)
pub fn ray_march( &self, ray_origin: Vec3, ray_dir: Vec3, max_dist: f32, light_dir: Vec3, light_color: Color, light_intensity: f32, ) -> (Color, f32)
Ray march through the fog volume from a camera ray. Returns (accumulated fog color, transmittance).
Sourcepub fn ray_march_multi_light(
&self,
ray_origin: Vec3,
ray_dir: Vec3,
max_dist: f32,
lights: &[(Vec3, Color, f32)],
) -> (Color, f32)
pub fn ray_march_multi_light( &self, ray_origin: Vec3, ray_dir: Vec3, max_dist: f32, lights: &[(Vec3, Color, f32)], ) -> (Color, f32)
Ray march with multiple light contributions.
Sourcepub fn apply_to_pixel(
&self,
scene_color: Color,
fog_color: Color,
transmittance: f32,
) -> Color
pub fn apply_to_pixel( &self, scene_color: Color, fog_color: Color, transmittance: f32, ) -> Color
Apply fog to a final pixel color given scene depth.
Trait Implementations§
Source§impl Clone for VolumetricFog
impl Clone for VolumetricFog
Source§impl Debug for VolumetricFog
impl Debug for VolumetricFog
Auto Trait Implementations§
impl Freeze for VolumetricFog
impl RefUnwindSafe for VolumetricFog
impl Send for VolumetricFog
impl Sync for VolumetricFog
impl Unpin for VolumetricFog
impl UnsafeUnpin for VolumetricFog
impl UnwindSafe for VolumetricFog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.