bevyengine / bevyengine/bevy

Transparency doesnt work when on webgl adreno devices

Open
#10,066 10 comments 0 reactions 0 assignees View on GitHub
A-Rendering C-Bug O-WebGL2 S-Needs-Investigation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

bevy 0.11.3, 0.10.x, and looking at the code, most likely on main as well

## Relevant system information

Most adreno devices tested, currently dont have one on hand. But I assume someone can verify. I guess this might also affect android devices

```ignore
`AdapterInfo { name: "Adreno 660", backend: WebGL }`
```

## What you did

The blend_modes example shows this quite well on Adreno devices on webgl, using this wasm-web-runner branch

`cargo install --git https://github.com/heisencoder/wasm-server-runner.git --branch
feature/support-gzip wasm-server-runner`

to host the example from another computer. Opaque flags are ignored and all balls are either entirerly invisible, or fully visible, no translucency

## Investigation

Looking at the [unity docs](https://docs.unity3d.com/es/530/Manual/SL-DataTypesAndPrecision.html), there are references to some types being 16bit in quite a few of the mobile GPU shader hardware. And when @gnargfu investigated, he found that this [commit](https://gitlab.com/insight-public/bevy/-/commit/738bd45a585075daeaf9987e7ab3564e5326a37c) solves it. (basically moves the bitflags to the lower 16 bits in the flags field, used to branch in the shader code, so their position in the flag field of the struct doesnt matter)

Probably, a lot of the crashes related to mobile devices, are in fact due to shader code being introduced, that assumes that all values are high precision.

Quote from [unity docs](https://docs.unity3d.com/es/530/Manual/SL-DataTypesAndPrecision.html)

> Precision, Hardware Support and Performance
> One complication of float/half/fixed data type usage is that PC GPUs are always high precision. That is, for all the PC (Windows/Mac/Linux) GPUs, it does not matter whether you write float, half or fixed data types in your shaders. They always compute everything in full 32-bit floating point precision.
>
> The half and fixed types only become relevant when targeting mobile GPUs, where these types primarily exist for power (and sometimes performance) constraints. Keep in mind that you need to test your shaders on mobile to see whether or not you are running into precision/numerical issues.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.