Skip to content

Commit 5b1f0b1

Browse files
authored
Fix error in volumetric fog shader (#16677)
# Objective Volumetric fog was broken by #13746. Looks like this particular shader just got missed. I don't see any other instances of `unpack_offset_and_counts` in the codebase. ``` 2024-12-06T03:18:42.297494Z ERROR bevy_render::render_resource::pipeline_cache: failed to process shader: error: no definition in scope for identifier: 'bevy_pbr::clustered_forward::unpack_offset_and_counts' ┌─ crates/bevy_pbr/src/volumetric_fog/volumetric_fog.wgsl:312:29 │ 312 │ let offset_and_counts = bevy_pbr::clustered_forward::unpack_offset_and_counts(cluster_index); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unknown identifier │ = no definition in scope for identifier: 'bevy_pbr::clustered_forward::unpack_offset_and_counts' ``` ## Solution Use `unpack_clusterable_object_index_ranges` to get the indices for point/spot lights. ## Testing `cargo run --example volumetric_fog` `cargo run --example fog_volumes` `cargo run --example scrolling_fog`
1 parent 24c3bd5 commit 5b1f0b1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crates/bevy_pbr/src/volumetric_fog/volumetric_fog.wgsl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,11 @@ fn fragment(@builtin(position) position: vec4<f32>) -> @location(0) vec4<f32> {
309309
let view_z = view_start_pos.z;
310310
let is_orthographic = view.clip_from_view[3].w == 1.0;
311311
let cluster_index = clustering::fragment_cluster_index(frag_coord.xy, view_z, is_orthographic);
312-
let offset_and_counts = clustering::unpack_offset_and_counts(cluster_index);
313-
let spot_light_start_index = offset_and_counts[0] + offset_and_counts[1];
314-
for (var i: u32 = offset_and_counts[0]; i < offset_and_counts[0] + offset_and_counts[1] + offset_and_counts[2]; i = i + 1u) {
312+
var clusterable_object_index_ranges =
313+
clustering::unpack_clusterable_object_index_ranges(cluster_index);
314+
for (var i: u32 = clusterable_object_index_ranges.first_point_light_index_offset;
315+
i < clusterable_object_index_ranges.first_reflection_probe_index_offset;
316+
i = i + 1u) {
315317
let light_id = clustering::get_clusterable_object_id(i);
316318
let light = &clusterable_objects.data[light_id];
317319
if (((*light).flags & POINT_LIGHT_FLAGS_VOLUMETRIC_BIT) == 0) {
@@ -340,7 +342,7 @@ fn fragment(@builtin(position) position: vec4<f32>) -> @location(0) vec4<f32> {
340342
let distance_square = dot(light_to_frag, light_to_frag);
341343
let distance_atten = getDistanceAttenuation(distance_square, (*light).color_inverse_square_range.w);
342344
var local_light_attenuation = distance_atten;
343-
if (i < spot_light_start_index) {
345+
if (i < clusterable_object_index_ranges.first_spot_light_index_offset) {
344346
var shadow: f32 = 1.0;
345347
if (((*light).flags & POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
346348
shadow = fetch_point_shadow_without_normal(light_id, vec4(P_world, 1.0));

0 commit comments

Comments
 (0)