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

Wrong lightness of textures with alpha channel and translucent pixels on Android #40541

Closed
Ralf12358 opened this issue Jul 20, 2020 · 4 comments

Comments

@Ralf12358
Copy link

Godot version:
Head on Branch 3.2: 89f57ae
Reproduced on 3.2.3beta1, too. Probably older version are affected, too

OS/device including version:
GLES2, Android. Tested with Galaxy S7 Edge and Amazon Fire HD 8

Issue description:
Please read carefully. Issue description may sound strange, but it's an annoying and often subtle bug. Attached is a sample project to easily reproduce the problem on Android.
When adding a textured quad mesh with an alpha channel where at least on pixel has an alpha != 1.0 to a 3D scene. The quads on Android are rendered too dark (see screenshots below).

The "funny" part is:

  • If the quads are scaled from 1.0 to 2.0 the problem nearly disappears (This has caused me some headaches).
  • The problem is independently if "Transparent" is enabled in the spatial material or disabled.
  • If the png file of the texure has an alpha channel with all pixels completely opaque the problem disapears (The png may still have an alpha channel)

The problem is probably unrelated to the quad mesh and more related to dealing with textures on Andoird in general.

The screenshots below contain two pngs: One completely opaque, but with alpha channel. One with some transparent pixels.

Android Small (Here the problem is visible):
AndroidSmall

Linux Small:
LinuxSmall

Android Large:
AndroidLarge

Linux Large:
LinuxLarge

Steps to reproduce:
Best use attached sample project.
Create new 3D scene. Add camera. Add Light. Add two quad meshes. In on mesh use a texture with alpha channel and some transparent pixels in the other mesh us a texture completely opaque with alpha channel, too. Quads have to be the correct size (usually relative small) to reproduce the bug. On Android the two quad will have different lightness. On Linux and browser both quad will have the same lightness.

Minimal reproduction project:
GodotAlphaBug.zip

@Ralf12358
Copy link
Author

I forget: This problems occurs, even if the materials are declared Unshaded (!!!).

=> This seems a pure texture problem unrelated to the lightning

Attached is another screenshot from Android with materials set to "Unshaded". If you look closely you will recognize it is different to the other Android screenshot with shading enabled, but the problem persists, anyway: All textures should have the same lighness.

AlphaBug_Android_Unshaded

@Calinou
Copy link
Member

Calinou commented Jul 21, 2020

@Ralf12358 Double-check that the textures are imported with sRGB enabled. Also, does this occur if you change its compression mode to Uncompressed or Lossless in the Import dock?

VRAM compression uses ETC1 when using GLES2. That format doesn't support alpha channels. There's a proposal about adding a hack to make it support alpha channels, but you should be able to do it with a custom shader already.

@Ralf12358
Copy link
Author

@Calinou: That's it! I set the Compress mode manually to "Uncompressed" and the problem is, gone! Thank's. I think you can close the issue. It might be worth considering to automatically import textures with alpha pixels != 1.0 as uncompressed on GLES2, but that's up to you.

Thank's again.

@Calinou
Copy link
Member

Calinou commented Jul 21, 2020

@Ralf12358 Alright, I'll close this as a duplicate of #26211 then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants