godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.51k stars 21.07k forks source link

TextureRect renders as black when Stretch Mode is set to Tile on GLES2 #47955

Open Tekuzo opened 3 years ago

Tekuzo commented 3 years ago

Godot version:

3.2.3 and 3.3 RC9

OS/device including version:

iPhone SE (2nd version) running iOS 14.4.2. This bug was discovered using GLES2. When I switched rendering to GLES3 I did not encounter the bug.

Issue description:

A TextureRect when put into tile mode will only render as black. And not simply the texture, but the whole area of the texture rect will render as black. IMG_0151

Steps to reproduce: Make a scene with a texture rect, switch its stretch mode to tile. Make sure that the render mode is on GLES2. Export an iPhone project. Run in Xcode.

Minimal reproduction project:

I have created a sample project and removed my Team ID and Bundle ID (I hope) Sample Project.zip

Calinou commented 3 years ago

See https://github.com/godotengine/godot/issues/40373. This is supposed to be fixed, but apparently it's not working?

Can you reproduce this issue with GLES2 on your own desktop machine? (Also, which OS does it run?)

Tekuzo commented 3 years ago

My Desktop I dual boot with Windows 10 and Ubuntu (whatever the latest version is). I have an iMac that is running Big Sur and a M1 Macbook Air running Big Sir and my Android Phone is a Pixel 3 running Android 11.

I can not re-produce this on Windows, Mac, Linux or Android, it only seems to happen on GLES2 on iOS

volzhs commented 3 years ago

maybe similar issue with #32837?

Tekuzo commented 3 years ago

If the stretch mode is on Scale then the issue goes away as well.

lawnjelly commented 3 years ago

maybe similar issue with #32837?

If so, that bug was fixed by setting rendering/gles2/compatibility/disable_half_float. I haven't yet looked at the shader, but in the meantime this setting is worth a try.

Tekuzo commented 3 years ago

maybe similar issue with #32837?

If so, that bug was fixed by setting rendering/gles2/compatibility/disable_half_float. I haven't yet looked at the shader, but in the meantime this setting is worth a try.

I tried to disable this feature and there was no change I have attached a screenshot to demonstrate.

IMG_0154

lawnjelly commented 3 years ago

Does it work with a power of 2 texture size?

Tekuzo commented 3 years ago

Does it work with a power of 2 texture size?

Yes I made the texture 16 by 16 pixels and it rendered

lawnjelly commented 3 years ago

Ok that confirms the general area to look. I'll try and take a look tomorrow.

Incidentally, I would always recommend using POT textures on such hardware regardless, because it will usually run faster, and tiling in the fragment shader can be very slow / problematic on some hardware.

lawnjelly commented 3 years ago

When I force support_npot_repeat_mipmap to false, and emulate what might be happening on npot hardware on desktop, it does work correctly for me (that was #40373) so this is a different bug.

You could try it with batching disabled, I suspect it will not work either.

This may be rather difficult to solve without the hardware in question. It may be something in the force repeat shader it doesn't like.

Tekuzo commented 3 years ago

Should I try this with batching disabled on 3.3 stable now?

lawnjelly commented 3 years ago

Should I try this with batching disabled on 3.3 stable now?

Yup sure. That will enable us to know better the rough area that is failing.

Tekuzo commented 3 years ago

I just tried with batching disabled on 3.3 stable

exported an iOS project, ran on my iPhone

No change. still rendered as a black box.