DistanceFog has no effect on Adreno 830/840 (Vulkan): apply_fog returns the colour unfogged

Open
#26,551 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
android, rust

Research direction

Start in crates/bevy_pbr/src/render/pbr_functions.wesl, in main_pass_post_lighting_processing, where apply_fog receives view_bindings::fog directly. The reported workaround copies that uniform into a local variable first, so try it there and check whether the fog behaves the same. Done means the fog renders on the affected Adreno devices without changing results on desktop, which needs an Android device to verify.

Written by the indexing model from the issue text.

Description

C-Bug S-Needs-Triage

Bevy version and features

0.20.1, with the android-native-activity feature. The same call is still in main.

Relevant system information

Two Android phones, both affected:

  • Adreno (TM) 840, Vulkan, Android 16 (OnePlus CPH2747).
    Driver Build: bd918c8d8b, Id7378d798a, 1781154747, Date: 06/11/26, Compiler Version: E031.50.19.31
  • Adreno (TM) 830, Vulkan, Android 17 (OnePlus CPH2671).
    Driver Build: 53a40df626, I4a8465d626, 1790589655, Date: 09/28/26, Compiler Version: E031.47.18.56

Desktop (Linux, Vulkan) draws the fog correctly from the same code.

What you did

Added DistanceFog with FogFalloff::Linear { start: 24.0, end: 100.0 } to a
non-HDR Camera3d (with Msaa::Off and NoIndirectDrawing) in a scene with
one shadow-casting DirectionalLight and StandardMaterial meshes.

What went wrong

On both phones no surface is fogged at any distance. Nothing is logged: no
shader, pipeline or validation error. ExponentialSquared falloff behaves the
same way.

Additional information

I narrowed it down with a custom Material whose fragment shader imports
mesh_view_bindings::fog and colours its output by the result of each test.
On the phones:

Test in the fragment shader Result
Read fog.mode, fog.be.xy, fog.base_color directly correct values
fog::linear_fog(fog, color, 200.0, vec3(0.0)) fogged (correct)
pbr_functions::apply_fog(fog, color, far, eye, frag_coord) unfogged
var f = fog; pbr_functions::apply_fog(f, color, far, eye, frag_coord) fogged (correct)
A copy of apply_fog without the scattering block, called with fog unfogged
The same copy ending in a direct linear_fog call instead of the if mode == … chain fogged (correct)

So the uniform data is fine. The call fails only when the uniform struct is
passed directly as the argument of a function that contains the
if fog_params.mode == … chain. Copying the uniform into a local variable
first makes the same call work. This looks like an Adreno driver compiler bug.

All of these tests give the fogged result on desktop.

Workaround

Changing the one call in main_pass_post_lighting_processing
(crates/bevy_pbr/src/render/pbr_functions.wesl) fixes the fog on both phones:

// before
output_color = apply_fog(
    view_bindings::fog,
    ...

// after
var fog_params = view_bindings::fog;
output_color = apply_fog(
    fog_params,
    ...
Dominant language
Rust
Stars
49.8k
Forks
5.1k
Avg merge
3d 4h
Merged PRs (30d)
136

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bevyengine/bevy

All issues in bevyengine/bevy

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.