Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in volumetric fog shader #16677

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions crates/bevy_pbr/src/volumetric_fog/volumetric_fog.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,11 @@ fn fragment(@builtin(position) position: vec4<f32>) -> @location(0) vec4<f32> {
let view_z = view_start_pos.z;
let is_orthographic = view.clip_from_view[3].w == 1.0;
let cluster_index = clustering::fragment_cluster_index(frag_coord.xy, view_z, is_orthographic);
let offset_and_counts = clustering::unpack_offset_and_counts(cluster_index);
let spot_light_start_index = offset_and_counts[0] + offset_and_counts[1];
for (var i: u32 = offset_and_counts[0]; i < offset_and_counts[0] + offset_and_counts[1] + offset_and_counts[2]; i = i + 1u) {
var clusterable_object_index_ranges =
clustering::unpack_clusterable_object_index_ranges(cluster_index);
for (var i: u32 = clusterable_object_index_ranges.first_point_light_index_offset;
i < clusterable_object_index_ranges.first_reflection_probe_index_offset;
i = i + 1u) {
let light_id = clustering::get_clusterable_object_id(i);
let light = &clusterable_objects.data[light_id];
if (((*light).flags & POINT_LIGHT_FLAGS_VOLUMETRIC_BIT) == 0) {
Expand Down Expand Up @@ -340,7 +342,7 @@ fn fragment(@builtin(position) position: vec4<f32>) -> @location(0) vec4<f32> {
let distance_square = dot(light_to_frag, light_to_frag);
let distance_atten = getDistanceAttenuation(distance_square, (*light).color_inverse_square_range.w);
var local_light_attenuation = distance_atten;
if (i < spot_light_start_index) {
if (i < clusterable_object_index_ranges.first_spot_light_index_offset) {
var shadow: f32 = 1.0;
if (((*light).flags & POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
shadow = fetch_point_shadow_without_normal(light_id, vec4(P_world, 1.0));
Expand Down
Loading