Atmosphere: dark speckles on lit surfaces when the sun is at zenith (NaN in calculate_visible_sun_ratio)

Đang mở Phù hợp với người mới
#26,558 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
computer-graphics

Hướng nghiên cứu

Bắt đầu từ calculate_visible_sun_ratio trong bevy_pbr/src/atmosphere/functions.wesl, nơi côsin thiên đỉnh được đưa vào fast_acos_4, rồi so sánh với tích vô hướng không bị giới hạn mu_light trong bevy_pbr/src/render/pbr_lighting.wesl. Tái hiện bằng một đèn định hướng chiếu thẳng xuống dưới camera Atmosphere, và kiểm tra các đốm tối gần điểm subsolar. Hoàn thành khi bề mặt được chiếu sáng đồng đều và độ hiển thị của mặt trời luôn hữu hạn ở mọi pixel.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

C-Bug S-Needs-Triage

Bevy version and features

  • 0.20.1
  • Default features; the camera uses Atmosphere + AtmosphereSettings.

[Optional] Relevant system information

  • cargo 1.99.1 (5f94df478 2026-08-27)
  • Windows 11
AdapterInfo { name: "NVIDIA GeForce RTX 5080", vendor: 4318, device: 11266, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "616.92", backend: Vulkan }

What you did

A scene with an atmosphere on the camera and a directional light (the sun) pointing
straight down, i.e. the sun is exactly at the local zenith of the lit surface.

What went wrong

  • Expected: surfaces under the sun are evenly lit.
  • Actual: random pixels on lit surfaces lose all direct sunlight (only scattered light
    remains), which looks like dark speckles. They appear within a few tens of meters
    around the subsolar point and are gone about 100 m away from it.

Additional information

Theory: a NaN in calculate_visible_sun_ratio.

bevy_pbr/src/render/pbr_lighting.wesl:

let mu_light = dot(L, local_up); // not clamped, can be slightly > 1.0 due to f32 rounding

bevy_pbr/src/atmosphere/functions.wesl, calculate_visible_sun_ratio:

let sun_zenith_angle = fast_acos_4(mu);

fast_acos_4 computes sqrt(1.0 - abs(x)), which is NaN for |x| > 1. The visibility
ratio then becomes 0, and color *= transmittance * sun_visibility removes the sun
light for that pixel. sample_sun_radiance in the same file already clamps its argument.

Workaround / proposed fix (one line):

let sun_zenith_angle = fast_acos_4(clamp(mu, -1.0, 1.0));

With this change the speckles are gone. Reproduced with two different atmosphere
setups, always around the point where the sun is exactly overhead. Tested on one
machine only. Before/after screenshots attached.

изображение изображение
Ngôn ngữ chính
Rust
Star
49.7k
Fork
5k
Merge trung bình
3 ngày 16 giờ
Pull request đã merge (30 ngày)
128

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của bevyengine/bevy

Tất cả issue của bevyengine/bevy

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.