playcanvas / engine

JavaScript game engine built on WebGL, WebGPU, WebXR and glTF
https://playcanvas.com
MIT License
9.69k stars 1.36k forks source link

>4K sprite texture as UI element does not render correctly when spriteFrame is changed #3119

Open yaustar opened 3 years ago

yaustar commented 3 years ago

Thread:: https://forum.playcanvas.com/t/change-image-ui-sprite-in-runtime/19700/5 Project: https://playcanvas.com/editor/scene/1138025

On desktop: image

On Android chrome: image

It renders correctly if it's a sprite component but not as a UI element.

My guess is that the texture height >4K so gets downsampled by the engine and has affected the UI rendering in some way.

Making the texture 50% smaller worksaround the issue.

mvaligursky commented 3 years ago

We had related discussion last week. It seems the UI system internally operates using pixel coordinates (not normalized to 0..1 range) and so does not handle texture resizing. When the texture is larger than what device supports, it will get resized to maximum supported, and that likely breaks the rendering here.

We can either change how the system works, or at least have some in-Editor warning when textures is >4k.

yaustar commented 3 years ago

Maybe a warning to start with while we rework the system?

Edit: Although some devices may support higher resolutions and others may support lower so a warning won't help much here 🤔

yaustar commented 2 years ago

Revoting for in editor warning about using >4K textures