bevy/crates/bevy_pbr/src
Jiří Švejda 510fce9af3
Allow fog density texture to be scrolled over time with an offset (#14868)
# Objective

- The goal of this PR is to make it possible to move the density texture
of a `FogVolume` over time in order to create dynamic effects like fog
moving in the wind.
- You could theoretically move the `FogVolume` itself, but this is not
ideal, because the `FogVolume` AABB would eventually leave the area. If
you want an area to remain foggy while also creating the impression that
the fog is moving in the wind, a scrolling density texture is a better
solution.

## Solution

- The PR adds a `density_texture_offset` field to the `FogVolume`
component. This offset is in the UVW coordinates of the density texture,
meaning that a value of `(0.5, 0.0, 0.0)` moves the 3d texture by half
along the x-axis.
- Values above 1.0 are wrapped, a 1.5 offset is the same as a 0.5
offset. This makes it so that the density texture wraps around on the
other side, meaning that a repeating 3d noise texture can seamlessly
scroll forever. It also makes it easy to move the density texture over
time by simply increasing the offset every frame.

## Testing

- A `scrolling_fog` example has been added to demonstrate the feature.
It uses the offset to scroll a repeating 3d noise density texture to
create the impression of fog moving in the wind.
- The camera is looking at a pillar with the sun peaking behind it. This
highlights the effect the changing density has on the volumetric
lighting interactions.
- Temporal anti-aliasing combined with the `jitter` option of
`VolumetricFogSettings` is used to improve the quality of the effect.

---

## Showcase


https://github.com/user-attachments/assets/3aa50ebd-771c-4c99-ab5d-255c0c3be1a8
2024-08-22 19:43:14 +00:00
..
cluster Glam 0.28 update - adopted (#14613) 2024-08-06 01:28:00 +00:00
deferred Add support for environment map transformation (#14290) 2024-07-19 15:00:50 +00:00
light Lighting Should Only hold Vec<Entity> instead of TypeId<Vec<Entity>> (#14073) 2024-07-14 17:00:54 +00:00
light_probe Add support for environment map transformation (#14290) 2024-07-19 15:00:50 +00:00
lightmap Pack multiple vertex and index arrays together into growable buffers. (#14257) 2024-07-16 20:33:15 +00:00
meshlet Changed Mesh::attributes* functions to return MeshVertexAttribute (#14394) 2024-08-12 15:54:28 +00:00
prepass Fix the example regressions from packed growable buffers. (#14375) 2024-07-22 18:55:51 +00:00
render Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
ssao Move Msaa to component (#14273) 2024-07-22 18:28:23 +00:00
ssr Add support for environment map transformation (#14290) 2024-07-19 15:00:50 +00:00
volumetric_fog Allow fog density texture to be scrolled over time with an offset (#14868) 2024-08-22 19:43:14 +00:00
bundle.rs Lighting Should Only hold Vec<Entity> instead of TypeId<Vec<Entity>> (#14073) 2024-07-14 17:00:54 +00:00
extended_material.rs impl Debug for ExtendedMaterial (#14140) 2024-07-04 23:59:48 +00:00
fog.rs Fix lints introduced in Rust beta 1.80 (#13899) 2024-06-17 17:22:01 +00:00
lib.rs Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
material.rs check sampler type in as_bind_group derives (#12637) 2024-08-21 01:41:31 +00:00
parallax.rs bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
pbr_material.rs Fix intra-doc links and make CI test them (#14076) 2024-07-11 13:08:31 +00:00
wireframe.rs Use WireframeColor to override global color (#13034) 2024-04-20 13:59:12 +00:00