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

オープン 初心者向け
#26,558 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust

調査の方向性

calculate_visible_sun_ratio から始めます。bevy_pbr/src/atmosphere/functions.wesl で天頂余弦が fast_acos_4 に入る箇所を読み、bevy_pbr/src/render/pbr_lighting.wesl にある、クランプされていない内積 mu_light と比較してください。真下を向いた平行光源を Atmosphere カメラの下に置いて再現し、太陽直下点付近に暗い斑点が出ないか確認します。照らされた面が一様に明るく、すべてのピクセルで太陽の可視性が有限の値に保たれていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

изображение изображение
主要言語
Rust
スター
49.7k
フォーク
5k
平均マージ
3日 16時間
マージ済み PR(30日)
128

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

bevyengine/bevy のほかの issue

bevyengine/bevy の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。