diff --git a/crates/bevy_pbr/src/render/mesh_functions.wgsl b/crates/bevy_pbr/src/render/mesh_functions.wgsl index 19ddfc64f5959..ce8e9701271a5 100644 --- a/crates/bevy_pbr/src/render/mesh_functions.wgsl +++ b/crates/bevy_pbr/src/render/mesh_functions.wgsl @@ -1,7 +1,11 @@ #define_import_path bevy_pbr::mesh_functions #import bevy_pbr::{ - mesh_view_bindings::{view, visibility_ranges}, + mesh_view_bindings::{ + view, + visibility_ranges, + VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE + }, mesh_bindings::mesh, mesh_types::MESH_FLAGS_SIGN_DETERMINANT_MODEL_3X3_BIT, view_transformations::position_world_to_clip, @@ -94,8 +98,8 @@ fn get_visibility_range_dither_level(instance_index: u32, world_position: vec4= 6 - // If we're using a uniform buffer, then the length is *exactly* 64. - let visibility_buffer_array_len = 64u; + // If we're using a uniform buffer, then the length is constant + let visibility_buffer_array_len = VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE; #endif // AVAILABLE_STORAGE_BUFFER_BINDINGS >= 6 let visibility_buffer_index = mesh[instance_index].flags & 0xffffu; diff --git a/crates/bevy_pbr/src/render/mesh_view_bindings.wgsl b/crates/bevy_pbr/src/render/mesh_view_bindings.wgsl index 415ecf6b9a487..b8e74c60b8b43 100644 --- a/crates/bevy_pbr/src/render/mesh_view_bindings.wgsl +++ b/crates/bevy_pbr/src/render/mesh_view_bindings.wgsl @@ -35,12 +35,11 @@ @group(0) @binding(10) var fog: types::Fog; @group(0) @binding(11) var light_probes: types::LightProbes; -// NB: If you change this `#if`, make sure to update the corresponding `#if` in -// `mesh_functions.wgsl` too. +const VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE: u32 = 64u; #if AVAILABLE_STORAGE_BUFFER_BINDINGS >= 6 @group(0) @binding(12) var visibility_ranges: array>; #else -@group(0) @binding(12) var visibility_ranges: array, 64u>; +@group(0) @binding(12) var visibility_ranges: array, VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE>; #endif @group(0) @binding(13) var screen_space_ambient_occlusion_texture: texture_2d;