bevy/crates
Máté Homolya a616ffa8ac
Web support for atmosphere (#18582)
# Objective

Add web support to atmosphere by gating dual source blending and using a
macro to determine the target platform.
The main objective of this PR is to ensure that users of Bevy's
atmosphere feature can also run it in a web-based context where WebGPU
support is enabled.

## Solution

- Make use of the `#[cfg(not(target_arch = "wasm32"))]` macro to gate
the dual source blending, as this is not (yet) supported in web
browsers.
- Rename the function `sample_sun_illuminance` to `sample_sun_radiance`
and move calls out of conditionals to ensure the shader compiles and
runs in both native and web-based contexts.
- Moved the multiplication of the transmittance out when calculating the
sun color, because calling the `sample_sun_illuminance` function was
causing issues in web. Overall this results in cleaner code and more
readable.

## Testing

- Tested by building a wasm target and loading it in a web page with
Vite dev server using `mate-h/bevy-webgpu` repo template.
- Tested the native build with `cargo run --example atmosphere` to
ensure it still works with dual source blending.

---

## Showcase

Screenshots show the atmosphere example running in two different
contexts:

<img width="1281" alt="atmosphere-web-showcase"
src="https://github.com/user-attachments/assets/40b1ee91-89ae-41a6-8189-89630d1ca1a6"
/>

---------

Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com>
2025-04-06 20:06:55 +00:00
..
bevy_a11y
bevy_animation Add PartialEq and Hash reflections for AnimationNodeIndex (#18718) 2025-04-04 16:35:12 +00:00
bevy_anti_aliasing
bevy_app Add Default for all schedule labels (#18731) 2025-04-06 16:44:33 +00:00
bevy_asset Add #[deprecated(since = "0.16.0", ...)] to items missing it (#18702) 2025-04-03 17:06:01 +00:00
bevy_audio
bevy_color fix typo (#18696) 2025-04-03 17:18:09 +00:00
bevy_core_pipeline Remove WebGL padding from MotionBlur (#18727) 2025-04-06 20:00:59 +00:00
bevy_derive
bevy_dev_tools
bevy_diagnostic Fix LogDiagnosticsPlugin log target typo (#18534) 2025-03-29 17:07:21 +00:00
bevy_dylib
bevy_ecs Add #[deprecated(since = "0.16.0", ...)] to items missing it (#18702) 2025-04-03 17:06:01 +00:00
bevy_encase_derive
bevy_gilrs reexport entity set collections in entity module (#18413) 2025-03-30 03:51:14 +00:00
bevy_gizmos Rename EntityBorrow/TrustedEntityBorrow to ContainsEntity/EntityEquivalent (#18470) 2025-03-30 06:04:26 +00:00
bevy_gltf reexport entity set collections in entity module (#18413) 2025-03-30 03:51:14 +00:00
bevy_image bevy_image: derive TypePath when Reflect is not available (#18501) 2025-03-30 02:50:24 +00:00
bevy_input
bevy_input_focus Switch ChildOf back to tuple struct (#18672) 2025-04-02 00:10:10 +00:00
bevy_internal Upgrade to Glam 0.29.3 and Simplify Feature Gating (#18638) 2025-03-31 18:54:46 +00:00
bevy_log
bevy_macro_utils
bevy_math Upgrade to Glam 0.29.3 and Simplify Feature Gating (#18638) 2025-03-31 18:54:46 +00:00
bevy_mesh
bevy_mikktspace Upgrade to Glam 0.29.3 and Simplify Feature Gating (#18638) 2025-03-31 18:54:46 +00:00
bevy_pbr Web support for atmosphere (#18582) 2025-04-06 20:06:55 +00:00
bevy_picking Newtype hashbrown (#18694) 2025-04-06 17:52:49 +00:00
bevy_platform_support Newtype hashbrown (#18694) 2025-04-06 17:52:49 +00:00
bevy_ptr
bevy_reflect Add accessors to DynamicEnum for the DynamicVariant (#18693) 2025-04-05 02:33:00 +00:00
bevy_remote Add Default for all schedule labels (#18731) 2025-04-06 16:44:33 +00:00
bevy_render Add Default for all schedule labels (#18731) 2025-04-06 16:44:33 +00:00
bevy_scene Newtype hashbrown (#18694) 2025-04-06 17:52:49 +00:00
bevy_sprite Parallelize bevy 0.16-rc bottlenecks (#18632) 2025-03-31 18:32:45 +00:00
bevy_state Add Default for all schedule labels (#18731) 2025-04-06 16:44:33 +00:00
bevy_tasks
bevy_text Switch ChildOf back to tuple struct (#18672) 2025-04-02 00:10:10 +00:00
bevy_time
bevy_transform Switch ChildOf back to tuple struct (#18672) 2025-04-02 00:10:10 +00:00
bevy_ui Switch ChildOf back to tuple struct (#18672) 2025-04-02 00:10:10 +00:00
bevy_utils
bevy_window Rename EntityBorrow/TrustedEntityBorrow to ContainsEntity/EntityEquivalent (#18470) 2025-03-30 06:04:26 +00:00
bevy_winit Switch ChildOf back to tuple struct (#18672) 2025-04-02 00:10:10 +00:00