Skip to content

Commit d90c65d

Browse files
TotalKrillcartmockersf
authored
Fix WebGL mode for Adreno GPUs (#8508)
# Objective - This fixes a crash when loading shaders, when running an Adreno GPU and using WebGL mode. - Fixes #8506 - Fixes #8047 ## Solution - The shader pbr_functions.wgsl, will fail in apply_fog function, trying to access values that are null on Adreno chipsets using WebGL, these devices are commonly found in android handheld devices. --------- Co-authored-by: Carter Anderson <[email protected]> Co-authored-by: François <[email protected]>
1 parent aeeb20e commit d90c65d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

crates/bevy_pbr/src/render/light.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ pub struct GpuLights {
216216

217217
// NOTE: this must be kept in sync with the same constants in pbr.frag
218218
pub const MAX_UNIFORM_BUFFER_POINT_LIGHTS: usize = 256;
219+
220+
//NOTE: When running bevy on Adreno GPU chipsets in WebGL, any value above 1 will result in a crash
221+
// when loading the wgsl "pbr_functions.wgsl" in the function apply_fog.
222+
#[cfg(all(feature = "webgl", target_arch = "wasm32"))]
223+
pub const MAX_DIRECTIONAL_LIGHTS: usize = 1;
224+
#[cfg(any(not(feature = "webgl"), not(target_arch = "wasm32")))]
219225
pub const MAX_DIRECTIONAL_LIGHTS: usize = 10;
220226
#[cfg(any(not(feature = "webgl"), not(target_arch = "wasm32")))]
221227
pub const MAX_CASCADES_PER_LIGHT: usize = 4;

0 commit comments

Comments
 (0)